Skip to content

Commit

Permalink
style(naming): use libxml2 struct names for typed data name
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Feb 2, 2024
1 parent 6ce44bf commit f42d6f6
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 94 deletions.
32 changes: 16 additions & 16 deletions ext/nokogiri/html4_element_description.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <nokogiri.h>

static const rb_data_type_t html4_element_description_type = {
.wrap_struct_name = "Nokogiri::HTML4::ElementDescription",
static const rb_data_type_t html_elem_desc_type = {
.wrap_struct_name = "htmlElemDesc",
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};

Expand All @@ -20,7 +20,7 @@ required_attributes(VALUE self)
VALUE list;
int i;

TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

list = rb_ary_new();

Expand All @@ -46,7 +46,7 @@ deprecated_attributes(VALUE self)
VALUE list;
int i;

TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

list = rb_ary_new();

Expand All @@ -72,7 +72,7 @@ optional_attributes(VALUE self)
VALUE list;
int i;

TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

list = rb_ary_new();

Expand All @@ -95,7 +95,7 @@ static VALUE
default_sub_element(VALUE self)
{
const htmlElemDesc *description;
TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

if (description->defaultsubelt) {
return NOKOGIRI_STR_NEW2(description->defaultsubelt);
Expand All @@ -117,7 +117,7 @@ sub_elements(VALUE self)
VALUE list;
int i;

TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

list = rb_ary_new();

Expand All @@ -140,7 +140,7 @@ static VALUE
description(VALUE self)
{
const htmlElemDesc *description;
TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

return NOKOGIRI_STR_NEW2(description->desc);
}
Expand All @@ -155,7 +155,7 @@ static VALUE
inline_eh(VALUE self)
{
const htmlElemDesc *description;
TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

if (description->isinline) { return Qtrue; }
return Qfalse;
Expand All @@ -171,7 +171,7 @@ static VALUE
deprecated_eh(VALUE self)
{
const htmlElemDesc *description;
TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

if (description->depr) { return Qtrue; }
return Qfalse;
Expand All @@ -187,7 +187,7 @@ static VALUE
empty_eh(VALUE self)
{
const htmlElemDesc *description;
TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

if (description->empty) { return Qtrue; }
return Qfalse;
Expand All @@ -203,7 +203,7 @@ static VALUE
save_end_tag_eh(VALUE self)
{
const htmlElemDesc *description;
TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

if (description->saveEndTag) { return Qtrue; }
return Qfalse;
Expand All @@ -219,7 +219,7 @@ static VALUE
implied_end_tag_eh(VALUE self)
{
const htmlElemDesc *description;
TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

if (description->endTag) { return Qtrue; }
return Qfalse;
Expand All @@ -235,7 +235,7 @@ static VALUE
implied_start_tag_eh(VALUE self)
{
const htmlElemDesc *description;
TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

if (description->startTag) { return Qtrue; }
return Qfalse;
Expand All @@ -251,7 +251,7 @@ static VALUE
name(VALUE self)
{
const htmlElemDesc *description;
TypedData_Get_Struct(self, htmlElemDesc, &html4_element_description_type, description);
TypedData_Get_Struct(self, htmlElemDesc, &html_elem_desc_type, description);

if (NULL == description->name) { return Qnil; }
return NOKOGIRI_STR_NEW2(description->name);
Expand All @@ -271,7 +271,7 @@ get_description(VALUE klass, VALUE tag_name)
);

if (NULL == description) { return Qnil; }
return TypedData_Wrap_Struct(klass, &html4_element_description_type, DISCARD_CONST_QUAL(void *, description));
return TypedData_Wrap_Struct(klass, &html_elem_desc_type, DISCARD_CONST_QUAL(void *, description));
}

void
Expand Down
8 changes: 4 additions & 4 deletions ext/nokogiri/xml_document.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ memsize(const void *data)
return memsize;
}

static const rb_data_type_t noko_xml_document_data_type = {
.wrap_struct_name = "Nokogiri::XML::Document",
static const rb_data_type_t xml_doc_type = {
.wrap_struct_name = "xmlDoc",
.function = {
.dmark = mark,
.dfree = dealloc,
Expand All @@ -146,7 +146,7 @@ static const rb_data_type_t noko_xml_document_data_type = {
static VALUE
_xml_document_alloc(VALUE klass)
{
return TypedData_Wrap_Struct(klass, &noko_xml_document_data_type, NULL);
return TypedData_Wrap_Struct(klass, &xml_doc_type, NULL);
}

static void
Expand Down Expand Up @@ -707,7 +707,7 @@ xmlDocPtr
noko_xml_document_unwrap(VALUE rb_document)
{
xmlDocPtr c_document;
TypedData_Get_Struct(rb_document, xmlDoc, &noko_xml_document_data_type, c_document);
TypedData_Get_Struct(rb_document, xmlDoc, &xml_doc_type, c_document);
return c_document;
}

Expand Down
18 changes: 9 additions & 9 deletions ext/nokogiri/xml_element_content.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

VALUE cNokogiriXmlElementContent;

static const rb_data_type_t element_content_data_type = {
.wrap_struct_name = "Nokogiri::XML::ElementContent",
static const rb_data_type_t xml_element_content_type = {
.wrap_struct_name = "xmlElementContent",
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};

Expand All @@ -17,7 +17,7 @@ static VALUE
get_name(VALUE self)
{
xmlElementContentPtr elem;
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);

if (!elem->name) { return Qnil; }
return NOKOGIRI_STR_NEW2(elem->name);
Expand All @@ -33,7 +33,7 @@ static VALUE
get_type(VALUE self)
{
xmlElementContentPtr elem;
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);

return INT2NUM(elem->type);
}
Expand All @@ -45,7 +45,7 @@ static VALUE
get_c1(VALUE self)
{
xmlElementContentPtr elem;
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);

if (!elem->c1) { return Qnil; }
return noko_xml_element_content_wrap(rb_iv_get(self, "@document"), elem->c1);
Expand All @@ -58,7 +58,7 @@ static VALUE
get_c2(VALUE self)
{
xmlElementContentPtr elem;
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);

if (!elem->c2) { return Qnil; }
return noko_xml_element_content_wrap(rb_iv_get(self, "@document"), elem->c2);
Expand All @@ -74,7 +74,7 @@ static VALUE
get_occur(VALUE self)
{
xmlElementContentPtr elem;
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);

return INT2NUM(elem->ocur);
}
Expand All @@ -89,7 +89,7 @@ static VALUE
get_prefix(VALUE self)
{
xmlElementContentPtr elem;
TypedData_Get_Struct(self, xmlElementContent, &element_content_data_type, elem);
TypedData_Get_Struct(self, xmlElementContent, &xml_element_content_type, elem);

if (!elem->prefix) { return Qnil; }

Expand All @@ -104,7 +104,7 @@ noko_xml_element_content_wrap(VALUE rb_document, xmlElementContentPtr c_element_
{
VALUE elem = TypedData_Wrap_Struct(
cNokogiriXmlElementContent,
&element_content_data_type,
&xml_element_content_type,
c_element_content
);

Expand Down
8 changes: 4 additions & 4 deletions ext/nokogiri/xml_encoding_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ xml_encoding_handler_dealloc(void *data)
xmlCharEncCloseFunc(c_handler);
}

static const rb_data_type_t xml_encoding_handler_type = {
.wrap_struct_name = "Nokogiri::EncodingHandler",
static const rb_data_type_t xml_char_encoding_handler_type = {
.wrap_struct_name = "xmlCharEncodingHandler",
.function = {
.dfree = xml_encoding_handler_dealloc,
},
Expand All @@ -31,7 +31,7 @@ rb_xml_encoding_handler_s_get(VALUE klass, VALUE key)

handler = xmlFindCharEncodingHandler(StringValueCStr(key));
if (handler) {
return TypedData_Wrap_Struct(klass, &xml_encoding_handler_type, handler);
return TypedData_Wrap_Struct(klass, &xml_char_encoding_handler_type, handler);
}

return Qnil;
Expand Down Expand Up @@ -90,7 +90,7 @@ rb_xml_encoding_handler_name(VALUE self)
{
xmlCharEncodingHandlerPtr handler;

TypedData_Get_Struct(self, xmlCharEncodingHandler, &xml_encoding_handler_type, handler);
TypedData_Get_Struct(self, xmlCharEncodingHandler, &xml_char_encoding_handler_type, handler);

return NOKOGIRI_STR_NEW2(handler->name);
}
Expand Down
12 changes: 6 additions & 6 deletions ext/nokogiri/xml_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ _xml_namespace_update_references(void *ptr)
}
}

static const rb_data_type_t nokogiri_xml_namespace_type_with_dealloc = {
.wrap_struct_name = "Nokogiri::XML::Namespace#with_dealloc",
static const rb_data_type_t xml_ns_type_with_free = {
.wrap_struct_name = "xmlNs (with free)",
.function = {
.dfree = _xml_namespace_dealloc,
.dcompact = _xml_namespace_update_references,
},
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};

static const rb_data_type_t nokogiri_xml_namespace_type_without_dealloc = {
.wrap_struct_name = "Nokogiri::XML::Namespace#without_dealloc",
static const rb_data_type_t xml_ns_type_without_free = {
.wrap_struct_name = "xmlNs (without free)",
.function = {
.dcompact = _xml_namespace_update_references,
},
Expand Down Expand Up @@ -145,7 +145,7 @@ noko_xml_namespace_wrap(xmlNsPtr c_namespace, xmlDocPtr c_document)

if (c_document) {
rb_namespace = TypedData_Wrap_Struct(cNokogiriXmlNamespace,
&nokogiri_xml_namespace_type_without_dealloc,
&xml_ns_type_without_free,
c_namespace);

if (DOC_RUBY_OBJECT_TEST(c_document)) {
Expand All @@ -154,7 +154,7 @@ noko_xml_namespace_wrap(xmlNsPtr c_namespace, xmlDocPtr c_document)
}
} else {
rb_namespace = TypedData_Wrap_Struct(cNokogiriXmlNamespace,
&nokogiri_xml_namespace_type_with_dealloc,
&xml_ns_type_with_free,
c_namespace);
}

Expand Down
6 changes: 3 additions & 3 deletions ext/nokogiri/xml_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ _xml_node_update_references(void *ptr)
}
}

static const rb_data_type_t nokogiri_node_type = {
.wrap_struct_name = "Nokogiri::XML::Node",
static const rb_data_type_t xml_node_type = {
.wrap_struct_name = "xmlNode",
.function = {
.dmark = _xml_node_mark,
.dcompact = _xml_node_update_references,
Expand All @@ -50,7 +50,7 @@ static const rb_data_type_t nokogiri_node_type = {
static VALUE
_xml_node_alloc(VALUE klass)
{
return TypedData_Wrap_Struct(klass, &nokogiri_node_type, NULL);
return TypedData_Wrap_Struct(klass, &xml_node_type, NULL);
}

static void
Expand Down
2 changes: 1 addition & 1 deletion ext/nokogiri/xml_node_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ xml_node_set_deallocate(void *data)
}

static const rb_data_type_t xml_node_set_type = {
.wrap_struct_name = "Nokogiri::XML::NodeSet",
.wrap_struct_name = "xmlNodeSet",
.function = {
.dmark = xml_node_set_mark,
.dfree = xml_node_set_deallocate,
Expand Down
Loading

0 comments on commit f42d6f6

Please sign in to comment.