1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/gobject/types"
12)
13
14// A parse context is used to parse a stream of bytes that
15// you expect to contain marked-up text.
16//
17// See g_markup_parse_context_new(), #GMarkupParser, and so
18// on for more details.
19type MarkupParseContext struct {
20 _ structs.HostLayout
21}
22
23var xMarkupParseContextGLibType func() types.GType
24
25func MarkupParseContextGLibType() types.GType {
26 return xMarkupParseContextGLibType()
27}
28
29func (x *MarkupParseContext) GoPointer() uintptr {
30 return uintptr(unsafe.Pointer(x))
31}
32
33var xNewMarkupParseContext func(*MarkupParser, MarkupParseFlags, uintptr, uintptr) *MarkupParseContext
34
35// Creates a new parse context. A parse context is used to parse
36// marked-up documents. You can feed any number of documents into
37// a context, as long as no errors occur; once an error occurs,
38// the parse context can't continue to parse text (you have to
39// free it and create a new parse context).
40func NewMarkupParseContext(ParserVar *MarkupParser, FlagsVar MarkupParseFlags, UserDataVar uintptr, UserDataDnotifyVar *DestroyNotify) *MarkupParseContext {
41
42 var UserDataDnotifyVarRef uintptr
43 if UserDataDnotifyVar != nil {
44 UserDataDnotifyVarPtr := uintptr(unsafe.Pointer(UserDataDnotifyVar))
45 if cbRefPtr, ok := GetCallback(UserDataDnotifyVarPtr); ok {
46 UserDataDnotifyVarRef = cbRefPtr
47 } else {
48 fcb := func(arg0 uintptr) {
49 cbFn := *UserDataDnotifyVar
50 cbFn(arg0)
51 }
52 UserDataDnotifyVarRef = purego.NewCallback(fcb)
53 SaveCallbackWithClosure(UserDataDnotifyVarPtr, UserDataDnotifyVarRef, UserDataDnotifyVar)
54 }
55 }
56
57 cret := xNewMarkupParseContext(ParserVar, FlagsVar, UserDataVar, UserDataDnotifyVarRef)
58 return cret
59}
60
61var xMarkupParseContextEndParse func(uintptr) bool
62
63// Signals to the #GMarkupParseContext that all data has been
64// fed into the parse context with g_markup_parse_context_parse().
65//
66// This function reports an error if the document isn't complete,
67// for example if elements are still open.
68func (x *MarkupParseContext) EndParse() (bool, error) {
69 var cerr *Error
70
71 cret := xMarkupParseContextEndParse(x.GoPointer())
72 if cerr == nil {
73 return cret, nil
74 }
75 return cret, cerr
76
77}
78
79var xMarkupParseContextFree func(uintptr)
80
81// Frees a #GMarkupParseContext.
82//
83// This function can't be called from inside one of the
84// #GMarkupParser functions or while a subparser is pushed.
85func (x *MarkupParseContext) Free() {
86
87 xMarkupParseContextFree(x.GoPointer())
88
89}
90
91var xMarkupParseContextGetElement func(uintptr) string
92
93// Retrieves the name of the currently open element.
94//
95// If called from the start_element or end_element handlers this will
96// give the element_name as passed to those functions. For the parent
97// elements, see g_markup_parse_context_get_element_stack().
98func (x *MarkupParseContext) GetElement() string {
99
100 cret := xMarkupParseContextGetElement(x.GoPointer())
101 return cret
102}
103
104var xMarkupParseContextGetElementStack func(uintptr) *SList
105
106// Retrieves the element stack from the internal state of the parser.
107//
108// The returned #GSList is a list of strings where the first item is
109// the currently open tag (as would be returned by
110// g_markup_parse_context_get_element()) and the next item is its
111// immediate parent.
112//
113// This function is intended to be used in the start_element and
114// end_element handlers where g_markup_parse_context_get_element()
115// would merely return the name of the element that is being
116// processed.
117func (x *MarkupParseContext) GetElementStack() *SList {
118
119 cret := xMarkupParseContextGetElementStack(x.GoPointer())
120 return cret
121}
122
123var xMarkupParseContextGetPosition func(uintptr, *int, *int)
124
125// Retrieves the current line number and the number of the character on
126// that line. Intended for use in error messages; there are no strict
127// semantics for what constitutes the "current" line number other than
128// "the best number we could come up with for error messages."
129func (x *MarkupParseContext) GetPosition(LineNumberVar *int, CharNumberVar *int) {
130
131 xMarkupParseContextGetPosition(x.GoPointer(), LineNumberVar, CharNumberVar)
132
133}
134
135var xMarkupParseContextGetUserData func(uintptr) uintptr
136
137// Returns the user_data associated with @context.
138//
139// This will either be the user_data that was provided to
140// g_markup_parse_context_new() or to the most recent call
141// of g_markup_parse_context_push().
142func (x *MarkupParseContext) GetUserData() uintptr {
143
144 cret := xMarkupParseContextGetUserData(x.GoPointer())
145 return cret
146}
147
148var xMarkupParseContextParse func(uintptr, string, int, **Error) bool
149
150// Feed some data to the #GMarkupParseContext.
151//
152// The data need not be valid UTF-8; an error will be signaled if
153// it's invalid. The data need not be an entire document; you can
154// feed a document into the parser incrementally, via multiple calls
155// to this function. Typically, as you receive data from a network
156// connection or file, you feed each received chunk of data into this
157// function, aborting the process if an error occurs. Once an error
158// is reported, no further data may be fed to the #GMarkupParseContext;
159// all errors are fatal.
160func (x *MarkupParseContext) Parse(TextVar string, TextLenVar int) (bool, error) {
161 var cerr *Error
162
163 cret := xMarkupParseContextParse(x.GoPointer(), TextVar, TextLenVar, &cerr)
164 if cerr == nil {
165 return cret, nil
166 }
167 return cret, cerr
168
169}
170
171var xMarkupParseContextPop func(uintptr) uintptr
172
173// Completes the process of a temporary sub-parser redirection.
174//
175// This function exists to collect the user_data allocated by a
176// matching call to g_markup_parse_context_push(). It must be called
177// in the end_element handler corresponding to the start_element
178// handler during which g_markup_parse_context_push() was called.
179// You must not call this function from the error callback -- the
180// @user_data is provided directly to the callback in that case.
181//
182// This function is not intended to be directly called by users
183// interested in invoking subparsers. Instead, it is intended to
184// be used by the subparsers themselves to implement a higher-level
185// interface.
186func (x *MarkupParseContext) Pop() uintptr {
187
188 cret := xMarkupParseContextPop(x.GoPointer())
189 return cret
190}
191
192var xMarkupParseContextPush func(uintptr, *MarkupParser, uintptr)
193
194// Temporarily redirects markup data to a sub-parser.
195//
196// This function may only be called from the start_element handler of
197// a #GMarkupParser. It must be matched with a corresponding call to
198// g_markup_parse_context_pop() in the matching end_element handler
199// (except in the case that the parser aborts due to an error).
200//
201// All tags, text and other data between the matching tags is
202// redirected to the subparser given by @parser. @user_data is used
203// as the user_data for that parser. @user_data is also passed to the
204// error callback in the event that an error occurs. This includes
205// errors that occur in subparsers of the subparser.
206//
207// The end tag matching the start tag for which this call was made is
208// handled by the previous parser (which is given its own user_data)
209// which is why g_markup_parse_context_pop() is provided to allow "one
210// last access" to the @user_data provided to this function. In the
211// case of error, the @user_data provided here is passed directly to
212// the error callback of the subparser and g_markup_parse_context_pop()
213// should not be called. In either case, if @user_data was allocated
214// then it ought to be freed from both of these locations.
215//
216// This function is not intended to be directly called by users
217// interested in invoking subparsers. Instead, it is intended to be
218// used by the subparsers themselves to implement a higher-level
219// interface.
220//
221// As an example, see the following implementation of a simple
222// parser that counts the number of tags encountered.
223//
224// |[<!-- language="C" -->
225// typedef struct
226//
227// {
228// gint tag_count;
229// } CounterData;
230//
231// static void
232// counter_start_element (GMarkupParseContext *context,
233//
234// const gchar *element_name,
235// const gchar **attribute_names,
236// const gchar **attribute_values,
237// gpointer user_data,
238// GError **error)
239//
240// {
241// CounterData *data = user_data;
242//
243// data->tag_count++;
244// }
245//
246// static void
247// counter_error (GMarkupParseContext *context,
248//
249// GError *error,
250// gpointer user_data)
251//
252// {
253// CounterData *data = user_data;
254//
255// g_slice_free (CounterData, data);
256// }
257//
258// static GMarkupParser counter_subparser =
259//
260// {
261// counter_start_element,
262// NULL,
263// NULL,
264// NULL,
265// counter_error
266// };
267//
268// ]|
269//
270// In order to allow this parser to be easily used as a subparser, the
271// following interface is provided:
272//
273// |[<!-- language="C" -->
274// void
275// start_counting (GMarkupParseContext *context)
276//
277// {
278// CounterData *data = g_slice_new (CounterData);
279//
280// data->tag_count = 0;
281// g_markup_parse_context_push (context, &counter_subparser, data);
282// }
283//
284// gint
285// end_counting (GMarkupParseContext *context)
286//
287// {
288// CounterData *data = g_markup_parse_context_pop (context);
289// int result;
290//
291// result = data->tag_count;
292// g_slice_free (CounterData, data);
293//
294// return result;
295// }
296//
297// ]|
298//
299// The subparser would then be used as follows:
300//
301// |[<!-- language="C" -->
302// static void start_element (context, element_name, ...)
303//
304// {
305// if (strcmp (element_name, "count-these") == 0)
306// start_counting (context);
307//
308// // else, handle other tags...
309// }
310//
311// static void end_element (context, element_name, ...)
312//
313// {
314// if (strcmp (element_name, "count-these") == 0)
315// g_print ("Counted %d tags\n", end_counting (context));
316//
317// // else, handle other tags...
318// }
319//
320// ]|
321func (x *MarkupParseContext) Push(ParserVar *MarkupParser, UserDataVar uintptr) {
322
323 xMarkupParseContextPush(x.GoPointer(), ParserVar, UserDataVar)
324
325}
326
327var xMarkupParseContextRef func(uintptr) *MarkupParseContext
328
329// Increases the reference count of @context.
330func (x *MarkupParseContext) Ref() *MarkupParseContext {
331
332 cret := xMarkupParseContextRef(x.GoPointer())
333 return cret
334}
335
336var xMarkupParseContextUnref func(uintptr)
337
338// Decreases the reference count of @context. When its reference count
339// drops to 0, it is freed.
340func (x *MarkupParseContext) Unref() {
341
342 xMarkupParseContextUnref(x.GoPointer())
343
344}
345
346// Any of the fields in #GMarkupParser can be %NULL, in which case they
347// will be ignored. Except for the @error function, any of these callbacks
348// can set an error; in particular the %G_MARKUP_ERROR_UNKNOWN_ELEMENT,
349// %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, and %G_MARKUP_ERROR_INVALID_CONTENT
350// errors are intended to be set from these callbacks. If you set an error
351// from a callback, g_markup_parse_context_parse() will report that error
352// back to its caller.
353//
354// Refer to the [GMarkup](../glib/markup.html) documentation to understand
355// the scope and limitations of `GMarkupParser`. In particular, it is not a
356// full XML parser and it must not be used to process untrusted data.
357type MarkupParser struct {
358 _ structs.HostLayout
359
360 xStartElement uintptr
361
362 xEndElement uintptr
363
364 xText uintptr
365
366 xPassthrough uintptr
367
368 xError uintptr
369}
370
371func (x *MarkupParser) GoPointer() uintptr {
372 return uintptr(unsafe.Pointer(x))
373}
374
375// OverrideStartElement sets the "start_element" callback function.
376// Callback to invoke when the opening tag of an element
377//
378// is seen. The callback's @attribute_names and @attribute_values parameters
379// are %NULL-terminated.
380func (x *MarkupParser) OverrideStartElement(cb func(*MarkupParseContext, string, string, string, uintptr)) {
381 if cb == nil {
382 x.xStartElement = 0
383 } else {
384 x.xStartElement = purego.NewCallback(func(ContextVarp *MarkupParseContext, ElementNameVarp string, AttributeNamesVarp string, AttributeValuesVarp string, UserDataVarp uintptr) {
385 cb(ContextVarp, ElementNameVarp, AttributeNamesVarp, AttributeValuesVarp, UserDataVarp)
386 })
387 }
388}
389
390// GetStartElement gets the "start_element" callback function.
391// Callback to invoke when the opening tag of an element
392//
393// is seen. The callback's @attribute_names and @attribute_values parameters
394// are %NULL-terminated.
395func (x *MarkupParser) GetStartElement() func(*MarkupParseContext, string, string, string, uintptr) {
396 if x.xStartElement == 0 {
397 return nil
398 }
399 var rawCallback func(ContextVarp *MarkupParseContext, ElementNameVarp string, AttributeNamesVarp string, AttributeValuesVarp string, UserDataVarp uintptr)
400 purego.RegisterFunc(&rawCallback, x.xStartElement)
401 return func(ContextVar *MarkupParseContext, ElementNameVar string, AttributeNamesVar string, AttributeValuesVar string, UserDataVar uintptr) {
402 rawCallback(ContextVar, ElementNameVar, AttributeNamesVar, AttributeValuesVar, UserDataVar)
403 }
404}
405
406// OverrideEndElement sets the "end_element" callback function.
407// Callback to invoke when the closing tag of an element
408//
409// is seen. Note that this is also called for empty tags like
410// `<empty/>`.
411func (x *MarkupParser) OverrideEndElement(cb func(*MarkupParseContext, string, uintptr)) {
412 if cb == nil {
413 x.xEndElement = 0
414 } else {
415 x.xEndElement = purego.NewCallback(func(ContextVarp *MarkupParseContext, ElementNameVarp string, UserDataVarp uintptr) {
416 cb(ContextVarp, ElementNameVarp, UserDataVarp)
417 })
418 }
419}
420
421// GetEndElement gets the "end_element" callback function.
422// Callback to invoke when the closing tag of an element
423//
424// is seen. Note that this is also called for empty tags like
425// `<empty/>`.
426func (x *MarkupParser) GetEndElement() func(*MarkupParseContext, string, uintptr) {
427 if x.xEndElement == 0 {
428 return nil
429 }
430 var rawCallback func(ContextVarp *MarkupParseContext, ElementNameVarp string, UserDataVarp uintptr)
431 purego.RegisterFunc(&rawCallback, x.xEndElement)
432 return func(ContextVar *MarkupParseContext, ElementNameVar string, UserDataVar uintptr) {
433 rawCallback(ContextVar, ElementNameVar, UserDataVar)
434 }
435}
436
437// OverrideText sets the "text" callback function.
438// Callback to invoke when some text is seen (text is always
439//
440// inside an element). Note that the text of an element may be spread
441// over multiple calls of this function. If the
442// %G_MARKUP_TREAT_CDATA_AS_TEXT flag is set, this function is also
443// called for the content of CDATA marked sections.
444func (x *MarkupParser) OverrideText(cb func(*MarkupParseContext, string, uint, uintptr)) {
445 if cb == nil {
446 x.xText = 0
447 } else {
448 x.xText = purego.NewCallback(func(ContextVarp *MarkupParseContext, TextVarp string, TextLenVarp uint, UserDataVarp uintptr) {
449 cb(ContextVarp, TextVarp, TextLenVarp, UserDataVarp)
450 })
451 }
452}
453
454// GetText gets the "text" callback function.
455// Callback to invoke when some text is seen (text is always
456//
457// inside an element). Note that the text of an element may be spread
458// over multiple calls of this function. If the
459// %G_MARKUP_TREAT_CDATA_AS_TEXT flag is set, this function is also
460// called for the content of CDATA marked sections.
461func (x *MarkupParser) GetText() func(*MarkupParseContext, string, uint, uintptr) {
462 if x.xText == 0 {
463 return nil
464 }
465 var rawCallback func(ContextVarp *MarkupParseContext, TextVarp string, TextLenVarp uint, UserDataVarp uintptr)
466 purego.RegisterFunc(&rawCallback, x.xText)
467 return func(ContextVar *MarkupParseContext, TextVar string, TextLenVar uint, UserDataVar uintptr) {
468 rawCallback(ContextVar, TextVar, TextLenVar, UserDataVar)
469 }
470}
471
472// OverridePassthrough sets the "passthrough" callback function.
473// Callback to invoke for comments, processing instructions
474//
475// and doctype declarations; if you're re-writing the parsed document,
476// write the passthrough text back out in the same position. If the
477// %G_MARKUP_TREAT_CDATA_AS_TEXT flag is not set, this function is also
478// called for CDATA marked sections.
479func (x *MarkupParser) OverridePassthrough(cb func(*MarkupParseContext, string, uint, uintptr)) {
480 if cb == nil {
481 x.xPassthrough = 0
482 } else {
483 x.xPassthrough = purego.NewCallback(func(ContextVarp *MarkupParseContext, PassthroughTextVarp string, TextLenVarp uint, UserDataVarp uintptr) {
484 cb(ContextVarp, PassthroughTextVarp, TextLenVarp, UserDataVarp)
485 })
486 }
487}
488
489// GetPassthrough gets the "passthrough" callback function.
490// Callback to invoke for comments, processing instructions
491//
492// and doctype declarations; if you're re-writing the parsed document,
493// write the passthrough text back out in the same position. If the
494// %G_MARKUP_TREAT_CDATA_AS_TEXT flag is not set, this function is also
495// called for CDATA marked sections.
496func (x *MarkupParser) GetPassthrough() func(*MarkupParseContext, string, uint, uintptr) {
497 if x.xPassthrough == 0 {
498 return nil
499 }
500 var rawCallback func(ContextVarp *MarkupParseContext, PassthroughTextVarp string, TextLenVarp uint, UserDataVarp uintptr)
501 purego.RegisterFunc(&rawCallback, x.xPassthrough)
502 return func(ContextVar *MarkupParseContext, PassthroughTextVar string, TextLenVar uint, UserDataVar uintptr) {
503 rawCallback(ContextVar, PassthroughTextVar, TextLenVar, UserDataVar)
504 }
505}
506
507// OverrideError sets the "error" callback function.
508// Callback to invoke when an error occurs.
509func (x *MarkupParser) OverrideError(cb func(*MarkupParseContext, *Error, uintptr)) {
510 if cb == nil {
511 x.xError = 0
512 } else {
513 x.xError = purego.NewCallback(func(ContextVarp *MarkupParseContext, ErrorVarp *Error, UserDataVarp uintptr) {
514 cb(ContextVarp, ErrorVarp, UserDataVarp)
515 })
516 }
517}
518
519// GetError gets the "error" callback function.
520// Callback to invoke when an error occurs.
521func (x *MarkupParser) GetError() func(*MarkupParseContext, *Error, uintptr) {
522 if x.xError == 0 {
523 return nil
524 }
525 var rawCallback func(ContextVarp *MarkupParseContext, ErrorVarp *Error, UserDataVarp uintptr)
526 purego.RegisterFunc(&rawCallback, x.xError)
527 return func(ContextVar *MarkupParseContext, ErrorVar *Error, UserDataVar uintptr) {
528 rawCallback(ContextVar, ErrorVar, UserDataVar)
529 }
530}
531
532// A mixed enumerated type and flags field. You must specify one type
533// (string, strdup, boolean, tristate). Additionally, you may optionally
534// bitwise OR the type with the flag %G_MARKUP_COLLECT_OPTIONAL.
535//
536// It is likely that this enum will be extended in the future to
537// support other types.
538type MarkupCollectType int
539
540const (
541
542 // used to terminate the list of attributes
543 // to collect
544 GMarkupCollectInvalidValue MarkupCollectType = 0
545 // collect the string pointer directly from
546 // the attribute_values[] array. Expects a parameter of type (const
547 // char **). If %G_MARKUP_COLLECT_OPTIONAL is specified and the
548 // attribute isn't present then the pointer will be set to %NULL
549 GMarkupCollectStringValue MarkupCollectType = 1
550 // as with %G_MARKUP_COLLECT_STRING, but
551 // expects a parameter of type (char **) and g_strdup()s the
552 // returned pointer. The pointer must be freed with g_free()
553 GMarkupCollectStrdupValue MarkupCollectType = 2
554 // expects a parameter of type (`gboolean *`)
555 // and parses the attribute value as a boolean. Sets %FALSE if the
556 // attribute isn't present. Valid boolean values consist of
557 // (case-insensitive) "false", "f", "no", "n", "0" and "true", "t",
558 // "yes", "y", "1"
559 GMarkupCollectBooleanValue MarkupCollectType = 3
560 // as with %G_MARKUP_COLLECT_BOOLEAN, but
561 // in the case of a missing attribute a value is set that compares
562 // equal to neither %FALSE nor %TRUE %G_MARKUP_COLLECT_OPTIONAL is
563 // implied
564 GMarkupCollectTristateValue MarkupCollectType = 4
565 // can be bitwise ORed with the other fields.
566 // If present, allows the attribute not to appear. A default value
567 // is set depending on what value type is used
568 GMarkupCollectOptionalValue MarkupCollectType = 65536
569)
570
571// Flags that affect the behaviour of the parser.
572type MarkupParseFlags int
573
574const (
575
576 // No special behaviour. Since: 2.74
577 GMarkupDefaultFlagsValue MarkupParseFlags = 0
578 // flag you should not use
579 GMarkupDoNotUseThisUnsupportedFlagValue MarkupParseFlags = 1
580 // When this flag is set, CDATA marked
581 // sections are not passed literally to the @passthrough function of
582 // the parser. Instead, the content of the section (without the
583 // `<![CDATA[` and `]]>`) is
584 // passed to the @text function. This flag was added in GLib 2.12
585 GMarkupTreatCdataAsTextValue MarkupParseFlags = 2
586 // Normally errors caught by GMarkup
587 // itself have line/column information prefixed to them to let the
588 // caller know the location of the error. When this flag is set the
589 // location information is also prefixed to errors generated by the
590 // #GMarkupParser implementation functions
591 GMarkupPrefixErrorPositionValue MarkupParseFlags = 4
592 // Ignore (don't report) qualified
593 // attributes and tags, along with their contents. A qualified
594 // attribute or tag is one that contains ':' in its name (ie: is in
595 // another namespace). Since: 2.40.
596 GMarkupIgnoreQualifiedValue MarkupParseFlags = 8
597)
598
599// Error codes returned by markup parsing.
600type MarkupError int
601
602const (
603
604 // text being parsed was not valid UTF-8
605 GMarkupErrorBadUtf8Value MarkupError = 0
606 // document contained nothing, or only whitespace
607 GMarkupErrorEmptyValue MarkupError = 1
608 // document was ill-formed
609 GMarkupErrorParseValue MarkupError = 2
610 // error should be set by #GMarkupParser
611 // functions; element wasn't known
612 GMarkupErrorUnknownElementValue MarkupError = 3
613 // error should be set by #GMarkupParser
614 // functions; attribute wasn't known
615 GMarkupErrorUnknownAttributeValue MarkupError = 4
616 // error should be set by #GMarkupParser
617 // functions; content was invalid
618 GMarkupErrorInvalidContentValue MarkupError = 5
619 // error should be set by #GMarkupParser
620 // functions; a required attribute was missing
621 GMarkupErrorMissingAttributeValue MarkupError = 6
622)
623
624var xMarkupCollectAttributes func(string, string, string, **Error, MarkupCollectType, string, ...interface{}) bool
625
626// Collects the attributes of the element from the data passed to the
627// #GMarkupParser start_element function, dealing with common error
628// conditions and supporting boolean values.
629//
630// This utility function is not required to write a parser but can save
631// a lot of typing.
632//
633// The @element_name, @attribute_names, @attribute_values and @error
634// parameters passed to the start_element callback should be passed
635// unmodified to this function.
636//
637// Following these arguments is a list of "supported" attributes to collect.
638// It is an error to specify multiple attributes with the same name. If any
639// attribute not in the list appears in the @attribute_names array then an
640// unknown attribute error will result.
641//
642// The #GMarkupCollectType field allows specifying the type of collection
643// to perform and if a given attribute must appear or is optional.
644//
645// The attribute name is simply the name of the attribute to collect.
646//
647// The pointer should be of the appropriate type (see the descriptions
648// under #GMarkupCollectType) and may be %NULL in case a particular
649// attribute is to be allowed but ignored.
650//
651// This function deals with issuing errors for missing attributes
652// (of type %G_MARKUP_ERROR_MISSING_ATTRIBUTE), unknown attributes
653// (of type %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE) and duplicate
654// attributes (of type %G_MARKUP_ERROR_INVALID_CONTENT) as well
655// as parse errors for boolean-valued attributes (again of type
656// %G_MARKUP_ERROR_INVALID_CONTENT). In all of these cases %FALSE
657// will be returned and @error will be set as appropriate.
658func MarkupCollectAttributes(ElementNameVar string, AttributeNamesVar string, AttributeValuesVar string, ErrorVar **Error, FirstTypeVar MarkupCollectType, FirstAttrVar string, varArgs ...interface{}) bool {
659
660 cret := xMarkupCollectAttributes(ElementNameVar, AttributeNamesVar, AttributeValuesVar, ErrorVar, FirstTypeVar, FirstAttrVar, varArgs...)
661
662 return cret
663}
664
665var xMarkupEscapeText func(string, int) string
666
667// Escapes text so that the markup parser will parse it verbatim.
668// Less than, greater than, ampersand, etc. are replaced with the
669// corresponding entities. This function would typically be used
670// when writing out a file to be parsed with the markup parser.
671//
672// Note that this function doesn't protect whitespace and line endings
673// from being processed according to the XML rules for normalization
674// of line endings and attribute values.
675//
676// Note also that this function will produce character references in
677// the range of &#x1; ... &#x1f; for all control sequences
678// except for tabstop, newline and carriage return. The character
679// references in this range are not valid XML 1.0, but they are
680// valid XML 1.1 and will be accepted by the GMarkup parser.
681func MarkupEscapeText(TextVar string, LengthVar int) string {
682
683 cret := xMarkupEscapeText(TextVar, LengthVar)
684
685 return cret
686}
687
688var xMarkupPrintfEscaped func(string, ...interface{}) string
689
690// Formats arguments according to @format, escaping
691// all string and character arguments in the fashion
692// of g_markup_escape_text(). This is useful when you
693// want to insert literal strings into XML-style markup
694// output, without having to worry that the strings
695// might themselves contain markup.
696//
697// |[<!-- language="C" -->
698// const char *store = "Fortnum & Mason";
699// const char *item = "Tea";
700// char *output;
701//
702// output = g_markup_printf_escaped ("<purchase>"
703//
704// "<store>%s</store>"
705// "<item>%s</item>"
706// "</purchase>",
707// store, item);
708//
709// ]|
710func MarkupPrintfEscaped(FormatVar string, varArgs ...interface{}) string {
711
712 cret := xMarkupPrintfEscaped(FormatVar, varArgs...)
713
714 return cret
715}
716
717var xMarkupVprintfEscaped func(string, []interface{}) string
718
719// Formats the data in @args according to @format, escaping
720// all string and character arguments in the fashion
721// of g_markup_escape_text(). See g_markup_printf_escaped().
722func MarkupVprintfEscaped(FormatVar string, ArgsVar []interface{}) string {
723
724 cret := xMarkupVprintfEscaped(FormatVar, ArgsVar)
725
726 return cret
727}
728
729func init() {
730 core.SetPackageName("GLIB", "glib-2.0")
731 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
732 var libs []uintptr
733 for _, libPath := range core.GetPaths("GLIB") {
734 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
735 if err != nil {
736 panic(err)
737 }
738 libs = append(libs, lib)
739 }
740
741 core.PuregoSafeRegister(&xMarkupCollectAttributes, libs, "g_markup_collect_attributes")
742 core.PuregoSafeRegister(&xMarkupEscapeText, libs, "g_markup_escape_text")
743 core.PuregoSafeRegister(&xMarkupPrintfEscaped, libs, "g_markup_printf_escaped")
744 core.PuregoSafeRegister(&xMarkupVprintfEscaped, libs, "g_markup_vprintf_escaped")
745
746 core.PuregoSafeRegister(&xMarkupParseContextGLibType, libs, "g_markup_parse_context_get_type")
747
748 core.PuregoSafeRegister(&xNewMarkupParseContext, libs, "g_markup_parse_context_new")
749
750 core.PuregoSafeRegister(&xMarkupParseContextEndParse, libs, "g_markup_parse_context_end_parse")
751 core.PuregoSafeRegister(&xMarkupParseContextFree, libs, "g_markup_parse_context_free")
752 core.PuregoSafeRegister(&xMarkupParseContextGetElement, libs, "g_markup_parse_context_get_element")
753 core.PuregoSafeRegister(&xMarkupParseContextGetElementStack, libs, "g_markup_parse_context_get_element_stack")
754 core.PuregoSafeRegister(&xMarkupParseContextGetPosition, libs, "g_markup_parse_context_get_position")
755 core.PuregoSafeRegister(&xMarkupParseContextGetUserData, libs, "g_markup_parse_context_get_user_data")
756 core.PuregoSafeRegister(&xMarkupParseContextParse, libs, "g_markup_parse_context_parse")
757 core.PuregoSafeRegister(&xMarkupParseContextPop, libs, "g_markup_parse_context_pop")
758 core.PuregoSafeRegister(&xMarkupParseContextPush, libs, "g_markup_parse_context_push")
759 core.PuregoSafeRegister(&xMarkupParseContextRef, libs, "g_markup_parse_context_ref")
760 core.PuregoSafeRegister(&xMarkupParseContextUnref, libs, "g_markup_parse_context_unref")
761
762}