Skip to content

Instantly share code, notes, and snippets.

@Skarsnik
Created March 9, 2016 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skarsnik/6556f4cdbc774b72679b to your computer and use it in GitHub Desktop.
Save Skarsnik/6556f4cdbc774b72679b to your computer and use it in GitHub Desktop.
## Enumerations
# == /usr/local/include/gumbo.h ==
enum GumboTag is export (
GUMBO_TAG_HTML => 0,
GUMBO_TAG_HEAD => 1,
GUMBO_TAG_TITLE => 2,
GUMBO_TAG_BASE => 3,
GUMBO_TAG_LINK => 4,
GUMBO_TAG_META => 5,
GUMBO_TAG_STYLE => 6,
GUMBO_TAG_SCRIPT => 7,
GUMBO_TAG_NOSCRIPT => 8,
GUMBO_TAG_TEMPLATE => 9,
GUMBO_TAG_BODY => 10,
GUMBO_TAG_ARTICLE => 11,
GUMBO_TAG_SECTION => 12,
GUMBO_TAG_NAV => 13,
GUMBO_TAG_ASIDE => 14,
GUMBO_TAG_H1 => 15,
GUMBO_TAG_H2 => 16,
GUMBO_TAG_H3 => 17,
GUMBO_TAG_H4 => 18,
GUMBO_TAG_H5 => 19,
GUMBO_TAG_H6 => 20,
GUMBO_TAG_HGROUP => 21,
GUMBO_TAG_HEADER => 22,
GUMBO_TAG_FOOTER => 23,
GUMBO_TAG_ADDRESS => 24,
GUMBO_TAG_P => 25,
GUMBO_TAG_HR => 26,
GUMBO_TAG_PRE => 27,
GUMBO_TAG_BLOCKQUOTE => 28,
GUMBO_TAG_OL => 29,
GUMBO_TAG_UL => 30,
GUMBO_TAG_LI => 31,
GUMBO_TAG_DL => 32,
GUMBO_TAG_DT => 33,
GUMBO_TAG_DD => 34,
GUMBO_TAG_FIGURE => 35,
GUMBO_TAG_FIGCAPTION => 36,
GUMBO_TAG_MAIN => 37,
GUMBO_TAG_DIV => 38,
GUMBO_TAG_A => 39,
GUMBO_TAG_EM => 40,
GUMBO_TAG_STRONG => 41,
GUMBO_TAG_SMALL => 42,
GUMBO_TAG_S => 43,
GUMBO_TAG_CITE => 44,
GUMBO_TAG_Q => 45,
GUMBO_TAG_DFN => 46,
GUMBO_TAG_ABBR => 47,
GUMBO_TAG_DATA => 48,
GUMBO_TAG_TIME => 49,
GUMBO_TAG_CODE => 50,
GUMBO_TAG_VAR => 51,
GUMBO_TAG_SAMP => 52,
GUMBO_TAG_KBD => 53,
GUMBO_TAG_SUB => 54,
GUMBO_TAG_SUP => 55,
GUMBO_TAG_I => 56,
GUMBO_TAG_B => 57,
GUMBO_TAG_U => 58,
GUMBO_TAG_MARK => 59,
GUMBO_TAG_RUBY => 60,
GUMBO_TAG_RT => 61,
GUMBO_TAG_RP => 62,
GUMBO_TAG_BDI => 63,
GUMBO_TAG_BDO => 64,
GUMBO_TAG_SPAN => 65,
GUMBO_TAG_BR => 66,
GUMBO_TAG_WBR => 67,
GUMBO_TAG_INS => 68,
GUMBO_TAG_DEL => 69,
GUMBO_TAG_IMAGE => 70,
GUMBO_TAG_IMG => 71,
GUMBO_TAG_IFRAME => 72,
GUMBO_TAG_EMBED => 73,
GUMBO_TAG_OBJECT => 74,
GUMBO_TAG_PARAM => 75,
GUMBO_TAG_VIDEO => 76,
GUMBO_TAG_AUDIO => 77,
GUMBO_TAG_SOURCE => 78,
GUMBO_TAG_TRACK => 79,
GUMBO_TAG_CANVAS => 80,
GUMBO_TAG_MAP => 81,
GUMBO_TAG_AREA => 82,
GUMBO_TAG_MATH => 83,
GUMBO_TAG_MI => 84,
GUMBO_TAG_MO => 85,
GUMBO_TAG_MN => 86,
GUMBO_TAG_MS => 87,
GUMBO_TAG_MTEXT => 88,
GUMBO_TAG_MGLYPH => 89,
GUMBO_TAG_MALIGNMARK => 90,
GUMBO_TAG_ANNOTATION_XML => 91,
GUMBO_TAG_SVG => 92,
GUMBO_TAG_FOREIGNOBJECT => 93,
GUMBO_TAG_DESC => 94,
GUMBO_TAG_TABLE => 95,
GUMBO_TAG_CAPTION => 96,
GUMBO_TAG_COLGROUP => 97,
GUMBO_TAG_COL => 98,
GUMBO_TAG_TBODY => 99,
GUMBO_TAG_THEAD => 100,
GUMBO_TAG_TFOOT => 101,
GUMBO_TAG_TR => 102,
GUMBO_TAG_TD => 103,
GUMBO_TAG_TH => 104,
GUMBO_TAG_FORM => 105,
GUMBO_TAG_FIELDSET => 106,
GUMBO_TAG_LEGEND => 107,
GUMBO_TAG_LABEL => 108,
GUMBO_TAG_INPUT => 109,
GUMBO_TAG_BUTTON => 110,
GUMBO_TAG_SELECT => 111,
GUMBO_TAG_DATALIST => 112,
GUMBO_TAG_OPTGROUP => 113,
GUMBO_TAG_OPTION => 114,
GUMBO_TAG_TEXTAREA => 115,
GUMBO_TAG_KEYGEN => 116,
GUMBO_TAG_OUTPUT => 117,
GUMBO_TAG_PROGRESS => 118,
GUMBO_TAG_METER => 119,
GUMBO_TAG_DETAILS => 120,
GUMBO_TAG_SUMMARY => 121,
GUMBO_TAG_MENU => 122,
GUMBO_TAG_MENUITEM => 123,
GUMBO_TAG_APPLET => 124,
GUMBO_TAG_ACRONYM => 125,
GUMBO_TAG_BGSOUND => 126,
GUMBO_TAG_DIR => 127,
GUMBO_TAG_FRAME => 128,
GUMBO_TAG_FRAMESET => 129,
GUMBO_TAG_NOFRAMES => 130,
GUMBO_TAG_ISINDEX => 131,
GUMBO_TAG_LISTING => 132,
GUMBO_TAG_XMP => 133,
GUMBO_TAG_NEXTID => 134,
GUMBO_TAG_NOEMBED => 135,
GUMBO_TAG_PLAINTEXT => 136,
GUMBO_TAG_RB => 137,
GUMBO_TAG_STRIKE => 138,
GUMBO_TAG_BASEFONT => 139,
GUMBO_TAG_BIG => 140,
GUMBO_TAG_BLINK => 141,
GUMBO_TAG_CENTER => 142,
GUMBO_TAG_FONT => 143,
GUMBO_TAG_MARQUEE => 144,
GUMBO_TAG_MULTICOL => 145,
GUMBO_TAG_NOBR => 146,
GUMBO_TAG_SPACER => 147,
GUMBO_TAG_TT => 148,
GUMBO_TAG_RTC => 149,
GUMBO_TAG_UNKNOWN => 150,
GUMBO_TAG_LAST => 151
);
enum GumboAttributeNamespaceEnum is export (
GUMBO_ATTR_NAMESPACE_NONE => 0,
GUMBO_ATTR_NAMESPACE_XLINK => 1,
GUMBO_ATTR_NAMESPACE_XML => 2,
GUMBO_ATTR_NAMESPACE_XMLNS => 3
);
enum GumboNodeType is export (
GUMBO_NODE_DOCUMENT => 0,
GUMBO_NODE_ELEMENT => 1,
GUMBO_NODE_TEXT => 2,
GUMBO_NODE_CDATA => 3,
GUMBO_NODE_COMMENT => 4,
GUMBO_NODE_WHITESPACE => 5,
GUMBO_NODE_TEMPLATE => 6
);
enum GumboQuirksModeEnum is export (
GUMBO_DOCTYPE_NO_QUIRKS => 0,
GUMBO_DOCTYPE_QUIRKS => 1,
GUMBO_DOCTYPE_LIMITED_QUIRKS => 2
);
enum GumboNamespaceEnum is export (
GUMBO_NAMESPACE_HTML => 0,
GUMBO_NAMESPACE_SVG => 1,
GUMBO_NAMESPACE_MATHML => 2
);
enum GumboParseFlags is export (
GUMBO_INSERTION_NORMAL => 0,
GUMBO_INSERTION_BY_PARSER => 1,
GUMBO_INSERTION_IMPLICIT_END_TAG => 2,
GUMBO_INSERTION_IMPLIED => 8,
GUMBO_INSERTION_CONVERTED_FROM_END_TAG => 16,
GUMBO_INSERTION_FROM_ISINDEX => 32,
GUMBO_INSERTION_FROM_IMAGE => 64,
GUMBO_INSERTION_RECONSTRUCTED_FORMATTING_ELEMENT => 128,
GUMBO_INSERTION_ADOPTION_AGENCY_CLONED => 256,
GUMBO_INSERTION_ADOPTION_AGENCY_MOVED => 512,
GUMBO_INSERTION_FOSTER_PARENTED => 1024
);
## Structures
# == /usr/local/include/gumbo.h ==
class GumboSourcePosition is repr('CStruct') is export {
has uint32 $.line; # unsigned int line
has uint32 $.column; # unsigned int column
has uint32 $.offset; # unsigned int offset
}
class GumboStringPiece is repr('CStruct') is export {
has Str $.data; # const char* data
has size_t $.length; # Typedef<size_t>->|unsigned int| length
}
class GumboVector is repr('CStruct') is export {
has Pointer[Pointer] $.data; # void** data
has uint32 $.length; # unsigned int length
has uint32 $.capacity; # unsigned int capacity
}
class GumboAttribute is repr('CStruct') is export {
has int32 $.attr_namespace; # GumboAttributeNamespaceEnum attr_namespace
has Str $.name; # const char* name
HAS GumboStringPiece $.original_name; # GumboStringPiece original_name
has Str $.value; # const char* value
HAS GumboStringPiece $.original_value; # GumboStringPiece original_value
HAS GumboSourcePosition $.name_start; # GumboSourcePosition name_start
HAS GumboSourcePosition $.name_end; # GumboSourcePosition name_end
HAS GumboSourcePosition $.value_start; # GumboSourcePosition value_start
HAS GumboSourcePosition $.value_end; # GumboSourcePosition value_end
}
class GumboDocument is repr('CStruct') is export {
HAS GumboVector $.children; # GumboVector children
has bool $.has_doctype; # bool has_doctype
has Str $.name; # const char* name
has Str $.public_identifier; # const char* public_identifier
has Str $.system_identifier; # const char* system_identifier
has int32 $.doc_type_quirks_mode; # GumboQuirksModeEnum doc_type_quirks_mode
}
class GumboText is repr('CStruct') is export {
has Str $.text; # const char* text
HAS GumboStringPiece $.original_text; # GumboStringPiece original_text
HAS GumboSourcePosition $.start_pos; # GumboSourcePosition start_pos
}
class GumboElement is repr('CStruct') is export {
HAS GumboVector $.children; # GumboVector children
has int32 $.tag; # GumboTag tag
has int32 $.tag_namespace; # GumboNamespaceEnum tag_namespace
HAS GumboStringPiece $.original_tag; # GumboStringPiece original_tag
HAS GumboStringPiece $.original_end_tag; # GumboStringPiece original_end_tag
HAS GumboSourcePosition $.start_pos; # GumboSourcePosition start_pos
HAS GumboSourcePosition $.end_pos; # GumboSourcePosition end_pos
HAS GumboVector $.attributes; # GumboVector attributes
}
class GumboInternalNode_v_Union is repr('CUnion') is export {
HAS GumboDocument $.document; # GumboDocument document
HAS GumboElement $.element; # GumboElement element
HAS GumboText $.text; # GumboText text
}
class GumboInternalNode is repr('CStruct') is export {
has int32 $.type; # GumboNodeType type
has Pointer[GumboInternalNode] $.parent; # Typedef<GumboNode>->|GumboInternalNode|* parent
has size_t $.index_within_parent; # Typedef<size_t>->|unsigned int| index_within_parent
has int32 $.parse_flags; # GumboParseFlags parse_flags
HAS GumboInternalNode_v_Union $.v; # Union v
}
class GumboInternalOptions is repr('CStruct') is export {
has Pointer $.allocator; # Typedef<GumboAllocatorFunction>->|F:void* ( void*, Typedef<size_t>->|unsigned int|)*| allocator
has Pointer $.deallocator; # Typedef<GumboDeallocatorFunction>->|F:void ( void*, void*)*| deallocator
has Pointer $.userdata; # void* userdata
has int32 $.tab_stop; # int tab_stop
has bool $.stop_on_first_error; # bool stop_on_first_error
has int32 $.max_errors; # int max_errors
has int32 $.fragment_context; # GumboTag fragment_context
has int32 $.fragment_namespace; # GumboNamespaceEnum fragment_namespace
}
class GumboInternalOutput is repr('CStruct') is export {
has Pointer[GumboInternalNode] $.document; # Typedef<GumboNode>->|GumboInternalNode|* document
has Pointer[GumboInternalNode] $.root; # Typedef<GumboNode>->|GumboInternalNode|* root
HAS GumboVector $.errors; # GumboVector errors
}
## Extras stuff
constant GumboOutput is export := GumboInternalOutput;
constant GumboOptions is export := GumboInternalOptions;
constant GumboNode is export := GumboInternalNode;
## Functions
# == /usr/local/include/gumbo.h ==
#-From /usr/local/include/gumbo.h:104
#/**
# * Compares two GumboStringPieces, and returns true if they're equal or false
# * otherwise.
# */
#bool gumbo_string_equals(
# const GumboStringPiece* str1, const GumboStringPiece* str2);
sub gumbo_string_equals(Pointer[GumboStringPiece] $str1 # const GumboStringPiece*
,Pointer[GumboStringPiece] $str2 # const GumboStringPiece*
) is native(LIB) returns bool is export { * }
#-From /usr/local/include/gumbo.h:111
#/**
# * Compares two GumboStringPieces ignoring case, and returns true if they're
# * equal or false otherwise.
# */
#bool gumbo_string_equals_ignore_case(
# const GumboStringPiece* str1, const GumboStringPiece* str2);
sub gumbo_string_equals_ignore_case(Pointer[GumboStringPiece] $str1 # const GumboStringPiece*
,Pointer[GumboStringPiece] $str2 # const GumboStringPiece*
) is native(LIB) returns bool is export { * }
#-From /usr/local/include/gumbo.h:142
#/**
# * Returns the first index at which an element appears in this vector (testing
# * by pointer equality), or -1 if it never does.
# */
#int gumbo_vector_index_of(GumboVector* vector, const void* element);
sub gumbo_vector_index_of(Pointer[GumboVector] $vector # GumboVector*
,Pointer $element # const void*
) is native(LIB) returns int32 is export { * }
#-From /usr/local/include/gumbo.h:172
#/**
# * Returns the normalized (usually all-lowercased, except for foreign content)
# * tag name for an GumboTag enum. Return value is static data owned by the
# * library.
# */
#const char* gumbo_normalized_tagname(GumboTag tag);
sub gumbo_normalized_tagname(int32 $tag # GumboTag
) is native(LIB) returns Str is export { * }
#-From /usr/local/include/gumbo.h:184
#/**
# * Extracts the tag name from the original_text field of an element or token by
# * stripping off </> characters and attributes and adjusting the passed-in
# * GumboStringPiece appropriately. The tag name is in the original case and
# * shares a buffer with the original text, to simplify memory management.
# * Behavior is undefined if a string-piece that doesn't represent an HTML tag
# * (<tagname> or </tagname>) is passed in. If the string piece is completely
# * empty (NULL data pointer), then this function will exit successfully as a
# * no-op.
# */
#void gumbo_tag_from_original_text(GumboStringPiece* text);
sub gumbo_tag_from_original_text(Pointer[GumboStringPiece] $text # GumboStringPiece*
) is native(LIB) is export { * }
#-From /usr/local/include/gumbo.h:198
#/**
# * Fixes the case of SVG elements that are not all lowercase.
# * http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#parsing-main-inforeign
# * This is not done at parse time because there's no place to store a mutated
# * tag name. tag_name is an enum (which will be TAG_UNKNOWN for most SVG tags
# * without special handling), while original_tag_name is a pointer into the
# * original buffer. Instead, we provide this helper function that clients can
# * use to rename SVG tags as appropriate.
# * Returns the case-normalized SVG tagname if a replacement is found, or NULL if
# * no normalization is called for. The return value is static data and owned by
# * the library.
# */
#const char* gumbo_normalize_svg_tagname(const GumboStringPiece* tagname);
sub gumbo_normalize_svg_tagname(Pointer[GumboStringPiece] $tagname # const GumboStringPiece*
) is native(LIB) returns Str is export { * }
#-From /usr/local/include/gumbo.h:204
#/**
# * Converts a tag name string (which may be in upper or mixed case) to a tag
# * enum. The `tag` version expects `tagname` to be NULL-terminated
# */
#GumboTag gumbo_tag_enum(const char* tagname);
sub gumbo_tag_enum(Str $tagname # const char*
) is native(LIB) returns int32 is export { * }
#-From /usr/local/include/gumbo.h:205
#GumboTag gumbo_tagn_enum(const char* tagname, unsigned int length);
sub gumbo_tagn_enum(Str $tagname # const char*
,uint32 $length # unsigned int
) is native(LIB) returns int32 is export { * }
#-From /usr/local/include/gumbo.h:285
#/**
# * Given a vector of GumboAttributes, look up the one with the specified name
# * and return it, or NULL if no such attribute exists. This uses a
# * case-insensitive match, as HTML is case-insensitive.
# */
#GumboAttribute* gumbo_get_attribute(const GumboVector* attrs, const char* name);
sub gumbo_get_attribute(Pointer[GumboVector] $attrs # const GumboVector*
,Str $name # const char*
) is native(LIB) returns Pointer[GumboAttribute] is export { * }
#-From /usr/local/include/gumbo.h:655
#/**
# * Parses a buffer of UTF8 text into an GumboNode parse tree. The buffer must
# * live at least as long as the parse tree, as some fields (eg. original_text)
# * point directly into the original buffer.
# *
# * This doesn't support buffers longer than 4 gigabytes.
# */
#GumboOutput* gumbo_parse(const char* buffer);
sub gumbo_parse(Str $buffer # const char*
) is native(LIB) returns Pointer[GumboInternalOutput] is export { * }
#-From /usr/local/include/gumbo.h:662
#/**
# * Extended version of gumbo_parse that takes an explicit options structure,
# * buffer, and length.
# */
#GumboOutput* gumbo_parse_with_options(
# const GumboOptions* options, const char* buffer, size_t buffer_length);
sub gumbo_parse_with_options(Pointer[GumboInternalOptions] $options # const Typedef<GumboOptions>->|GumboInternalOptions|*
,Str $buffer # const char*
,size_t $buffer_length # Typedef<size_t>->|unsigned int|
) is native(LIB) returns Pointer[GumboInternalOutput] is export { * }
#-From /usr/local/include/gumbo.h:665
#/** Release the memory used for the parse tree & parse errors. */
#void gumbo_destroy_output(const GumboOptions* options, GumboOutput* output);
sub gumbo_destroy_output(Pointer[GumboInternalOptions] $options # const Typedef<GumboOptions>->|GumboInternalOptions|*
,Pointer[GumboInternalOutput] $output # Typedef<GumboOutput>->|GumboInternalOutput|*
) is native(LIB) is export { * }
## Externs
# == /usr/local/include/gumbo.h ==
our GumboSourcePosition $kGumboEmptySourcePosition is export = cglobals(LIB, "kGumboEmptySourcePosition", GumboSourcePosition);
our GumboStringPiece $kGumboEmptyString is export = cglobals(LIB, "kGumboEmptyString", GumboStringPiece);
our GumboVector $kGumboEmptyVector is export = cglobals(LIB, "kGumboEmptyVector", GumboVector);
our GumboInternalOptions $kGumboDefaultOptions is export = cglobals(LIB, "kGumboDefaultOptions", GumboInternalOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment