File: ruby_xml_schema_facet.c

package info (click to toggle)
ruby-libxml 5.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,804 kB
  • sloc: xml: 18,263; ansic: 7,669; ruby: 5,809; makefile: 6
file content (50 lines) | stat: -rw-r--r-- 1,199 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "ruby_libxml.h"
#include "ruby_xml_schema_facet.h"

#include <libxml/schemasInternals.h>
#include <libxml/xmlschemas.h>
#include <libxml/xmlschemastypes.h>

VALUE cXMLSchemaFacet;

static void rxml_schema_facet_free(xmlSchemaFacetPtr xschema_type)
{
  xschema_type = NULL;
  xmlFree(xschema_type);
}

VALUE rxml_wrap_schema_facet(xmlSchemaFacetPtr facet)
{
  VALUE result;

  if (!facet)
    rb_raise(rb_eArgError, "XML::Schema::Facet required!");

  result = Data_Wrap_Struct(cXMLSchemaFacet, NULL, rxml_schema_facet_free, facet);

  rb_iv_set(result, "@kind", INT2NUM(facet->type));
  rb_iv_set(result, "@value", QNIL_OR_STRING(facet->value));

  return result;

}

/* START FACET*/

static VALUE rxml_schema_facet_node(VALUE self)
{
  xmlSchemaFacetPtr facet;

  Data_Get_Struct(self, xmlSchemaFacet, facet);

  return rxml_node_wrap(facet->node);
}

void rxml_init_schema_facet(void)
{
  cXMLSchemaFacet = rb_define_class_under(cXMLSchema, "Facet", rb_cObject);
  rb_define_attr(cXMLSchemaFacet, "kind", 1, 0);
  rb_define_attr(cXMLSchemaFacet, "value", 1, 0);

  rb_define_method(cXMLSchemaFacet, "node", rxml_schema_facet_node, 0);
}