// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT package glib import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" ) // Specifies the type of the message handler function. type ScannerMsgFunc func(*Scanner, string, bool) // `GScanner` provides a general-purpose lexical scanner. // // You should set @input_name after creating the scanner, since // it is used by the default message handler when displaying // warnings and errors. If you are scanning a file, the filename // would be a good choice. // // The @user_data and @max_parse_errors fields are not used. // If you need to associate extra data with the scanner you // can place them here. // // If you want to use your own message handler you can set the // @msg_handler field. The type of the message handler function // is declared by #GScannerMsgFunc. type Scanner struct { _ structs.HostLayout UserData uintptr MaxParseErrors uint ParseErrors uint InputName uintptr Qdata *Data Config *ScannerConfig Token TokenType Value TokenValue Line uint Position uint NextToken TokenType NextValue TokenValue NextLine uint NextPosition uint SymbolTable *HashTable InputFd int32 Text uintptr TextEnd uintptr Buffer uintptr ScopeId uint MsgHandler ScannerMsgFunc } func (x *Scanner) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } var xScannerCurLine func(uintptr) uint // Returns the current line in the input stream (counting // from 1). This is the line of the last token parsed via // g_scanner_get_next_token(). func (x *Scanner) CurLine() uint { cret := xScannerCurLine(x.GoPointer()) return cret } var xScannerCurPosition func(uintptr) uint // Returns the current position in the current line (counting // from 0). This is the position of the last token parsed via // g_scanner_get_next_token(). func (x *Scanner) CurPosition() uint { cret := xScannerCurPosition(x.GoPointer()) return cret } var xScannerCurToken func(uintptr) TokenType // Gets the current token type. This is simply the @token // field in the #GScanner structure. func (x *Scanner) CurToken() TokenType { cret := xScannerCurToken(x.GoPointer()) return cret } var xScannerCurValue func(uintptr) TokenValue // Gets the current token value. This is simply the @value // field in the #GScanner structure. func (x *Scanner) CurValue() TokenValue { cret := xScannerCurValue(x.GoPointer()) return cret } var xScannerDestroy func(uintptr) // Frees all memory used by the #GScanner. func (x *Scanner) Destroy() { xScannerDestroy(x.GoPointer()) } var xScannerEof func(uintptr) bool // Returns %TRUE if the scanner has reached the end of // the file or text buffer. func (x *Scanner) Eof() bool { cret := xScannerEof(x.GoPointer()) return cret } var xScannerError func(uintptr, string, ...interface{}) // Outputs an error message, via the #GScanner message handler. func (x *Scanner) Error(FormatVar string, varArgs ...interface{}) { xScannerError(x.GoPointer(), FormatVar, varArgs...) } var xScannerGetNextToken func(uintptr) TokenType // Parses the next token just like g_scanner_peek_next_token() // and also removes it from the input stream. The token data is // placed in the @token, @value, @line, and @position fields of // the #GScanner structure. func (x *Scanner) GetNextToken() TokenType { cret := xScannerGetNextToken(x.GoPointer()) return cret } var xScannerInputFile func(uintptr, int) // Prepares to scan a file. func (x *Scanner) InputFile(InputFdVar int) { xScannerInputFile(x.GoPointer(), InputFdVar) } var xScannerInputText func(uintptr, string, uint) // Prepares to scan a text buffer. func (x *Scanner) InputText(TextVar string, TextLenVar uint) { xScannerInputText(x.GoPointer(), TextVar, TextLenVar) } var xScannerLookupSymbol func(uintptr, string) uintptr // Looks up a symbol in the current scope and return its value. // If the symbol is not bound in the current scope, %NULL is // returned. func (x *Scanner) LookupSymbol(SymbolVar string) uintptr { cret := xScannerLookupSymbol(x.GoPointer(), SymbolVar) return cret } var xScannerPeekNextToken func(uintptr) TokenType // Parses the next token, without removing it from the input stream. // The token data is placed in the @next_token, @next_value, @next_line, // and @next_position fields of the #GScanner structure. // // Note that, while the token is not removed from the input stream // (i.e. the next call to g_scanner_get_next_token() will return the // same token), it will not be reevaluated. This can lead to surprising // results when changing scope or the scanner configuration after peeking // the next token. Getting the next token after switching the scope or // configuration will return whatever was peeked before, regardless of // any symbols that may have been added or removed in the new scope. func (x *Scanner) PeekNextToken() TokenType { cret := xScannerPeekNextToken(x.GoPointer()) return cret } var xScannerScopeAddSymbol func(uintptr, uint, string, uintptr) // Adds a symbol to the given scope. func (x *Scanner) ScopeAddSymbol(ScopeIdVar uint, SymbolVar string, ValueVar uintptr) { xScannerScopeAddSymbol(x.GoPointer(), ScopeIdVar, SymbolVar, ValueVar) } var xScannerScopeForeachSymbol func(uintptr, uint, uintptr, uintptr) // Calls the given function for each of the symbol/value pairs // in the given scope of the #GScanner. The function is passed // the symbol and value of each pair, and the given @user_data // parameter. func (x *Scanner) ScopeForeachSymbol(ScopeIdVar uint, FuncVar *HFunc, UserDataVar uintptr) { var FuncVarRef uintptr if FuncVar != nil { FuncVarPtr := uintptr(unsafe.Pointer(FuncVar)) if cbRefPtr, ok := GetCallback(FuncVarPtr); ok { FuncVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *FuncVar cbFn(arg0, arg1, arg2) } FuncVarRef = purego.NewCallback(fcb) SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar) } } xScannerScopeForeachSymbol(x.GoPointer(), ScopeIdVar, FuncVarRef, UserDataVar) } var xScannerScopeLookupSymbol func(uintptr, uint, string) uintptr // Looks up a symbol in a scope and return its value. If the // symbol is not bound in the scope, %NULL is returned. func (x *Scanner) ScopeLookupSymbol(ScopeIdVar uint, SymbolVar string) uintptr { cret := xScannerScopeLookupSymbol(x.GoPointer(), ScopeIdVar, SymbolVar) return cret } var xScannerScopeRemoveSymbol func(uintptr, uint, string) // Removes a symbol from a scope. func (x *Scanner) ScopeRemoveSymbol(ScopeIdVar uint, SymbolVar string) { xScannerScopeRemoveSymbol(x.GoPointer(), ScopeIdVar, SymbolVar) } var xScannerSetScope func(uintptr, uint) uint // Sets the current scope. func (x *Scanner) SetScope(ScopeIdVar uint) uint { cret := xScannerSetScope(x.GoPointer(), ScopeIdVar) return cret } var xScannerSyncFileOffset func(uintptr) // Rewinds the filedescriptor to the current buffer position // and blows the file read ahead buffer. This is useful for // third party uses of the scanners filedescriptor, which hooks // onto the current scanning position. func (x *Scanner) SyncFileOffset() { xScannerSyncFileOffset(x.GoPointer()) } var xScannerUnexpToken func(uintptr, TokenType, string, string, string, string, int) // Outputs a message through the scanner's msg_handler, // resulting from an unexpected token in the input stream. // Note that you should not call g_scanner_peek_next_token() // followed by g_scanner_unexp_token() without an intermediate // call to g_scanner_get_next_token(), as g_scanner_unexp_token() // evaluates the scanner's current token (not the peeked token) // to construct part of the message. func (x *Scanner) UnexpToken(ExpectedTokenVar TokenType, IdentifierSpecVar string, SymbolSpecVar string, SymbolNameVar string, MessageVar string, IsErrorVar int) { xScannerUnexpToken(x.GoPointer(), ExpectedTokenVar, IdentifierSpecVar, SymbolSpecVar, SymbolNameVar, MessageVar, IsErrorVar) } var xScannerWarn func(uintptr, string, ...interface{}) // Outputs a warning message, via the #GScanner message handler. func (x *Scanner) Warn(FormatVar string, varArgs ...interface{}) { xScannerWarn(x.GoPointer(), FormatVar, varArgs...) } // Specifies the #GScanner parser configuration. Most settings can // be changed during the parsing phase and will affect the lexical // parsing of the next unpeeked token. type ScannerConfig struct { _ structs.HostLayout CsetSkipCharacters uintptr CsetIdentifierFirst uintptr CsetIdentifierNth uintptr CpairCommentSingle uintptr CaseSensitive uint SkipCommentMulti uint SkipCommentSingle uint ScanCommentMulti uint ScanIdentifier uint ScanIdentifier1char uint ScanIdentifierNULL uint ScanSymbols uint ScanBinary uint ScanOctal uint ScanFloat uint ScanHex uint ScanHexDollar uint ScanStringSq uint ScanStringDq uint Numbers2Int uint Int2Float uint Identifier2String uint Char2Token uint Symbol2Token uint Scope0Fallback uint StoreInt64 uint PaddingDummy uint } func (x *ScannerConfig) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // A union holding the value of the token. type TokenValue = uintptr const ( // The set of uppercase ASCII alphabet characters. // Used for specifying valid identifier characters // in #GScannerConfig. CSET_A_2_Z string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // The set of ASCII digits. // Used for specifying valid identifier characters // in #GScannerConfig. CSET_DIGITS string = "0123456789" // The set of lowercase ASCII alphabet characters. // Used for specifying valid identifier characters // in #GScannerConfig. CSET_a_2_z string = "abcdefghijklmnopqrstuvwxyz" ) // The possible errors, used in the @v_error field // of #GTokenValue, when the token is a %G_TOKEN_ERROR. type ErrorType int const ( // unknown error GErrUnknownValue ErrorType = 0 // unexpected end of file GErrUnexpEofValue ErrorType = 1 // unterminated string constant GErrUnexpEofInStringValue ErrorType = 2 // unterminated comment GErrUnexpEofInCommentValue ErrorType = 3 // non-digit character in a number GErrNonDigitInConstValue ErrorType = 4 // digit beyond radix in a number GErrDigitRadixValue ErrorType = 5 // non-decimal floating point number GErrFloatRadixValue ErrorType = 6 // malformed floating point number GErrFloatMalformedValue ErrorType = 7 ) // The possible types of token returned from each // g_scanner_get_next_token() call. type TokenType int const ( // the end of the file GTokenEofValue TokenType = 0 // a '(' character GTokenLeftParenValue TokenType = 40 // a ')' character GTokenRightParenValue TokenType = 41 // a '{' character GTokenLeftCurlyValue TokenType = 123 // a '}' character GTokenRightCurlyValue TokenType = 125 // a '[' character GTokenLeftBraceValue TokenType = 91 // a ']' character GTokenRightBraceValue TokenType = 93 // a '=' character GTokenEqualSignValue TokenType = 61 // a ',' character GTokenCommaValue TokenType = 44 // not a token GTokenNoneValue TokenType = 256 // an error occurred GTokenErrorValue TokenType = 257 // a character GTokenCharValue TokenType = 258 // a binary integer GTokenBinaryValue TokenType = 259 // an octal integer GTokenOctalValue TokenType = 260 // an integer GTokenIntValue TokenType = 261 // a hex integer GTokenHexValue TokenType = 262 // a floating point number GTokenFloatValue TokenType = 263 // a string GTokenStringValue TokenType = 264 // a symbol GTokenSymbolValue TokenType = 265 // an identifier GTokenIdentifierValue TokenType = 266 // a null identifier GTokenIdentifierNullValue TokenType = 267 // one line comment GTokenCommentSingleValue TokenType = 268 // multi line comment GTokenCommentMultiValue TokenType = 269 ) func init() { core.SetPackageName("GLIB", "glib-2.0") core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GLIB") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xScannerCurLine, libs, "g_scanner_cur_line") core.PuregoSafeRegister(&xScannerCurPosition, libs, "g_scanner_cur_position") core.PuregoSafeRegister(&xScannerCurToken, libs, "g_scanner_cur_token") core.PuregoSafeRegister(&xScannerCurValue, libs, "g_scanner_cur_value") core.PuregoSafeRegister(&xScannerDestroy, libs, "g_scanner_destroy") core.PuregoSafeRegister(&xScannerEof, libs, "g_scanner_eof") core.PuregoSafeRegister(&xScannerError, libs, "g_scanner_error") core.PuregoSafeRegister(&xScannerGetNextToken, libs, "g_scanner_get_next_token") core.PuregoSafeRegister(&xScannerInputFile, libs, "g_scanner_input_file") core.PuregoSafeRegister(&xScannerInputText, libs, "g_scanner_input_text") core.PuregoSafeRegister(&xScannerLookupSymbol, libs, "g_scanner_lookup_symbol") core.PuregoSafeRegister(&xScannerPeekNextToken, libs, "g_scanner_peek_next_token") core.PuregoSafeRegister(&xScannerScopeAddSymbol, libs, "g_scanner_scope_add_symbol") core.PuregoSafeRegister(&xScannerScopeForeachSymbol, libs, "g_scanner_scope_foreach_symbol") core.PuregoSafeRegister(&xScannerScopeLookupSymbol, libs, "g_scanner_scope_lookup_symbol") core.PuregoSafeRegister(&xScannerScopeRemoveSymbol, libs, "g_scanner_scope_remove_symbol") core.PuregoSafeRegister(&xScannerSetScope, libs, "g_scanner_set_scope") core.PuregoSafeRegister(&xScannerSyncFileOffset, libs, "g_scanner_sync_file_offset") core.PuregoSafeRegister(&xScannerUnexpToken, libs, "g_scanner_unexp_token") core.PuregoSafeRegister(&xScannerWarn, libs, "g_scanner_warn") }