objects

package
v0.5.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Overview

pkg/objects/array.go

pkg/objects/bigfloat.go BigFloat represents an arbitrary-precision floating-point value

pkg/objects/bigint.go BigInt represents an arbitrary-precision integer value

pkg/objects/builtin.go

pkg/objects/builtin_crypto.go Encryption helper functions for Charlang compatibility

pkg/objects/builtin_db.go Database builtin functions for Xxlang. Provides two versions of database functions: 1. String-based functions (Charlang compatible): dbQuery, dbQueryRecs, dbQueryMap, etc. 2. Typed functions (preserve native types): dbQueryTyped, dbQueryRowTyped, etc.

pkg/objects/builtin_file_upload.go Built-in functions for file upload handling in server mode.

pkg/objects/builtin_http.go Built-in functions for HTTP server mode.

pkg/objects/builtin_system.go System command builtin functions for Xxlang. Provides systemCmd, systemCmdDetached, and systemStart functions.

pkg/objects/builtin_system_unix.go Unix-specific system command utilities.

pkg/objects/builtin_testing.go Test assertion built-in functions for Xxlang

pkg/objects/bytes.go Bytes is an immutable byte sequence object. It represents a read-only []byte and is useful for binary data handling.

pkg/objects/bytes_buffer.go BytesBuffer is a mutable buffer of bytes for efficient byte operations. It's similar to Go's bytes.Buffer type. NOTE: This type is NOT thread-safe. Users must handle concurrency themselves using Mutex or RWMutex if shared across goroutines.

pkg/objects/chars.go

pkg/objects/class.go

pkg/objects/context.go Context object for timeout and cancellation (similar to Go's context package)

pkg/objects/db.go Database object types for Xxlang. Provides database connection, transaction, rows, and statement objects.

pkg/objects/file.go File object type for streaming file operations in Xxlang.

pkg/objects/file_lock_unix.go File locking implementation for Unix-like systems (Linux, macOS, BSD, etc.)

pkg/objects/float.go

pkg/objects/function.go

pkg/objects/http.go HTTP object types for server mode.

pkg/objects/int.go

pkg/objects/jsonutil.go JSON utility functions for Xxlang objects. These functions are exported for use by both the builtin functions and the stdlib json module.

pkg/objects/map.go

pkg/objects/methods.go

pkg/objects/methods_pptx.go PPTX methods for Xxlang.

pkg/objects/module.go Module object type for runtime module representation.

pkg/objects/object.go

pkg/objects/orderedmap.go OrderedMap is a map that preserves insertion order and supports reordering.

pkg/objects/pdf.go PDF object types for PDF processing in Xxlang. Implemented using only Go standard library - no third-party dependencies.

pkg/objects/pptx.go PPTX object types for Xxlang - PowerPoint file handling.

pkg/objects/queue.go Queue type for Xxlang - FIFO data structure with O(1) push/pop operations.

pkg/objects/reader_writer.go Reader and Writer objects for streaming I/O operations.

pkg/objects/scanner.go Scanner object for reading input from stdin or any io.Reader.

pkg/objects/set.go Set type for Xxlang - unordered collection of unique elements.

pkg/objects/string.go

pkg/objects/stringbuilder.go StringBuilder is a mutable string builder for efficient string concatenation. Unlike regular string concatenation which creates a new string each time, StringBuilder uses an internal buffer to accumulate strings efficiently. NOTE: This type is NOT thread-safe. Users must handle concurrency themselves using Mutex or RWMutex if shared across goroutines.

pkg/objects/sync.go Synchronization primitives for concurrent programming

pkg/objects/tube.go Tube object for concurrent communication (similar to Go channels)

Package objects defines the object types for Xxlang. This file contains the WebView object type for GUI support.

pkg/objects/xlsx.go XLSX workbook type for Xxlang - Excel file handling.

pkg/objects/xml.go XML types for Xxlang - XML document and node handling.

Index

Constants

View Source
const (
	SeekStart   = 0 // Seek relative to start of file
	SeekCurrent = 1 // Seek relative to current position
	SeekEnd     = 2 // Seek relative to end of file
)

Seek constants for use with File.seek()

View Source
const (
	WebSocketTextMessage   = 1
	WebSocketBinaryMessage = 2
	WebSocketCloseMessage  = 8
	WebSocketPingMessage   = 9
	WebSocketPongMessage   = 10
)

WebSocketMessageType constants

View Source
const (
	PPTX_NS_A       = "http://schemas.openxmlformats.org/drawingml/2006/main"
	PPTX_NS_R       = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
	PPTX_NS_P       = "http://schemas.openxmlformats.org/presentationml/2006/main"
	PPTX_NS_PIC     = "http://schemas.openxmlformats.org/drawingml/2006/picture"
	PPTX_NS_C       = "http://schemas.openxmlformats.org/drawingml/2006/chart"
	PPTX_NS_C_R     = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"
	PPTX_NS_RELS    = "http://schemas.openxmlformats.org/package/2006/relationships"
	PPTX_NS_CONTENT = "http://schemas.openxmlformats.org/package/2006/content-types"
)

XML Namespaces for PPTX

View Source
const (
	EMU_PER_INCH  = 914400
	EMU_PER_POINT = 12700
	EMU_PER_PIXEL = 9525 // at 96 DPI
)

EMU conversion constants (English Metric Units)

View Source
const DefaultBigFloatPrecision = 256

DefaultBigFloatPrecision is the default precision for BigFloat values (256 bits)

View Source
const IntCacheMax = 100000

IntCacheMax is the maximum cached integer value Extended to cover common loop indices and calculation results

View Source
const IntCacheMin = -1000

IntCacheMin is the minimum cached integer value

Variables

View Source
var (
	ContextCanceled         = &Error{Message: "context canceled"}
	ContextDeadlineExceeded = &Error{Message: "context deadline exceeded"}
)

Context error types for Xxlang

View Source
var (
	FLOAT_ZERO     = &Float{Value: 0.0}
	FLOAT_ONE      = &Float{Value: 1.0}
	FLOAT_NEG_ONE  = &Float{Value: -1.0}
	FLOAT_TWO      = &Float{Value: 2.0}
	FLOAT_HALF     = &Float{Value: 0.5}
	FLOAT_TEN      = &Float{Value: 10.0}
	FLOAT_HUNDRED  = &Float{Value: 100.0}
	FLOAT_THOUSAND = &Float{Value: 1000.0}
	FLOAT_PI       = &Float{Value: 3.14159265358979323846}
	FLOAT_E        = &Float{Value: 2.71828182845904523536}
)

Pre-cached common float values Unlike integers, we can only cache a small set due to the infinite nature of floats

View Source
var (
	TRUE  = &Bool{Value: true}
	FALSE = &Bool{Value: false}
)

TRUE and FALSE are singleton boolean values

View Source
var (
	STRING_EMPTY   = &String{Value: ""}
	STRING_TRUE    = &String{Value: "true"}
	STRING_FALSE   = &String{Value: "false"}
	STRING_NULL    = &String{Value: "null"}
	STRING_INT     = &String{Value: "INT"}
	STRING_FLOAT   = &String{Value: "FLOAT"}
	STRING_BOOL    = &String{Value: "BOOL"}
	STRING_STRING  = &String{Value: "STRING"}
	STRING_ARRAY   = &String{Value: "ARRAY"}
	STRING_MAP     = &String{Value: "MAP"}
	STRING_FUNC    = &String{Value: "FUNCTION"}
	STRING_BUILTIN = &String{Value: "BUILTIN"}
	STRING_ERROR   = &String{Value: "ERROR"}
	STRING_NIL     = &String{Value: "nil"}
	STRING_ZERO    = &String{Value: "0"}
	STRING_ONE     = &String{Value: "1"}
	STRING_SPACE   = &String{Value: " "}
	STRING_NEWLINE = &String{Value: "\n"}
)

Pre-cached common string values

View Source
var (
	BYTES_EMPTY = &Bytes{Value: []byte{}}
)

Pre-cached common Bytes values

View Source
var BuiltinDbClose = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) != 1 {
			return newError("wrong number of arguments for dbClose. got=%d, want=1", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("argument to 'dbClose' must be DB, got %s", args[0].Type())
		}

		if err := db.Close(); err != nil {
			return newError("failed to close database: %v", err)
		}

		return NULL
	},
}

BuiltinDbClose closes a database connection.

View Source
var BuiltinDbConnect = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbConnect. got=%d, want=2", len(args))
		}

		driver, ok := args[0].(*String)
		if !ok {
			return newError("first argument to 'dbConnect' must be STRING (driver), got %s", args[0].Type())
		}

		connStr, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbConnect' must be STRING (connection string), got %s", args[1].Type())
		}

		driverName := driver.Value

		switch driverName {
		case "sqlite3":
			driverName = "sqlite"
		case "pg", "postgresql":
			driverName = "postgres"
		case "sqlserver", "mssqlserver":
			driverName = "mssql"
		}

		db, err := sql.Open(driverName, connStr.Value)
		if err != nil {
			return newError("failed to open database: %v", err)
		}

		if err := db.Ping(); err != nil {
			db.Close()
			return newError("failed to connect to database: %v", err)
		}

		return NewDB(db, driverName, connStr.Value)
	},
}

BuiltinDbConnect connects to a database and returns a DB object.

View Source
var BuiltinDbExec = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbExec. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbExec' must be DB, got %s", args[0].Type())
		}

		sqlStmt, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbExec' must be STRING, got %s", args[1].Type())
		}

		execArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			execArgs[i] = objectToGoValue(arg)
		}

		result, err := db.Value.Exec(sqlStmt.Value, execArgs...)
		if err != nil {
			return newError("exec failed: %v", err)
		}

		lastID, _ := result.LastInsertId()
		rowsAffected, _ := result.RowsAffected()

		return NewArray([]Object{
			NewInt(lastID),
			NewInt(rowsAffected),
		})
	},
}

BuiltinDbExec executes a SQL statement (INSERT, UPDATE, DELETE, etc.) Returns: [lastInsertId, rowsAffected]

View Source
var BuiltinDbQuery = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbQuery. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQuery' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQuery' must be STRING, got %s", args[1].Type())
		}

		queryArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		columns, err := rows.Columns()
		if err != nil {
			return newError("failed to get columns: %v", err)
		}

		var result []Object

		for rows.Next() {
			values := make([]interface{}, len(columns))
			valuePtrs := make([]interface{}, len(columns))
			for i := range values {
				valuePtrs[i] = &values[i]
			}

			if err := rows.Scan(valuePtrs...); err != nil {
				return newError("scan failed: %v", err)
			}

			pairs := make(map[HashKey]MapPair)
			for i, col := range columns {
				key := NewString(col)
				pairs[key.HashKey()] = MapPair{
					Key:   key,
					Value: NewString(dbValueToString(values[i])),
				}
			}
			result = append(result, NewMap(pairs))
		}

		if err := rows.Err(); err != nil {
			return newError("rows error: %v", err)
		}

		return NewArray(result)
	},
}

BuiltinDbQuery executes a SQL query and returns results as an array of maps. All values are converted to strings (Charlang behavior).

View Source
var BuiltinDbQueryArrayTyped = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbQueryArrayTyped. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryArrayTyped' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryArrayTyped' must be STRING, got %s", args[1].Type())
		}

		queryArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		columns, err := rows.Columns()
		if err != nil {
			return newError("failed to get columns: %v", err)
		}

		var result []Object

		for rows.Next() {
			values := make([]interface{}, len(columns))
			valuePtrs := make([]interface{}, len(columns))
			for i := range values {
				valuePtrs[i] = &values[i]
			}

			if err := rows.Scan(valuePtrs...); err != nil {
				return newError("scan failed: %v", err)
			}

			rowArray := make([]Object, len(columns))
			for i, val := range values {
				rowArray[i] = dbValueToObjectPreserveType(val)
			}
			result = append(result, NewArray(rowArray))
		}

		if err := rows.Err(); err != nil {
			return newError("rows error: %v", err)
		}

		return NewArray(result)
	},
}

BuiltinDbQueryArrayTyped executes a SQL query and returns results as a 2D array. Native data types are preserved.

View Source
var BuiltinDbQueryCount = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbQueryCount. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryCount' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryCount' must be STRING, got %s", args[1].Type())
		}

		queryArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return NewInt(-1)
		}
		defer rows.Close()

		if !rows.Next() {
			return NewInt(-1)
		}

		var count int = -1
		if err := rows.Scan(&count); err != nil {
			return NewInt(-1)
		}

		return NewInt(int64(count))
	},
}

BuiltinDbQueryCount executes a SQL query that returns a single integer value. Returns -1 on error.

View Source
var BuiltinDbQueryFloat = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbQueryFloat. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryFloat' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryFloat' must be STRING, got %s", args[1].Type())
		}

		queryArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		if !rows.Next() {
			return &Float{Value: 0}
		}

		var val float64
		if err := rows.Scan(&val); err != nil {
			return newError("scan failed: %v", err)
		}

		return &Float{Value: val}
	},
}

BuiltinDbQueryFloat executes a SQL query that returns a single float value.

View Source
var BuiltinDbQueryMap = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 3 {
			return newError("wrong number of arguments for dbQueryMap. got=%d, want>=3", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryMap' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryMap' must be STRING, got %s", args[1].Type())
		}

		keyCol, ok := args[2].(*String)
		if !ok {
			return newError("third argument to 'dbQueryMap' must be STRING (key column), got %s", args[2].Type())
		}

		queryArgs := make([]interface{}, len(args)-3)
		for i, arg := range args[3:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		columns, err := rows.Columns()
		if err != nil {
			return newError("failed to get columns: %v", err)
		}

		keyColIdx := -1
		for i, col := range columns {
			if col == keyCol.Value {
				keyColIdx = i
				break
			}
		}
		if keyColIdx < 0 {
			return newError("key column '%s' not found in result", keyCol.Value)
		}

		result := make(map[HashKey]MapPair)

		for rows.Next() {
			values := make([]interface{}, len(columns))
			valuePtrs := make([]interface{}, len(columns))
			for i := range values {
				valuePtrs[i] = &values[i]
			}

			if err := rows.Scan(valuePtrs...); err != nil {
				return newError("scan failed: %v", err)
			}

			pairs := make(map[HashKey]MapPair)
			for i, col := range columns {
				key := NewString(col)
				pairs[key.HashKey()] = MapPair{
					Key:   key,
					Value: NewString(dbValueToString(values[i])),
				}
			}

			keyValue := NewString(dbValueToString(values[keyColIdx]))
			result[keyValue.HashKey()] = MapPair{
				Key:   keyValue,
				Value: NewMap(pairs),
			}
		}

		if err := rows.Err(); err != nil {
			return newError("rows error: %v", err)
		}

		return NewMap(result)
	},
}

BuiltinDbQueryMap executes a SQL query and returns results as a map grouped by a key column. All values are converted to strings. Usage: dbQueryMap(db, sql, keyColumn, args...)

View Source
var BuiltinDbQueryMapArray = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 3 {
			return newError("wrong number of arguments for dbQueryMapArray. got=%d, want>=3", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryMapArray' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryMapArray' must be STRING, got %s", args[1].Type())
		}

		keyCol, ok := args[2].(*String)
		if !ok {
			return newError("third argument to 'dbQueryMapArray' must be STRING (key column), got %s", args[2].Type())
		}

		queryArgs := make([]interface{}, len(args)-3)
		for i, arg := range args[3:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		columns, err := rows.Columns()
		if err != nil {
			return newError("failed to get columns: %v", err)
		}

		keyColIdx := -1
		for i, col := range columns {
			if col == keyCol.Value {
				keyColIdx = i
				break
			}
		}
		if keyColIdx < 0 {
			return newError("key column '%s' not found in result", keyCol.Value)
		}

		tempResult := make(map[string][]Object)

		for rows.Next() {
			values := make([]interface{}, len(columns))
			valuePtrs := make([]interface{}, len(columns))
			for i := range values {
				valuePtrs[i] = &values[i]
			}

			if err := rows.Scan(valuePtrs...); err != nil {
				return newError("scan failed: %v", err)
			}

			pairs := make(map[HashKey]MapPair)
			for i, col := range columns {
				key := NewString(col)
				pairs[key.HashKey()] = MapPair{
					Key:   key,
					Value: NewString(dbValueToString(values[i])),
				}
			}

			keyValue := dbValueToString(values[keyColIdx])
			tempResult[keyValue] = append(tempResult[keyValue], NewMap(pairs))
		}

		if err := rows.Err(); err != nil {
			return newError("rows error: %v", err)
		}

		result := make(map[HashKey]MapPair)
		for keyStr, arr := range tempResult {
			keyObj := NewString(keyStr)
			result[keyObj.HashKey()] = MapPair{
				Key:   keyObj,
				Value: NewArray(arr),
			}
		}

		return NewMap(result)
	},
}

BuiltinDbQueryMapArray executes a SQL query and returns results as a map of arrays grouped by a key column. All values are converted to strings. Usage: dbQueryMapArray(db, sql, keyColumn, args...)

View Source
var BuiltinDbQueryOrdered = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbQueryOrdered. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryOrdered' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryOrdered' must be STRING, got %s", args[1].Type())
		}

		queryArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		columns, err := rows.Columns()
		if err != nil {
			return newError("failed to get columns: %v", err)
		}

		var result []Object

		for rows.Next() {
			values := make([]interface{}, len(columns))
			valuePtrs := make([]interface{}, len(columns))
			for i := range values {
				valuePtrs[i] = &values[i]
			}

			if err := rows.Scan(valuePtrs...); err != nil {
				return newError("scan failed: %v", err)
			}

			pairs := make([]Object, len(columns))
			for i, col := range columns {
				pairs[i] = NewArray([]Object{
					NewString(col),
					NewString(dbValueToString(values[i])),
				})
			}
			result = append(result, NewArray(pairs))
		}

		if err := rows.Err(); err != nil {
			return newError("rows error: %v", err)
		}

		return NewArray(result)
	},
}

BuiltinDbQueryOrdered executes a SQL query and returns results as an array of ordered maps. All values are converted to strings.

View Source
var BuiltinDbQueryRecs = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbQueryRecs. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryRecs' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryRecs' must be STRING, got %s", args[1].Type())
		}

		queryArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		columns, err := rows.Columns()
		if err != nil {
			return newError("failed to get columns: %v", err)
		}

		var result []Object

		headerRow := make([]Object, len(columns))
		for i, col := range columns {
			headerRow[i] = NewString(col)
		}
		result = append(result, NewArray(headerRow))

		for rows.Next() {
			values := make([]interface{}, len(columns))
			valuePtrs := make([]interface{}, len(columns))
			for i := range values {
				valuePtrs[i] = &values[i]
			}

			if err := rows.Scan(valuePtrs...); err != nil {
				return newError("scan failed: %v", err)
			}

			rowArray := make([]Object, len(columns))
			for i, val := range values {
				rowArray[i] = NewString(dbValueToString(val))
			}
			result = append(result, NewArray(rowArray))
		}

		if err := rows.Err(); err != nil {
			return newError("rows error: %v", err)
		}

		return NewArray(result)
	},
}

BuiltinDbQueryRecs executes a SQL query and returns results as a 2D string array. The first row contains column names (Charlang behavior).

View Source
var BuiltinDbQueryRowTyped = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbQueryRowTyped. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryRowTyped' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryRowTyped' must be STRING, got %s", args[1].Type())
		}

		queryArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		if !rows.Next() {
			return NULL
		}

		columns, err := rows.Columns()
		if err != nil {
			return newError("failed to get columns: %v", err)
		}

		values := make([]interface{}, len(columns))
		valuePtrs := make([]interface{}, len(columns))
		for i := range values {
			valuePtrs[i] = &values[i]
		}

		if err := rows.Scan(valuePtrs...); err != nil {
			return newError("scan failed: %v", err)
		}

		pairs := make(map[HashKey]MapPair)
		for i, col := range columns {
			key := NewString(col)
			pairs[key.HashKey()] = MapPair{
				Key:   key,
				Value: dbValueToObjectPreserveType(values[i]),
			}
		}

		return NewMap(pairs)
	},
}

BuiltinDbQueryRowTyped executes a SQL query and returns a single row as a map. Native data types are preserved.

View Source
var BuiltinDbQueryString = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbQueryString. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryString' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryString' must be STRING, got %s", args[1].Type())
		}

		queryArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		if !rows.Next() {
			return NewString("")
		}

		var val string
		if err := rows.Scan(&val); err != nil {
			return newError("scan failed: %v", err)
		}

		return NewString(val)
	},
}

BuiltinDbQueryString executes a SQL query that returns a single string value.

View Source
var BuiltinDbQueryTyped = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbQueryTyped. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryTyped' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryTyped' must be STRING, got %s", args[1].Type())
		}

		queryArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		columns, err := rows.Columns()
		if err != nil {
			return newError("failed to get columns: %v", err)
		}

		var result []Object

		for rows.Next() {
			values := make([]interface{}, len(columns))
			valuePtrs := make([]interface{}, len(columns))
			for i := range values {
				valuePtrs[i] = &values[i]
			}

			if err := rows.Scan(valuePtrs...); err != nil {
				return newError("scan failed: %v", err)
			}

			pairs := make(map[HashKey]MapPair)
			for i, col := range columns {
				key := NewString(col)
				pairs[key.HashKey()] = MapPair{
					Key:   key,
					Value: dbValueToObjectPreserveType(values[i]),
				}
			}
			result = append(result, NewMap(pairs))
		}

		if err := rows.Err(); err != nil {
			return newError("rows error: %v", err)
		}

		return NewArray(result)
	},
}

BuiltinDbQueryTyped executes a SQL query and returns results as an array of maps. Native data types are preserved (int, float, bool, string, time).

View Source
var BuiltinDbQueryValueTyped = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 2 {
			return newError("wrong number of arguments for dbQueryValueTyped. got=%d, want>=2", len(args))
		}

		db, ok := args[0].(*DB)
		if !ok {
			return newError("first argument to 'dbQueryValueTyped' must be DB, got %s", args[0].Type())
		}

		query, ok := args[1].(*String)
		if !ok {
			return newError("second argument to 'dbQueryValueTyped' must be STRING, got %s", args[1].Type())
		}

		queryArgs := make([]interface{}, len(args)-2)
		for i, arg := range args[2:] {
			queryArgs[i] = objectToGoValue(arg)
		}

		rows, err := db.Value.Query(query.Value, queryArgs...)
		if err != nil {
			return newError("query failed: %v", err)
		}
		defer rows.Close()

		if !rows.Next() {
			return NULL
		}

		var value interface{}
		if err := rows.Scan(&value); err != nil {
			return newError("scan failed: %v", err)
		}

		return dbValueToObjectPreserveType(value)
	},
}

BuiltinDbQueryValueTyped executes a SQL query that returns a single value. Native data types are preserved.

View Source
var BuiltinFormatSQLValue = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) != 1 {
			return newError("wrong number of arguments for formatSQLValue. got=%d, want=1", len(args))
		}

		str, ok := args[0].(*String)
		if !ok {
			return newError("argument to 'formatSQLValue' must be STRING, got %s", args[0].Type())
		}

		result := strings.Replace(str.Value, "\r", "\\r", -1)
		result = strings.Replace(result, "\n", "\\n", -1)
		result = strings.Replace(result, "'", "''", -1)

		return NewString(result)
	},
}

BuiltinFormatSQLValue escapes special characters in a string for safe SQL usage.

View Source
var BuiltinSystemCmd = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 1 {
			return newError("wrong number of arguments for systemCmd. got=%d, want>=1", len(args))
		}

		cmdStr, ok := args[0].(*String)
		if !ok {
			return newError("first argument to 'systemCmd' must be STRING, got %s", args[0].Type())
		}

		// Build command arguments
		var cmdArgs []string
		for i := 1; i < len(args); i++ {
			if arg, ok := args[i].(*String); ok {
				cmdArgs = append(cmdArgs, arg.Value)
			} else {
				return newError("argument %d to 'systemCmd' must be STRING, got %s", i+1, args[i].Type())
			}
		}

		// Execute command
		var cmd *exec.Cmd
		if runtime.GOOS == "windows" {

			if len(cmdArgs) > 0 {
				cmd = exec.Command(cmdStr.Value, cmdArgs...)
			} else {
				cmd = exec.Command("cmd", "/c", cmdStr.Value)
			}
		} else {

			if len(cmdArgs) > 0 {
				cmd = exec.Command(cmdStr.Value, cmdArgs...)
			} else {
				cmd = exec.Command("sh", "-c", cmdStr.Value)
			}
		}

		// Capture output
		var stdout, stderr bytes.Buffer
		cmd.Stdout = &stdout
		cmd.Stderr = &stderr
		cmd.Stdin = nil

		err := cmd.Run()
		output := stdout.String() + stderr.String()

		result := NewOrderedMap()
		result.Set(NewString("output"), NewString(output))

		if err != nil {
			if exitErr, ok := err.(*exec.ExitError); ok {
				result.Set(NewString("success"), FALSE)
				result.Set(NewString("exitCode"), NewInt(int64(exitErr.ExitCode())))
				result.Set(NewString("error"), NewString(err.Error()))
			} else {
				result.Set(NewString("success"), FALSE)
				result.Set(NewString("exitCode"), NewInt(-1))
				result.Set(NewString("error"), NewString(err.Error()))
			}
		} else {
			result.Set(NewString("success"), TRUE)
			result.Set(NewString("exitCode"), NewInt(0))
			result.Set(NewString("error"), NewString(""))
		}

		return result
	},
}

BuiltinSystemCmd executes a system command synchronously and returns the result. Usage: systemCmd(cmd) or systemCmd(cmd, args...) Returns a map with:

  • "success": bool - whether the command succeeded
  • "exitCode": int - the exit code
  • "output": string - combined stdout and stderr
  • "error": string - error message if any
View Source
var BuiltinSystemCmdDetached = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 1 {
			return newError("wrong number of arguments for systemCmdDetached. got=%d, want>=1", len(args))
		}

		cmdStr, ok := args[0].(*String)
		if !ok {
			return newError("first argument to 'systemCmdDetached' must be STRING, got %s", args[0].Type())
		}

		// Build command arguments
		var cmdArgs []string
		for i := 1; i < len(args); i++ {
			if arg, ok := args[i].(*String); ok {
				cmdArgs = append(cmdArgs, arg.Value)
			} else {
				return newError("argument %d to 'systemCmdDetached' must be STRING, got %s", i+1, args[i].Type())
			}
		}

		// Create command
		var cmd *exec.Cmd
		if runtime.GOOS == "windows" {
			if len(cmdArgs) > 0 {
				cmd = exec.Command(cmdStr.Value, cmdArgs...)
			} else {
				cmd = exec.Command("cmd", "/c", cmdStr.Value)
			}
		} else {
			if len(cmdArgs) > 0 {
				cmd = exec.Command(cmdStr.Value, cmdArgs...)
			} else {
				cmd = exec.Command("sh", "-c", cmdStr.Value)
			}
		}

		cmd.Stdin = nil
		cmd.Stdout = nil
		cmd.Stderr = nil

		setDetachedAttr(cmd)

		err := cmd.Start()

		result := NewOrderedMap()
		if err != nil {
			result.Set(NewString("success"), FALSE)
			result.Set(NewString("pid"), NewInt(0))
			result.Set(NewString("error"), NewString(err.Error()))
			return result
		}

		pid := 0
		if cmd.Process != nil {
			pid = cmd.Process.Pid
		}

		cmd.Process.Release()

		result.Set(NewString("success"), TRUE)
		result.Set(NewString("pid"), NewInt(int64(pid)))
		result.Set(NewString("error"), NewString(""))

		return result
	},
}

BuiltinSystemCmdDetached executes a system command in detached mode (asynchronously). The command runs in the background without waiting for completion. Usage: systemCmdDetached(cmd) or systemCmdDetached(cmd, args...) Returns a map with:

  • "success": bool - whether the command was started successfully
  • "pid": int - process ID (0 if not available)
  • "error": string - error message if any
View Source
var BuiltinSystemStart = &Builtin{
	Fn: func(args ...Object) Object {
		if len(args) < 1 {
			return newError("wrong number of arguments for systemStart. got=%d, want>=1", len(args))
		}

		pathStr, ok := args[0].(*String)
		if !ok {
			return newError("first argument to 'systemStart' must be STRING, got %s", args[0].Type())
		}

		path := pathStr.Value

		// Optional working directory
		var workingDir string
		if len(args) >= 2 {
			if wd, ok := args[1].(*String); ok {
				workingDir = wd.Value
			}
		}

		var err error

		switch runtime.GOOS {
		case "windows":

			cmd := exec.Command("cmd", "/c", "start", "", path)
			if workingDir != "" {
				cmd.Dir = workingDir
			}
			cmd.Stdout = nil
			cmd.Stderr = nil
			err = cmd.Run()

		case "darwin":

			cmd := exec.Command("open", path)
			if workingDir != "" {
				cmd.Dir = workingDir
			}
			cmd.Stdout = nil
			cmd.Stderr = nil
			err = cmd.Run()

		case "linux":

			cmd := exec.Command("xdg-open", path)
			if workingDir != "" {
				cmd.Dir = workingDir
			}
			cmd.Stdout = nil
			cmd.Stderr = nil
			err = cmd.Run()

		default:
			err = fmt.Errorf("unsupported platform: %s", runtime.GOOS)
		}

		result := NewOrderedMap()
		if err != nil {
			result.Set(NewString("success"), FALSE)
			result.Set(NewString("error"), NewString(err.Error()))
		} else {
			result.Set(NewString("success"), TRUE)
			result.Set(NewString("error"), NewString(""))
		}

		return result
	},
}

BuiltinSystemStart starts a program or opens a file/URL with the default application. This is similar to the "start" command on Windows or "open" on macOS. Usage: systemStart(path) or systemStart(path, workingDir) Returns a map with:

  • "success": bool - whether the operation succeeded
  • "error": string - error message if any
View Source
var Builtins = map[string]*Builtin{}/* 203 elements not displayed */

Builtins contains all built-in functions

View Source
var (
	CHARS_EMPTY = &Chars{Value: []rune{}}
)

Pre-cached common chars values

View Source
var EMPTY_ARRAY = &Array{Elements: emptyElements}

Pre-cached empty array

View Source
var EMPTY_MAP = &Map{Pairs: emptyPairs}

Pre-cached empty map

View Source
var FileUploadBuiltins = map[string]*Builtin{

	"getFileUploads": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for getFileUploads. got=%d, want=1", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("argument to 'getFileUploads' must be HTTP_REQ, got %s", args[0].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			if err := req.Value.ParseMultipartForm(32 << 20); err != nil {

				if strings.Contains(err.Error(), "multipart") {
					return NewMap(make(map[HashKey]MapPair))
				}
				return newError("failed to parse multipart form: %v", err)
			}

			pairs := make(map[HashKey]MapPair)
			for key, fileHeaders := range req.Value.MultipartForm.File {
				k := NewString(key)
				uploads := make([]Object, len(fileHeaders))
				for i, fh := range fileHeaders {
					uploads[i] = NewFileUpload(fh)
				}
				pairs[k.HashKey()] = MapPair{Key: k, Value: NewArray(uploads)}
			}

			return NewMap(pairs)
		},
	},

	"getFileUpload": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for getFileUpload. got=%d, want=2", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("first argument to 'getFileUpload' must be HTTP_REQ, got %s", args[0].Type())
			}

			fieldName, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'getFileUpload' must be STRING, got %s", args[1].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			if err := req.Value.ParseMultipartForm(32 << 20); err != nil {
				return NULL
			}

			file, header, err := req.Value.FormFile(fieldName.Value)
			if err != nil {
				return NULL
			}
			file.Close()

			return NewFileUpload(header)
		},
	},

	"saveFile": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for saveFile. got=%d, want=2", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("first argument to 'saveFile' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			path, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'saveFile' must be STRING, got %s", args[1].Type())
			}

			savedPath, err := file.Save(path.Value)
			if err != nil {
				return NewFileUploadResult(false, err.Error(), "", file.Header.Filename, 0)
			}

			return NewFileUploadResult(true, "File saved successfully", savedPath, file.Header.Filename, file.Header.Size)
		},
	},

	"saveFileToDir": {
		Fn: func(args ...Object) Object {
			if len(args) < 2 || len(args) > 3 {
				return newError("wrong number of arguments for saveFileToDir. got=%d, want=2 or 3", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("first argument to 'saveFileToDir' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			dirPath, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'saveFileToDir' must be STRING, got %s", args[1].Type())
			}

			autoRename := false
			if len(args) == 3 {
				ar, ok := args[2].(*Bool)
				if !ok {
					return newError("third argument to 'saveFileToDir' must be BOOL, got %s", args[2].Type())
				}
				autoRename = ar.Value
			}

			savedPath, err := file.SaveToDir(dirPath.Value, autoRename)
			if err != nil {
				return NewFileUploadResult(false, err.Error(), "", file.Header.Filename, 0)
			}

			return NewFileUploadResult(true, "File saved successfully", savedPath, file.Header.Filename, file.Header.Size)
		},
	},

	"readFile": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for readFile. got=%d, want=1", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("argument to 'readFile' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			content, err := file.ReadAsString()
			if err != nil {
				return newError("failed to read file: %v", err)
			}

			return NewString(content)
		},
	},

	"readFileBytes": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for readFileBytes. got=%d, want=1", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("argument to 'readFileBytes' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			data, err := file.ReadAll()
			if err != nil {
				return newError("failed to read file: %v", err)
			}

			return NewBytesBufferFromBytes(data)
		},
	},

	"fileHashSHA256": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for fileHashSHA256. got=%d, want=1", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("argument to 'fileHashSHA256' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			hash, err := file.HashSHA256()
			if err != nil {
				return newError("failed to calculate hash: %v", err)
			}

			return NewString(hash)
		},
	},

	"isFileUpload": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for isFileUpload. got=%d, want=1", len(args))
			}
			_, ok := args[0].(*FileUpload)
			return &Bool{Value: ok}
		},
	},

	"isFileUploadResult": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for isFileUploadResult. got=%d, want=1", len(args))
			}
			_, ok := args[0].(*FileUploadResult)
			return &Bool{Value: ok}
		},
	},

	"parseMultipartForm": {
		Fn: func(args ...Object) Object {
			if len(args) < 1 || len(args) > 2 {
				return newError("wrong number of arguments for parseMultipartForm. got=%d, want=1 or 2", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("first argument to 'parseMultipartForm' must be HTTP_REQ, got %s", args[0].Type())
			}

			maxMemory := int64(32 << 20)
			if len(args) == 2 {
				m, ok := args[1].(*Int)
				if !ok {
					return newError("second argument to 'parseMultipartForm' must be INT, got %s", args[1].Type())
				}
				maxMemory = m.Value
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			formValues, files, err := ParseMultipartForm(req.Value, maxMemory)
			if err != nil {
				return newError("failed to parse multipart form: %v", err)
			}

			resultPairs := make(map[HashKey]MapPair)

			valuesPairs := make(map[HashKey]MapPair)
			for key, vals := range formValues {
				k := NewString(key)
				var v Object
				if len(vals) == 1 {
					v = NewString(vals[0])
				} else {
					elements := make([]Object, len(vals))
					for i, val := range vals {
						elements[i] = NewString(val)
					}
					v = NewArray(elements)
				}
				valuesPairs[k.HashKey()] = MapPair{Key: k, Value: v}
			}
			resultPairs[NewString("values").HashKey()] = MapPair{
				Key:   NewString("values"),
				Value: NewMap(valuesPairs),
			}

			filesPairs := make(map[HashKey]MapPair)
			for key, uploads := range files {
				k := NewString(key)
				elements := make([]Object, len(uploads))
				for i, upload := range uploads {
					elements[i] = upload
				}
				filesPairs[k.HashKey()] = MapPair{Key: k, Value: NewArray(elements)}
			}
			resultPairs[NewString("files").HashKey()] = MapPair{
				Key:   NewString("files"),
				Value: NewMap(filesPairs),
			}

			return NewMap(resultPairs)
		},
	},

	"safePath": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for safePath. got=%d, want=2", len(args))
			}

			baseDir, ok := args[0].(*String)
			if !ok {
				return newError("first argument to 'safePath' must be STRING, got %s", args[0].Type())
			}

			filename, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'safePath' must be STRING, got %s", args[1].Type())
			}

			safe, err := SafePath(baseDir.Value, filename.Value)
			if err != nil {
				return newError("unsafe path: %v", err)
			}

			return NewString(safe)
		},
	},

	"validateFile": {
		Fn: func(args ...Object) Object {
			if len(args) < 2 {
				return newError("wrong number of arguments for validateFile. got=%d, want at least 2", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("first argument to 'validateFile' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			maxSize, ok := args[1].(*Int)
			if !ok {
				return newError("second argument to 'validateFile' must be INT, got %s", args[1].Type())
			}

			if maxSize.Value > 0 && file.Header.Size > maxSize.Value {
				return &Bool{Value: false}
			}

			if len(args) > 2 {
				ext := strings.ToLower(filepath.Ext(file.Header.Filename))
				allowed := false
				for i := 2; i < len(args); i++ {
					allowedExt, ok := args[i].(*String)
					if !ok {
						continue
					}
					checkExt := strings.ToLower(allowedExt.Value)
					if !strings.HasPrefix(checkExt, ".") {
						checkExt = "." + checkExt
					}
					if checkExt == ext {
						allowed = true
						break
					}
				}
				if !allowed {
					return &Bool{Value: false}
				}
			}

			return &Bool{Value: true}
		},
	},

	"getFileExtension": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for getFileExtension. got=%d, want=1", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("argument to 'getFileExtension' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			return NewString(filepath.Ext(file.Header.Filename))
		},
	},

	"getFileName": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for getFileName. got=%d, want=1", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("argument to 'getFileName' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			name := strings.TrimSuffix(file.Header.Filename, filepath.Ext(file.Header.Filename))
			return NewString(name)
		},
	},

	"getFileSize": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for getFileSize. got=%d, want=1", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("argument to 'getFileSize' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			return NewInt(file.Header.Size)
		},
	},

	"getFileContentType": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for getFileContentType. got=%d, want=1", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("argument to 'getFileContentType' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			return NewString(file.Header.Header.Get("Content-Type"))
		},
	},

	"openFileUpload": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for openFileUpload. got=%d, want=1", len(args))
			}

			file, ok := args[0].(*FileUpload)
			if !ok {
				return newError("argument to 'openFileUpload' must be FILE_UPLOAD, got %s", args[0].Type())
			}

			f, err := file.Header.Open()
			if err != nil {
				return newError("failed to open file: %v", err)
			}
			defer f.Close()

			data, err := io.ReadAll(f)
			if err != nil {
				return newError("failed to read file: %v", err)
			}

			return NewBytesBufferFromBytes(data)
		},
	},

	"saveUploadedFile": {
		Fn: func(args ...Object) Object {
			if len(args) < 3 || len(args) > 4 {
				return newError("wrong number of arguments for saveUploadedFile. got=%d, want=3 or 4", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("first argument to 'saveUploadedFile' must be HTTP_REQ, got %s", args[0].Type())
			}

			fieldName, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'saveUploadedFile' must be STRING, got %s", args[1].Type())
			}

			dirPath, ok := args[2].(*String)
			if !ok {
				return newError("third argument to 'saveUploadedFile' must be STRING, got %s", args[2].Type())
			}

			if req.Value == nil {
				return NewFileUploadResult(false, "http request is nil", "", "", 0)
			}

			maxSize := int64(10 * 1024 * 1024)
			autoRename := true
			var allowedExtensions []string

			if len(args) == 4 {
				opts, ok := args[3].(*Map)
				if !ok {
					return newError("fourth argument to 'saveUploadedFile' must be MAP, got %s", args[3].Type())
				}

				for _, pair := range opts.Pairs {
					keyStr, ok := pair.Key.(*String)
					if !ok {
						continue
					}

					switch keyStr.Value {
					case "maxSize":
						if v, ok := pair.Value.(*Int); ok {
							maxSize = v.Value
						}
					case "autoRename":
						if v, ok := pair.Value.(*Bool); ok {
							autoRename = v.Value
						}
					case "allowedExtensions":
						if arr, ok := pair.Value.(*Array); ok {
							for _, elem := range arr.Elements {
								if s, ok := elem.(*String); ok {
									allowedExtensions = append(allowedExtensions, s.Value)
								}
							}
						}
					}
				}
			}

			if err := req.Value.ParseMultipartForm(maxSize); err != nil {
				return NewFileUploadResult(false, fmt.Sprintf("failed to parse form: %v", err), "", "", 0)
			}

			file, header, err := req.Value.FormFile(fieldName.Value)
			if err != nil {
				return NewFileUploadResult(false, fmt.Sprintf("file not found: %v", err), "", "", 0)
			}
			file.Close()

			upload := NewFileUpload(header)

			if header.Size > maxSize {
				return NewFileUploadResult(false, fmt.Sprintf("file size %d exceeds maximum %d", header.Size, maxSize), "", header.Filename, header.Size)
			}

			if len(allowedExtensions) > 0 {
				ext := strings.ToLower(filepath.Ext(header.Filename))
				allowed := false
				for _, ae := range allowedExtensions {
					checkExt := strings.ToLower(ae)
					if !strings.HasPrefix(checkExt, ".") {
						checkExt = "." + checkExt
					}
					if checkExt == ext {
						allowed = true
						break
					}
				}
				if !allowed {
					return NewFileUploadResult(false, fmt.Sprintf("file extension %s is not allowed", ext), "", header.Filename, header.Size)
				}
			}

			savedPath, err := upload.SaveToDir(dirPath.Value, autoRename)
			if err != nil {
				return NewFileUploadResult(false, err.Error(), "", header.Filename, header.Size)
			}

			return NewFileUploadResult(true, "File saved successfully", savedPath, header.Filename, header.Size)
		},
	},
}

FileUploadBuiltins contains all file upload related built-in functions. These are only available in server mode.

View Source
var HttpBuiltins = map[string]*Builtin{

	"writeResp": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for writeResp. got=%d, want=2", len(args))
			}

			resp, ok := args[0].(*HttpResp)
			if !ok {
				return newError("first argument to 'writeResp' must be HTTP_RESP, got %s", args[0].Type())
			}

			var content string
			switch c := args[1].(type) {
			case *String:
				content = c.Value
			default:
				content = c.Inspect()
			}

			if resp.Value == nil {
				return newError("http response is nil")
			}

			_, err := resp.Value.Write([]byte(content))
			if err != nil {
				return newError("write response failed: %v", err)
			}
			resp.SetWritten()

			return NULL
		},
	},

	"setRespHeader": {
		Fn: func(args ...Object) Object {
			if len(args) != 3 {
				return newError("wrong number of arguments for setRespHeader. got=%d, want=3", len(args))
			}

			resp, ok := args[0].(*HttpResp)
			if !ok {
				return newError("first argument to 'setRespHeader' must be HTTP_RESP, got %s", args[0].Type())
			}

			key, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'setRespHeader' must be STRING, got %s", args[1].Type())
			}

			value, ok := args[2].(*String)
			if !ok {
				return newError("third argument to 'setRespHeader' must be STRING, got %s", args[2].Type())
			}

			if resp.Value == nil {
				return newError("http response is nil")
			}

			resp.Value.Header().Set(key.Value, value.Value)
			return NULL
		},
	},

	"addRespHeader": {
		Fn: func(args ...Object) Object {
			if len(args) != 3 {
				return newError("wrong number of arguments for addRespHeader. got=%d, want=3", len(args))
			}

			resp, ok := args[0].(*HttpResp)
			if !ok {
				return newError("first argument to 'addRespHeader' must be HTTP_RESP, got %s", args[0].Type())
			}

			key, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'addRespHeader' must be STRING, got %s", args[1].Type())
			}

			value, ok := args[2].(*String)
			if !ok {
				return newError("third argument to 'addRespHeader' must be STRING, got %s", args[2].Type())
			}

			if resp.Value == nil {
				return newError("http response is nil")
			}

			resp.Value.Header().Add(key.Value, value.Value)
			return NULL
		},
	},

	"getReqHeader": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for getReqHeader. got=%d, want=2", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("first argument to 'getReqHeader' must be HTTP_REQ, got %s", args[0].Type())
			}

			key, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'getReqHeader' must be STRING, got %s", args[1].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			value := req.Value.Header.Get(key.Value)
			return NewString(value)
		},
	},

	"getReqHeaders": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for getReqHeaders. got=%d, want=1", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("argument to 'getReqHeaders' must be HTTP_REQ, got %s", args[0].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			return req.getHeaders()
		},
	},

	"setCookie": {
		Fn: func(args ...Object) Object {
			if len(args) < 3 || len(args) > 4 {
				return newError("wrong number of arguments for setCookie. got=%d, want=3 or 4", len(args))
			}

			resp, ok := args[0].(*HttpResp)
			if !ok {
				return newError("first argument to 'setCookie' must be HTTP_RESP, got %s", args[0].Type())
			}

			name, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'setCookie' must be STRING, got %s", args[1].Type())
			}

			value, ok := args[2].(*String)
			if !ok {
				return newError("third argument to 'setCookie' must be STRING, got %s", args[2].Type())
			}

			if resp.Value == nil {
				return newError("http response is nil")
			}

			cookie := &http.Cookie{
				Name:  name.Value,
				Value: value.Value,
			}

			if len(args) == 4 {
				opts, ok := args[3].(*Map)
				if !ok {
					return newError("fourth argument to 'setCookie' must be MAP, got %s", args[3].Type())
				}

				for _, pair := range opts.Pairs {
					keyStr, ok := pair.Key.(*String)
					if !ok {
						continue
					}

					switch keyStr.Value {
					case "path":
						if v, ok := pair.Value.(*String); ok {
							cookie.Path = v.Value
						}
					case "domain":
						if v, ok := pair.Value.(*String); ok {
							cookie.Domain = v.Value
						}
					case "maxAge":
						if v, ok := pair.Value.(*Int); ok {
							cookie.MaxAge = int(v.Value)
						}
					case "secure":
						if v, ok := pair.Value.(*Bool); ok {
							cookie.Secure = v.Value
						}
					case "httpOnly":
						if v, ok := pair.Value.(*Bool); ok {
							cookie.HttpOnly = v.Value
						}
					case "sameSite":
						if v, ok := pair.Value.(*Int); ok {
							cookie.SameSite = http.SameSite(v.Value)
						}
					case "expires":
						if v, ok := pair.Value.(*String); ok {
							t, err := time.Parse(time.RFC3339, v.Value)
							if err == nil {
								cookie.Expires = t
							}
						}
					}
				}
			}

			http.SetCookie(resp.Value, cookie)
			return NULL
		},
	},

	"getCookie": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for getCookie. got=%d, want=2", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("first argument to 'getCookie' must be HTTP_REQ, got %s", args[0].Type())
			}

			name, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'getCookie' must be STRING, got %s", args[1].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			cookie, err := req.Value.Cookie(name.Value)
			if err != nil {
				return NULL
			}

			return NewString(cookie.Value)
		},
	},

	"getCookies": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for getCookies. got=%d, want=1", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("argument to 'getCookies' must be HTTP_REQ, got %s", args[0].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			pairs := make(map[HashKey]MapPair)
			for _, cookie := range req.Value.Cookies() {
				k := NewString(cookie.Name)
				pairs[k.HashKey()] = MapPair{Key: k, Value: NewString(cookie.Value)}
			}

			return NewMap(pairs)
		},
	},

	"parseForm": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for parseForm. got=%d, want=1", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("argument to 'parseForm' must be HTTP_REQ, got %s", args[0].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			if err := req.Value.ParseForm(); err != nil {
				return newError("parse form failed: %v", err)
			}

			pairs := make(map[HashKey]MapPair)

			for key, values := range req.Value.URL.Query() {
				k := NewString(key)
				var v Object
				if len(values) == 1 {
					v = NewString(values[0])
				} else {
					elements := make([]Object, len(values))
					for i, val := range values {
						elements[i] = NewString(val)
					}
					v = NewArray(elements)
				}
				pairs[k.HashKey()] = MapPair{Key: k, Value: v}
			}

			for key, values := range req.Value.PostForm {
				k := NewString(key)

				if existing, ok := pairs[k.HashKey()]; ok {
					if arr, ok := existing.Value.(*Array); ok {
						elements := arr.Elements
						for _, val := range values {
							elements = append(elements, NewString(val))
						}
						pairs[k.HashKey()] = MapPair{Key: k, Value: NewArray(elements)}
					} else {
						elements := []Object{existing.Value}
						for _, val := range values {
							elements = append(elements, NewString(val))
						}
						pairs[k.HashKey()] = MapPair{Key: k, Value: NewArray(elements)}
					}
				} else {
					var v Object
					if len(values) == 1 {
						v = NewString(values[0])
					} else {
						elements := make([]Object, len(values))
						for i, val := range values {
							elements[i] = NewString(val)
						}
						v = NewArray(elements)
					}
					pairs[k.HashKey()] = MapPair{Key: k, Value: v}
				}
			}

			return NewMap(pairs)
		},
	},

	"parseJSON": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for parseJSON. got=%d, want=1", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("argument to 'parseJSON' must be HTTP_REQ, got %s", args[0].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			body, err := io.ReadAll(req.Value.Body)
			if err != nil {
				return newError("read request body failed: %v", err)
			}

			var data interface{}
			if err := json.Unmarshal(body, &data); err != nil {
				return newError("parse JSON failed: %v", err)
			}

			return GoValueToObject(data)
		},
	},

	"getReqBody": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for getReqBody. got=%d, want=1", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("argument to 'getReqBody' must be HTTP_REQ, got %s", args[0].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			body, err := io.ReadAll(req.Value.Body)
			if err != nil {
				return newError("read request body failed: %v", err)
			}

			return NewString(string(body))
		},
	},

	"getReqBodyBytes": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for getReqBodyBytes. got=%d, want=1", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("argument to 'getReqBodyBytes' must be HTTP_REQ, got %s", args[0].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			body, err := io.ReadAll(req.Value.Body)
			if err != nil {
				return newError("read request body failed: %v", err)
			}

			elements := make([]Object, len(body))
			for i, b := range body {
				elements[i] = NewInt(int64(b))
			}
			return NewArray(elements)
		},
	},

	"status": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for status. got=%d, want=2", len(args))
			}

			resp, ok := args[0].(*HttpResp)
			if !ok {
				return newError("first argument to 'status' must be HTTP_RESP, got %s", args[0].Type())
			}

			code, ok := args[1].(*Int)
			if !ok {
				return newError("second argument to 'status' must be INT, got %s", args[1].Type())
			}

			if resp.Value == nil {
				return newError("http response is nil")
			}

			resp.Value.WriteHeader(int(code.Value))
			return NULL
		},
	},

	"redirect": {
		Fn: func(args ...Object) Object {
			if len(args) < 2 || len(args) > 3 {
				return newError("wrong number of arguments for redirect. got=%d, want=2 or 3", len(args))
			}

			resp, ok := args[0].(*HttpResp)
			if !ok {
				return newError("first argument to 'redirect' must be HTTP_RESP, got %s", args[0].Type())
			}

			url, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'redirect' must be STRING, got %s", args[1].Type())
			}

			code := 302
			if len(args) == 3 {
				c, ok := args[2].(*Int)
				if !ok {
					return newError("third argument to 'redirect' must be INT, got %s", args[2].Type())
				}
				code = int(c.Value)
			}

			if resp.Value == nil {
				return newError("http response is nil")
			}

			http.Redirect(resp.Value, &http.Request{}, url.Value, code)
			resp.SetWritten()
			return NULL
		},
	},

	"serveFile": {
		Fn: func(args ...Object) Object {
			if len(args) != 3 {
				return newError("wrong number of arguments for serveFile. got=%d, want=3", len(args))
			}

			resp, ok := args[0].(*HttpResp)
			if !ok {
				return newError("first argument to 'serveFile' must be HTTP_RESP, got %s", args[0].Type())
			}

			req, ok := args[1].(*HttpReq)
			if !ok {
				return newError("second argument to 'serveFile' must be HTTP_REQ, got %s", args[1].Type())
			}

			path, ok := args[2].(*String)
			if !ok {
				return newError("third argument to 'serveFile' must be STRING, got %s", args[2].Type())
			}

			if resp.Value == nil || req.Value == nil {
				return newError("http response or request is nil")
			}

			http.ServeFile(resp.Value, req.Value, path.Value)
			resp.SetWritten()
			return NULL
		},
	},

	"getMimeType": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for getMimeType. got=%d, want=1", len(args))
			}

			path, ok := args[0].(*String)
			if !ok {
				return newError("argument to 'getMimeType' must be STRING, got %s", args[0].Type())
			}

			ext := filepath.Ext(path.Value)
			mimeType := mime.TypeByExtension(ext)
			if mimeType == "" {
				mimeType = "application/octet-stream"
			}

			return NewString(mimeType)
		},
	},

	"setContentType": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for setContentType. got=%d, want=2", len(args))
			}

			resp, ok := args[0].(*HttpResp)
			if !ok {
				return newError("first argument to 'setContentType' must be HTTP_RESP, got %s", args[0].Type())
			}

			mimeType, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'setContentType' must be STRING, got %s", args[1].Type())
			}

			if resp.Value == nil {
				return newError("http response is nil")
			}

			resp.Value.Header().Set("Content-Type", mimeType.Value)
			return NULL
		},
	},

	"queryParam": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for queryParam. got=%d, want=2", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("first argument to 'queryParam' must be HTTP_REQ, got %s", args[0].Type())
			}

			name, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'queryParam' must be STRING, got %s", args[1].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			value := req.Value.URL.Query().Get(name.Value)
			return NewString(value)
		},
	},

	"queryParams": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for queryParams. got=%d, want=1", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("argument to 'queryParams' must be HTTP_REQ, got %s", args[0].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			pairs := make(map[HashKey]MapPair)
			for key, values := range req.Value.URL.Query() {
				k := NewString(key)
				var v Object
				if len(values) == 1 {
					v = NewString(values[0])
				} else {
					elements := make([]Object, len(values))
					for i, val := range values {
						elements[i] = NewString(val)
					}
					v = NewArray(elements)
				}
				pairs[k.HashKey()] = MapPair{Key: k, Value: v}
			}

			return NewMap(pairs)
		},
	},

	"formValue": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for formValue. got=%d, want=2", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("first argument to 'formValue' must be HTTP_REQ, got %s", args[0].Type())
			}

			name, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'formValue' must be STRING, got %s", args[1].Type())
			}

			if req.Value == nil {
				return newError("http request is nil")
			}

			value := req.Value.FormValue(name.Value)
			return NewString(value)
		},
	},

	"webSocket": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for webSocket. got=%d, want=2", len(args))
			}

			req, ok := args[0].(*HttpReq)
			if !ok {
				return newError("first argument to 'webSocket' must be HTTP_REQ, got %s", args[0].Type())
			}

			resp, ok := args[1].(*HttpResp)
			if !ok {
				return newError("second argument to 'webSocket' must be HTTP_RESP, got %s", args[1].Type())
			}

			if req.Value == nil || resp.Value == nil {
				return newError("http request or response is nil")
			}

			conn, err := websocketUpgrader.Upgrade(resp.Value, req.Value, nil)
			if err != nil {
				return newError("websocket upgrade failed: %v", err)
			}

			return NewWebSocket(conn)
		},
	},

	"wsReadMsg": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for wsReadMsg. got=%d, want=1", len(args))
			}

			ws, ok := args[0].(*WebSocket)
			if !ok {
				return newError("argument to 'wsReadMsg' must be WEBSOCKET, got %s", args[0].Type())
			}

			return ws.ReadMessage()
		},
	},

	"wsSendText": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for wsSendText. got=%d, want=2", len(args))
			}

			ws, ok := args[0].(*WebSocket)
			if !ok {
				return newError("first argument to 'wsSendText' must be WEBSOCKET, got %s", args[0].Type())
			}

			text, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'wsSendText' must be STRING, got %s", args[1].Type())
			}

			return ws.SendTextMessage(text.Value)
		},
	},

	"wsSendBinary": {
		Fn: func(args ...Object) Object {
			if len(args) != 2 {
				return newError("wrong number of arguments for wsSendBinary. got=%d, want=2", len(args))
			}

			ws, ok := args[0].(*WebSocket)
			if !ok {
				return newError("first argument to 'wsSendBinary' must be WEBSOCKET, got %s", args[0].Type())
			}

			data, ok := args[1].(*String)
			if !ok {
				return newError("second argument to 'wsSendBinary' must be STRING, got %s", args[1].Type())
			}

			return ws.SendBinaryMessage(data.Value)
		},
	},

	"wsSendClose": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for wsSendClose. got=%d, want=1", len(args))
			}

			ws, ok := args[0].(*WebSocket)
			if !ok {
				return newError("argument to 'wsSendClose' must be WEBSOCKET, got %s", args[0].Type())
			}

			return ws.SendCloseMessage()
		},
	},

	"wsClose": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for wsClose. got=%d, want=1", len(args))
			}

			ws, ok := args[0].(*WebSocket)
			if !ok {
				return newError("argument to 'wsClose' must be WEBSOCKET, got %s", args[0].Type())
			}

			return ws.Close()
		},
	},

	"isWebSocket": {
		Fn: func(args ...Object) Object {
			if len(args) != 1 {
				return newError("wrong number of arguments for isWebSocket. got=%d, want=1", len(args))
			}
			_, ok := args[0].(*WebSocket)
			return &Bool{Value: ok}
		},
	},
}

HttpBuiltins contains all HTTP-related built-in functions. These are only available in server mode.

View Source
var NULL = &Null{}

NULL is the singleton null value

View Source
var TypeMethods = map[ObjectType]map[string]*Builtin{
	IntType:           intMethods,
	FloatType:         floatMethods,
	BigIntType:        bigIntMethods,
	BigFloatType:      bigFloatMethods,
	StringType:        stringMethods,
	CharsType:         charsMethods,
	ArrayType:         arrayMethods,
	MapType:           mapMethods,
	BoolType:          boolMethods,
	NullType:          nullMethods,
	StringBuilderType: stringBuilderMethods,
	BytesType:         bytesMethods,
	BytesBufferType:   bytesBufferMethods,
	WebSocketType:     webSocketMethods,

	MutexType:     mutexMethods,
	RWMutexType:   rwMutexMethods,
	WaitGroupType: waitGroupMethods,
	AtomicIntType: atomicIntMethods,
	TubeType:      tubeMethods,
	OnceType:      onceMethods,
	CondType:      condMethods,
	ContextType:   contextMethods,

	FileUploadType:       fileUploadMethods,
	FileUploadResultType: fileUploadResultMethods,

	FileType:     fileMethods,
	FileInfoType: fileInfoMethods,

	ReaderType:  readerMethods,
	WriterType:  writerMethods,
	ScannerType: scannerMethods,

	OrderedMapType: orderedMapMethods,

	QueueType: queueMethods,
	SetType:   setMethods,

	XLSXType: xlsxMethods,

	PPTXDocumentType:  pptxDocumentMethods,
	PPTXSlideType:     pptxSlideMethods,
	PPTXTextFrameType: pptxTextFrameMethods,
	PPTXTextRunType:   pptxTextRunMethods,
	PPTXShapeType:     pptxShapeMethods,
	PPTXTableType:     pptxTableMethods,
	PPTXChartType:     pptxChartMethods,
	PPTXImageType:     pptxImageMethods,

	XMLDocumentType: xmlDocumentMethods,
	XMLNodeType:     xmlNodeMethods,
}

TypeMethods maps ObjectType -> methodName -> *Builtin

Functions

func ClearInternCache added in v0.4.23

func ClearInternCache()

ClearInternCache clears the string intern cache Use with caution - this will cause all interned strings to be re-allocated

func ColToIndex added in v0.5.2

func ColToIndex(col string) int

ColToIndex converts column letter to index (A=1).

func EncodeToXML added in v0.5.4

func EncodeToXML(obj Object, rootName string) (string, error)

EncodeToXML converts an Object to XML string.

func ErrIndexOutOfRange added in v0.5.7

func ErrIndexOutOfRange(index, length int) error

ErrIndexOutOfRange creates an error for an out of range index

func ErrKeyNotFound added in v0.5.7

func ErrKeyNotFound(key Object) error

ErrKeyNotFound creates an error for a missing key

func EscapeXMLAttr added in v0.5.4

func EscapeXMLAttr(s string) string

EscapeXMLAttr escapes special characters for XML attributes.

func EscapeXMLText added in v0.5.4

func EscapeXMLText(s string) string

EscapeXMLText escapes special characters for XML text.

func FormatBigFloat added in v0.4.25

func FormatBigFloat(b *BigFloat) string

FormatBigFloat formats a BigFloat value for display with the 'm' suffix

func FormatBigInt added in v0.4.25

func FormatBigInt(b *BigInt) string

FormatBigInt formats a BigInt value for display with the 'n' suffix

func IndexToCol added in v0.5.2

func IndexToCol(index int) string

IndexToCol converts index to column letter.

func IsCachedInt added in v0.4.23

func IsCachedInt(val int64) bool

IsCachedInt returns true if the given value is within the cached range

func IsTruthy

func IsTruthy(obj Object) bool

IsTruthy checks if an object is truthy

func NewBytesReader added in v0.4.25

func NewBytesReader(data []byte) io.Reader

NewBytesReader creates an io.Reader from a byte slice. This is useful for creating a Reader from byte array data.

func NewStringReader added in v0.4.25

func NewStringReader(s string) io.Reader

NewStringReader creates an io.Reader from a string. This is useful for creating a Reader from a string value.

func ObjectToGoValue added in v0.4.25

func ObjectToGoValue(obj Object) (interface{}, error)

ObjectToGoValue converts an Xxlang Object to a Go value suitable for JSON marshaling. Returns nil for null, and returns an error for types that cannot be serialized.

func ObjectToJSON added in v0.4.25

func ObjectToJSON(obj Object, opts ObjectToJSONOptions) ([]byte, error)

ObjectToJSON converts an Object to JSON bytes with the given options. This is the primary function for JSON serialization in Xxlang.

func ParseCellRef added in v0.5.2

func ParseCellRef(ref string) (col string, row int)

ParseCellRef parses a cell reference.

func ParseMultipartForm added in v0.4.25

func ParseMultipartForm(req *http.Request, maxMemory int64) (map[string][]string, map[string][]*FileUpload, error)

ParseMultipartForm parses a multipart form from an HTTP request. It returns a map of form values and a map of file uploads.

func PutBufferedFloat added in v0.4.23

func PutBufferedFloat(obj *Float)

PutBufferedFloat returns a temporary Float to the global buffer

func PutBufferedInt added in v0.4.23

func PutBufferedInt(obj *Int)

PutBufferedInt returns a temporary Int to the global buffer

func PutBufferedString added in v0.4.23

func PutBufferedString(obj *String)

PutBufferedString returns a temporary String to the global buffer

func RegisterFileUploadBuiltins added in v0.4.25

func RegisterFileUploadBuiltins()

RegisterFileUploadBuiltins registers file upload built-in functions into the main Builtins map.

func RegisterHttpBuiltins added in v0.4.25

func RegisterHttpBuiltins()

RegisterHttpBuiltins registers HTTP built-in functions into the main Builtins map.

func ReleaseArray added in v0.4.23

func ReleaseArray(obj *Array)

ReleaseArray returns an Array object to the pool

func ReleaseArraySlice added in v0.4.23

func ReleaseArraySlice(objs []*Array)

ReleaseArraySlice returns multiple Array objects to the pool

func ReleaseFloat added in v0.4.23

func ReleaseFloat(obj *Float)

ReleaseFloat returns a Float object to the pool if it's not a cached value This should be called when the object is no longer needed

func ReleaseFloatSlice added in v0.4.23

func ReleaseFloatSlice(objs []*Float)

ReleaseFloatSlice returns multiple Float objects to the pool This is more efficient than calling ReleaseFloat multiple times

func ReleaseInt added in v0.4.23

func ReleaseInt(obj *Int)

ReleaseInt returns an Int object to the pool if it's outside the cache range This should be called when the object is no longer needed

func ReleaseIntSlice added in v0.4.23

func ReleaseIntSlice(objs []*Int)

ReleaseIntSlice returns multiple Int objects to the pool This is more efficient than calling ReleaseInt multiple times

func ReleaseMap added in v0.4.23

func ReleaseMap(obj *Map)

ReleaseMap returns a Map object to the pool

func ReleaseMapSlice added in v0.4.23

func ReleaseMapSlice(objs []*Map)

ReleaseMapSlice returns multiple Map objects to the pool

func ReleaseOrderedMap added in v0.5.7

func ReleaseOrderedMap(om *OrderedMap)

ReleaseOrderedMap returns an OrderedMap to the pool

func ReleaseString added in v0.4.23

func ReleaseString(obj *String)

ReleaseString returns a String object to the pool if it's not a cached value This should be called when the object is no longer needed

func ReleaseStringSlice added in v0.4.23

func ReleaseStringSlice(objs []*String)

ReleaseStringSlice returns multiple String objects to the pool This is more efficient than calling ReleaseString multiple times

func ResetArrayPoolStats added in v0.4.23

func ResetArrayPoolStats()

ResetArrayPoolStats resets the pool statistics counters

func ResetFloatPoolStats added in v0.4.23

func ResetFloatPoolStats()

ResetFloatPoolStats resets the pool statistics counters

func ResetGlobalReader added in v0.4.25

func ResetGlobalReader()

ResetGlobalReader resets the global reader for stdin. This is useful for testing or when stdin needs to be reinitialized.

func ResetIntPoolStats added in v0.4.23

func ResetIntPoolStats()

ResetIntPoolStats resets the pool statistics counters

func ResetMapPoolStats added in v0.4.23

func ResetMapPoolStats()

ResetMapPoolStats resets the pool statistics counters

func ResetStringPoolStats added in v0.4.23

func ResetStringPoolStats()

ResetStringPoolStats resets the pool statistics counters

func SafePath added in v0.4.25

func SafePath(baseDir, filename string) (string, error)

SafePath validates and returns a safe file path. It prevents directory traversal attacks by checking for ".." and ensuring the path is within the allowed directory.

func Scan2 added in v0.4.25

func Scan2() (Object, Object)

Scan2 reads two whitespace-delimited tokens from stdin.

func Scan3 added in v0.4.25

func Scan3() (Object, Object, Object)

Scan3 reads three whitespace-delimited tokens from stdin.

func ScanRow added in v0.4.36

func ScanRow(rows *sql.Rows, columns []string) (map[string]interface{}, error)

ScanRow scans a single row into a map. This is a helper function used by the db module.

func SetCallUserFuncImpl added in v0.4.25

func SetCallUserFuncImpl(fn func(fnObj Object, args ...Object) (Object, error)) func(Object, ...Object) (Object, error)

SetCallUserFuncImpl registers the callback for calling user functions and returns the previous value

func SetDelegateImpl added in v0.4.25

func SetDelegateImpl(fn func(source string) (Object, error)) func(source string) (Object, error)

SetDelegateImpl registers the delegate implementation and returns the previous value

func SetLoadPluginImpl added in v0.4.19

func SetLoadPluginImpl(fn func(path string) (Object, error)) func(path string) (Object, error)

SetLoadPluginImpl registers the loadPlugin implementation and returns the previous value

func SetRunCodeImpl added in v0.4.19

func SetRunCodeImpl(fn func(code string, args *Map) (Object, error)) func(code string, args *Map) (Object, error)

SetRunCodeImpl registers the runCode implementation and returns the previous value

func WarmArrayPool added in v0.4.23

func WarmArrayPool(count int)

WarmArrayPool pre-allocates Array objects into the pool

func WarmFloatPool added in v0.4.23

func WarmFloatPool(count int)

WarmFloatPool pre-allocates a number of Float objects into the pool This can improve performance by reducing allocations during hot paths

func WarmIntPool added in v0.4.23

func WarmIntPool(count int)

WarmIntPool pre-allocates a number of Int objects into the pool This can improve performance by reducing allocations during hot paths

func WarmMapPool added in v0.4.23

func WarmMapPool(count int)

WarmMapPool pre-allocates Map objects into the pool

func WarmStringPool added in v0.4.23

func WarmStringPool(count int)

WarmStringPool pre-allocates a number of String objects into the pool This can improve performance by reducing allocations during hot paths

Types

type Array

type Array struct {
	Elements   []Object
	LastPopped Object // Used by pop() to return the popped value
}

Array represents an array value

func NewArray added in v0.4.23

func NewArray(elements []Object) *Array

NewArray creates a new Array object with the given elements

func NewArrayWithCapacity added in v0.4.23

func NewArrayWithCapacity(capacity int) *Array

NewArrayWithCapacity creates a new Array with pre-allocated capacity

func (*Array) HashKey

func (a *Array) HashKey() HashKey

HashKey returns the hash key for map operations

func (*Array) Inspect

func (a *Array) Inspect() string

Inspect returns the string representation

func (*Array) ToBool

func (a *Array) ToBool() *Bool

ToBool converts the array to a boolean

func (*Array) Type

func (a *Array) Type() ObjectType

Type returns the object type

func (*Array) TypeTag

func (a *Array) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type ArrayPoolStats added in v0.4.23

type ArrayPoolStats struct {
	CacheHits int64
	PoolHits  int64
	Created   int64
	Released  int64
}

ArrayPoolStats tracks statistics about array pool usage

func GetArrayPoolStats added in v0.4.23

func GetArrayPoolStats() ArrayPoolStats

GetArrayPoolStats returns current statistics about array pool usage

type AtomicInt added in v0.4.25

type AtomicInt struct {
	// contains filtered or unexported fields
}

AtomicInt provides atomic operations on an integer

func NewAtomicInt added in v0.4.25

func NewAtomicInt(initial int64) *AtomicInt

NewAtomicInt creates a new AtomicInt with the given initial value

func (*AtomicInt) Add added in v0.4.25

func (a *AtomicInt) Add(delta int64) int64

Add atomically adds delta to the value and returns the new value

func (*AtomicInt) CompareAndSwap added in v0.4.25

func (a *AtomicInt) CompareAndSwap(old, new int64) bool

CompareAndSwap atomically compares and swaps Returns true if the swap was successful

func (*AtomicInt) HashKey added in v0.4.25

func (a *AtomicInt) HashKey() HashKey

func (*AtomicInt) Inspect added in v0.4.25

func (a *AtomicInt) Inspect() string

func (*AtomicInt) Load added in v0.4.25

func (a *AtomicInt) Load() int64

Load atomically loads and returns the value

func (*AtomicInt) Store added in v0.4.25

func (a *AtomicInt) Store(val int64)

Store atomically stores the value

func (*AtomicInt) Swap added in v0.4.25

func (a *AtomicInt) Swap(new int64) int64

Swap atomically swaps the value and returns the old value

func (*AtomicInt) ToBool added in v0.4.25

func (a *AtomicInt) ToBool() *Bool

func (*AtomicInt) Type added in v0.4.25

func (a *AtomicInt) Type() ObjectType

Object interface implementation

func (*AtomicInt) TypeTag added in v0.4.25

func (a *AtomicInt) TypeTag() TypeTag

type BigFloat added in v0.4.25

type BigFloat struct {
	Value *big.Float
}

BigFloat represents an arbitrary-precision floating-point value It wraps Go's math/big.Float for unlimited precision floating-point arithmetic

func NewBigFloat added in v0.4.25

func NewBigFloat(val *big.Float) *BigFloat

NewBigFloat creates a new BigFloat from a big.Float

func NewBigFloatFromBigInt added in v0.4.25

func NewBigFloatFromBigInt(b *BigInt) *BigFloat

NewBigFloatFromBigInt creates a new BigFloat from a BigInt object

func NewBigFloatFromFloat64 added in v0.4.25

func NewBigFloatFromFloat64(f float64) *BigFloat

NewBigFloatFromFloat64 creates a new BigFloat from a float64

func NewBigFloatFromInt added in v0.4.25

func NewBigFloatFromInt(i *Int) *BigFloat

NewBigFloatFromInt creates a new BigFloat from an Int object

func NewBigFloatFromInt64 added in v0.4.25

func NewBigFloatFromInt64(n int64) *BigFloat

NewBigFloatFromInt64 creates a new BigFloat from an int64

func NewBigFloatFromString added in v0.4.25

func NewBigFloatFromString(s string) (*BigFloat, error)

NewBigFloatFromString creates a new BigFloat from a string representation

func (*BigFloat) Abs added in v0.4.25

func (b *BigFloat) Abs() *BigFloat

Abs returns a new BigFloat that is the absolute value of b

func (*BigFloat) Add added in v0.4.25

func (b *BigFloat) Add(other *BigFloat) *BigFloat

Add returns a new BigFloat that is the sum of b and other

func (*BigFloat) AddFloat64 added in v0.4.25

func (b *BigFloat) AddFloat64(f float64) *BigFloat

AddFloat64 returns a new BigFloat that is the sum of b and a float64

func (*BigFloat) Ceil added in v0.4.25

func (b *BigFloat) Ceil() *BigFloat

Ceil returns the least integer value greater than or equal to b

func (*BigFloat) Clone added in v0.4.25

func (b *BigFloat) Clone() *BigFloat

Clone creates a copy of the BigFloat

func (*BigFloat) Cmp added in v0.4.25

func (b *BigFloat) Cmp(other *BigFloat) int

Cmp compares two BigFloat values Returns -1 if b < other, 0 if b == other, 1 if b > other

func (*BigFloat) Div added in v0.4.25

func (b *BigFloat) Div(other *BigFloat) *BigFloat

Div returns a new BigFloat that is b divided by other Returns nil if other is zero

func (*BigFloat) DivFloat64 added in v0.4.25

func (b *BigFloat) DivFloat64(f float64) *BigFloat

DivFloat64 returns a new BigFloat that is b divided by a float64 Returns nil if f is zero

func (*BigFloat) Floor added in v0.4.25

func (b *BigFloat) Floor() *BigFloat

Floor returns the greatest integer value less than or equal to b

func (*BigFloat) HashKey added in v0.4.25

func (b *BigFloat) HashKey() HashKey

HashKey returns the hash key for map operations

func (*BigFloat) Inspect added in v0.4.25

func (b *BigFloat) Inspect() string

Inspect returns the string representation (without the 'm' suffix)

func (*BigFloat) IsNegative added in v0.4.25

func (b *BigFloat) IsNegative() bool

IsNegative returns true if the BigFloat is negative

func (*BigFloat) IsPositive added in v0.4.25

func (b *BigFloat) IsPositive() bool

IsPositive returns true if the BigFloat is positive

func (*BigFloat) IsZero added in v0.4.25

func (b *BigFloat) IsZero() bool

IsZero returns true if the BigFloat is zero

func (*BigFloat) Mul added in v0.4.25

func (b *BigFloat) Mul(other *BigFloat) *BigFloat

Mul returns a new BigFloat that is b multiplied by other

func (*BigFloat) MulFloat64 added in v0.4.25

func (b *BigFloat) MulFloat64(f float64) *BigFloat

MulFloat64 returns a new BigFloat that is b multiplied by a float64

func (*BigFloat) Neg added in v0.4.25

func (b *BigFloat) Neg() *BigFloat

Neg returns a new BigFloat that is the negation of b

func (*BigFloat) Precision added in v0.4.25

func (b *BigFloat) Precision() uint

Precision returns the precision of the BigFloat in bits

func (*BigFloat) Round added in v0.4.25

func (b *BigFloat) Round() *BigFloat

Round returns the nearest integer value to b

func (*BigFloat) SetPrecision added in v0.4.25

func (b *BigFloat) SetPrecision(prec uint) *BigFloat

SetPrecision returns a new BigFloat with the specified precision

func (*BigFloat) Sign added in v0.4.25

func (b *BigFloat) Sign() int

Sign returns the sign of the BigFloat Returns -1 for negative, 0 for zero, 1 for positive

func (*BigFloat) String added in v0.4.25

func (b *BigFloat) String() string

String returns the string representation

func (*BigFloat) Sub added in v0.4.25

func (b *BigFloat) Sub(other *BigFloat) *BigFloat

Sub returns a new BigFloat that is b minus other

func (*BigFloat) SubFloat64 added in v0.4.25

func (b *BigFloat) SubFloat64(f float64) *BigFloat

SubFloat64 returns a new BigFloat that is b minus a float64

func (*BigFloat) ToBigInt added in v0.4.25

func (b *BigFloat) ToBigInt() *BigInt

ToBigInt converts the BigFloat to a BigInt (truncates toward zero)

func (*BigFloat) ToBool added in v0.4.25

func (b *BigFloat) ToBool() *Bool

ToBool converts the BigFloat to a boolean

func (*BigFloat) ToFloat64 added in v0.4.25

func (b *BigFloat) ToFloat64() (float64, big.Accuracy)

ToFloat64 converts the BigFloat to float64 May lose precision for very large or high-precision values

func (*BigFloat) ToInt64 added in v0.4.25

func (b *BigFloat) ToInt64() (int64, bool)

ToInt64 converts the BigFloat to int64 (truncates toward zero) Returns false if the value overflows int64

func (*BigFloat) Type added in v0.4.25

func (b *BigFloat) Type() ObjectType

Type returns the object type

func (*BigFloat) TypeTag added in v0.4.25

func (b *BigFloat) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type BigInt added in v0.4.25

type BigInt struct {
	Value *big.Int
}

BigInt represents an arbitrary-precision integer value It wraps Go's math/big.Int for unlimited precision integer arithmetic

func NewBigInt added in v0.4.25

func NewBigInt(val *big.Int) *BigInt

NewBigInt creates a new BigInt from a big.Int

func NewBigIntFromInt added in v0.4.25

func NewBigIntFromInt(i *Int) *BigInt

NewBigIntFromInt creates a new BigInt from an Int object

func NewBigIntFromInt64 added in v0.4.25

func NewBigIntFromInt64(n int64) *BigInt

NewBigIntFromInt64 creates a new BigInt from an int64

func NewBigIntFromString added in v0.4.25

func NewBigIntFromString(s string) (*BigInt, error)

NewBigIntFromString creates a new BigInt from a string representation The string can be in decimal, hex (0x prefix), octal (0 prefix), or binary (0b prefix)

func (*BigInt) Abs added in v0.4.25

func (b *BigInt) Abs() *BigInt

Abs returns a new BigInt that is the absolute value of b

func (*BigInt) Add added in v0.4.25

func (b *BigInt) Add(other *BigInt) *BigInt

Add returns a new BigInt that is the sum of b and other

func (*BigInt) AddInt added in v0.4.25

func (b *BigInt) AddInt(n int64) *BigInt

AddInt returns a new BigInt that is the sum of b and an int64

func (*BigInt) BitLen added in v0.4.25

func (b *BigInt) BitLen() int

BitLen returns the length of the absolute value in bits

func (*BigInt) Clone added in v0.4.25

func (b *BigInt) Clone() *BigInt

Clone creates a copy of the BigInt

func (*BigInt) Cmp added in v0.4.25

func (b *BigInt) Cmp(other *BigInt) int

Cmp compares two BigInt values Returns -1 if b < other, 0 if b == other, 1 if b > other

func (*BigInt) Div added in v0.4.25

func (b *BigInt) Div(other *BigInt) *BigInt

Div returns a new BigInt that is b divided by other Returns nil if other is zero

func (*BigInt) DivInt added in v0.4.25

func (b *BigInt) DivInt(n int64) *BigInt

DivInt returns a new BigInt that is b divided by an int64 Returns nil if n is zero

func (*BigInt) HashKey added in v0.4.25

func (b *BigInt) HashKey() HashKey

HashKey returns the hash key for map operations

func (*BigInt) Inspect added in v0.4.25

func (b *BigInt) Inspect() string

Inspect returns the string representation (without the 'n' suffix)

func (*BigInt) IsNegative added in v0.4.25

func (b *BigInt) IsNegative() bool

IsNegative returns true if the BigInt is negative

func (*BigInt) IsPositive added in v0.4.25

func (b *BigInt) IsPositive() bool

IsPositive returns true if the BigInt is positive

func (*BigInt) IsZero added in v0.4.25

func (b *BigInt) IsZero() bool

IsZero returns true if the BigInt is zero

func (*BigInt) Mod added in v0.4.25

func (b *BigInt) Mod(other *BigInt) *BigInt

Mod returns a new BigInt that is b mod other Returns nil if other is zero

func (*BigInt) ModInt added in v0.4.25

func (b *BigInt) ModInt(n int64) *BigInt

ModInt returns a new BigInt that is b mod an int64 Returns nil if n is zero

func (*BigInt) Mul added in v0.4.25

func (b *BigInt) Mul(other *BigInt) *BigInt

Mul returns a new BigInt that is b multiplied by other

func (*BigInt) MulInt added in v0.4.25

func (b *BigInt) MulInt(n int64) *BigInt

MulInt returns a new BigInt that is b multiplied by an int64

func (*BigInt) Neg added in v0.4.25

func (b *BigInt) Neg() *BigInt

Neg returns a new BigInt that is the negation of b

func (*BigInt) Sign added in v0.4.25

func (b *BigInt) Sign() int

Sign returns the sign of the BigInt Returns -1 for negative, 0 for zero, 1 for positive

func (*BigInt) String added in v0.4.25

func (b *BigInt) String() string

String returns the string representation

func (*BigInt) Sub added in v0.4.25

func (b *BigInt) Sub(other *BigInt) *BigInt

Sub returns a new BigInt that is b minus other

func (*BigInt) SubInt added in v0.4.25

func (b *BigInt) SubInt(n int64) *BigInt

SubInt returns a new BigInt that is b minus an int64

func (*BigInt) ToBigFloat added in v0.4.25

func (b *BigInt) ToBigFloat() *BigFloat

ToBigFloat converts the BigInt to a BigFloat

func (*BigInt) ToBool added in v0.4.25

func (b *BigInt) ToBool() *Bool

ToBool converts the BigInt to a boolean

func (*BigInt) ToFloat64 added in v0.4.25

func (b *BigInt) ToFloat64() float64

ToFloat64 converts the BigInt to float64 May lose precision for very large values

func (*BigInt) ToInt64 added in v0.4.25

func (b *BigInt) ToInt64() (int64, bool)

ToInt64 converts the BigInt to int64 Returns false if the value overflows int64

func (*BigInt) Type added in v0.4.25

func (b *BigInt) Type() ObjectType

Type returns the object type

func (*BigInt) TypeTag added in v0.4.25

func (b *BigInt) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type Bool

type Bool struct {
	Value bool
}

Bool represents a boolean value

func (*Bool) HashKey

func (b *Bool) HashKey() HashKey

func (*Bool) Inspect

func (b *Bool) Inspect() string

func (*Bool) ToBool

func (b *Bool) ToBool() *Bool

func (*Bool) Type

func (b *Bool) Type() ObjectType

func (*Bool) TypeTag

func (b *Bool) TypeTag() TypeTag

type Builtin

type Builtin struct {
	Fn BuiltinFunction
}

Builtin represents a built-in function

func GetMethod

func GetMethod(objType ObjectType, name string) (*Builtin, bool)

GetMethod returns the builtin method for the given object type and method name

func (*Builtin) HashKey

func (b *Builtin) HashKey() HashKey

func (*Builtin) Inspect

func (b *Builtin) Inspect() string

func (*Builtin) ToBool

func (b *Builtin) ToBool() *Bool

func (*Builtin) Type

func (b *Builtin) Type() ObjectType

func (*Builtin) TypeTag

func (b *Builtin) TypeTag() TypeTag

type BuiltinFunction

type BuiltinFunction func(args ...Object) Object

BuiltinFunction is the type for built-in functions

type Bytes added in v0.4.25

type Bytes struct {
	Value []byte
}

Bytes represents an immutable sequence of bytes. Unlike BytesBuffer which is mutable, Bytes is read-only after creation.

func NewBytes added in v0.4.25

func NewBytes(data []byte) *Bytes

NewBytes creates a new Bytes object from a byte slice. The byte slice is copied to ensure immutability.

func NewBytesFromArray added in v0.4.25

func NewBytesFromArray(elements []Object) *Bytes

NewBytesFromArray creates a new Bytes object from an integer array. Each integer must be in range 0-255.

func (*Bytes) At added in v0.4.25

func (b *Bytes) At(index int) (int64, bool)

At returns the byte value at the given index.

func (*Bytes) Concat added in v0.4.25

func (b *Bytes) Concat(others ...*Bytes) *Bytes

Concat concatenates multiple Bytes objects.

func (*Bytes) Contains added in v0.4.25

func (b *Bytes) Contains(sub *Bytes) bool

Contains checks if the bytes contain the given subsequence.

func (*Bytes) Count added in v0.4.25

func (b *Bytes) Count(sub *Bytes) int

Count counts the number of non-overlapping instances of sub.

func (*Bytes) Equal added in v0.4.25

func (b *Bytes) Equal(other *Bytes) bool

Equal checks if two Bytes objects are equal.

func (*Bytes) GetIOReader added in v0.4.25

func (b *Bytes) GetIOReader() io.Reader

GetIOReader returns an io.Reader for the bytes. This allows Bytes to be used with Reader objects.

func (*Bytes) GetMember added in v0.4.25

func (b *Bytes) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*Bytes) HasPrefix added in v0.4.25

func (b *Bytes) HasPrefix(prefix *Bytes) bool

HasPrefix checks if the bytes start with the given prefix.

func (*Bytes) HasSuffix added in v0.4.25

func (b *Bytes) HasSuffix(suffix *Bytes) bool

HasSuffix checks if the bytes end with the given suffix.

func (*Bytes) HashKey added in v0.4.25

func (b *Bytes) HashKey() HashKey

HashKey returns a hash key for the Bytes.

func (*Bytes) Index added in v0.4.25

func (b *Bytes) Index(sub *Bytes) int

Index returns the index of the first occurrence of sub. Returns -1 if not found.

func (*Bytes) Inspect added in v0.4.25

func (b *Bytes) Inspect() string

Inspect returns a string representation of the Bytes.

func (*Bytes) LastIndex added in v0.4.25

func (b *Bytes) LastIndex(sub *Bytes) int

LastIndex returns the index of the last occurrence of sub. Returns -1 if not found.

func (*Bytes) Len added in v0.4.25

func (b *Bytes) Len() int

Len returns the number of bytes.

func (*Bytes) Repeat added in v0.4.25

func (b *Bytes) Repeat(n int) *Bytes

Repeat returns a new Bytes with the content repeated n times.

func (*Bytes) Slice added in v0.4.25

func (b *Bytes) Slice(start, end int) *Bytes

Slice returns a new Bytes from start to end index.

func (*Bytes) String added in v0.4.25

func (b *Bytes) String() string

String returns the bytes as a string (UTF-8 interpretation).

func (*Bytes) ToArray added in v0.4.25

func (b *Bytes) ToArray() *Array

ToArray converts the bytes to an array of integers.

func (*Bytes) ToBool added in v0.4.25

func (b *Bytes) ToBool() *Bool

ToBool converts the Bytes to a boolean (true if non-empty).

func (*Bytes) Type added in v0.4.25

func (b *Bytes) Type() ObjectType

Type returns the object type.

func (*Bytes) TypeTag added in v0.4.25

func (b *Bytes) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type BytesBuffer added in v0.4.25

type BytesBuffer struct {
	// contains filtered or unexported fields
}

BytesBuffer is a mutable buffer for efficient byte operations. Not thread-safe - use external synchronization if needed.

func NewBytesBuffer added in v0.4.25

func NewBytesBuffer() *BytesBuffer

NewBytesBuffer creates a new BytesBuffer instance.

func NewBytesBufferFromBytes added in v0.4.25

func NewBytesBufferFromBytes(data []byte) *BytesBuffer

NewBytesBufferFromBytes creates a new BytesBuffer from an existing byte slice.

func (*BytesBuffer) Bytes added in v0.4.25

func (bb *BytesBuffer) Bytes() []byte

Bytes returns a copy of the buffer contents as a byte slice.

func (*BytesBuffer) BytesRef added in v0.4.25

func (bb *BytesBuffer) BytesRef() []byte

BytesRef returns a reference to the underlying byte slice (no copy). WARNING: The returned slice may be modified by subsequent buffer operations.

func (*BytesBuffer) Cap added in v0.4.25

func (bb *BytesBuffer) Cap() int

Cap returns the current capacity of the buffer.

func (*BytesBuffer) Clear added in v0.4.25

func (bb *BytesBuffer) Clear()

Clear resets the buffer, removing all content.

func (*BytesBuffer) Equals added in v0.4.25

func (bb *BytesBuffer) Equals(other *BytesBuffer) bool

Equals compares two BytesBuffer contents.

func (*BytesBuffer) GetIOReader added in v0.4.25

func (bb *BytesBuffer) GetIOReader() *bytesBufferReader

GetIOReader returns the buffer as an io.Reader interface. This allows the BytesBuffer to be used with Reader objects.

func (*BytesBuffer) GetIOWriter added in v0.4.25

func (bb *BytesBuffer) GetIOWriter() *bytesBufferWriter

GetIOWriter returns the buffer as an io.Writer interface. This allows the BytesBuffer to be used with Writer objects.

func (*BytesBuffer) Grow added in v0.4.25

func (bb *BytesBuffer) Grow(n int)

Grow grows the buffer's capacity to hold at least n more bytes.

func (*BytesBuffer) HashKey added in v0.4.25

func (bb *BytesBuffer) HashKey() HashKey

HashKey returns a hash key for the BytesBuffer.

func (*BytesBuffer) Inspect added in v0.4.25

func (bb *BytesBuffer) Inspect() string

Inspect returns a string representation.

func (*BytesBuffer) Len added in v0.4.25

func (bb *BytesBuffer) Len() int

Len returns the current length of the buffer.

func (*BytesBuffer) Peek added in v0.4.25

func (bb *BytesBuffer) Peek(n int) []byte

Peek returns the next n bytes without advancing the reader.

func (*BytesBuffer) Read added in v0.4.25

func (bb *BytesBuffer) Read(p []byte) (int, error)

Read reads up to len(p) bytes from the buffer into p. Returns the number of bytes read.

func (*BytesBuffer) ReadByte added in v0.4.25

func (bb *BytesBuffer) ReadByte() (byte, error)

ReadByte reads and returns the next byte from the buffer.

func (*BytesBuffer) ReadBytes added in v0.4.25

func (bb *BytesBuffer) ReadBytes(delim byte) ([]byte, error)

ReadBytes reads until the first occurrence of delim in the input.

func (*BytesBuffer) ReadFloat32 added in v0.4.25

func (bb *BytesBuffer) ReadFloat32() (float32, error)

ReadFloat32 reads a 32-bit float in little-endian format.

func (*BytesBuffer) ReadFloat64 added in v0.4.25

func (bb *BytesBuffer) ReadFloat64() (float64, error)

ReadFloat64 reads a 64-bit float in little-endian format.

func (*BytesBuffer) ReadInt16 added in v0.4.25

func (bb *BytesBuffer) ReadInt16() (int16, error)

ReadInt16 reads a 16-bit integer in little-endian format.

func (*BytesBuffer) ReadInt32 added in v0.4.25

func (bb *BytesBuffer) ReadInt32() (int32, error)

ReadInt32 reads a 32-bit integer in little-endian format.

func (*BytesBuffer) ReadInt64 added in v0.4.25

func (bb *BytesBuffer) ReadInt64() (int64, error)

ReadInt64 reads a 64-bit integer in little-endian format.

func (*BytesBuffer) ReadString added in v0.4.25

func (bb *BytesBuffer) ReadString(delim byte) (string, error)

ReadString reads until the first occurrence of delim in the input.

func (*BytesBuffer) Reset added in v0.4.25

func (bb *BytesBuffer) Reset()

Reset is an alias for Clear.

func (*BytesBuffer) Seek added in v0.4.25

func (bb *BytesBuffer) Seek(offset int64, whence int) int64

Seek sets the position for the next Read or Write. This is a simplified version that resets and writes the data back.

func (*BytesBuffer) String added in v0.4.25

func (bb *BytesBuffer) String() string

String returns the buffer contents as a string.

func (*BytesBuffer) ToBool added in v0.4.25

func (bb *BytesBuffer) ToBool() *Bool

ToBool returns true (BytesBuffer is always truthy).

func (*BytesBuffer) Truncate added in v0.4.25

func (bb *BytesBuffer) Truncate(n int)

Truncate discards all but the first n bytes.

func (*BytesBuffer) Type added in v0.4.25

func (bb *BytesBuffer) Type() ObjectType

Type returns the object type.

func (*BytesBuffer) TypeTag added in v0.4.25

func (bb *BytesBuffer) TypeTag() TypeTag

TypeTag returns the fast type tag.

func (*BytesBuffer) Write added in v0.4.25

func (bb *BytesBuffer) Write(data []byte) int

Write appends bytes to the buffer.

func (*BytesBuffer) WriteByte added in v0.4.25

func (bb *BytesBuffer) WriteByte(b byte) error

WriteByte appends a single byte to the buffer.

func (*BytesBuffer) WriteFloat32 added in v0.4.25

func (bb *BytesBuffer) WriteFloat32(v float32) error

WriteFloat32 appends a 32-bit float in little-endian format.

func (*BytesBuffer) WriteFloat64 added in v0.4.25

func (bb *BytesBuffer) WriteFloat64(v float64) error

WriteFloat64 appends a 64-bit float in little-endian format.

func (*BytesBuffer) WriteInt16 added in v0.4.25

func (bb *BytesBuffer) WriteInt16(v int16) error

WriteInt16 appends a 16-bit integer in little-endian format.

func (*BytesBuffer) WriteInt32 added in v0.4.25

func (bb *BytesBuffer) WriteInt32(v int32) error

WriteInt32 appends a 32-bit integer in little-endian format.

func (*BytesBuffer) WriteInt64 added in v0.4.25

func (bb *BytesBuffer) WriteInt64(v int64) error

WriteInt64 appends a 64-bit integer in little-endian format.

func (*BytesBuffer) WriteString added in v0.4.25

func (bb *BytesBuffer) WriteString(s string) int

WriteString appends a string to the buffer as bytes.

func (*BytesBuffer) WriteTo added in v0.4.25

func (bb *BytesBuffer) WriteTo(other *BytesBuffer) (int64, error)

WriteTo writes the buffer contents to another BytesBuffer.

type Cell added in v0.5.2

type Cell struct {
	Value    string
	Type     string // "s"=shared string, "n"=number, "b"=bool, "str"=string, "d"=date
	Formula  string
	StyleIdx int
}

Cell represents a cell.

type Chars added in v0.4.25

type Chars struct {
	Value []rune
}

Chars represents a sequence of Unicode code points ([]rune in Go). Unlike String which is UTF-8 encoded bytes, Chars operates on character level, making it suitable for proper Unicode text processing.

func NewChars added in v0.4.25

func NewChars(val []rune) *Chars

NewChars creates a new Chars object from a rune slice

func NewCharsFromString added in v0.4.25

func NewCharsFromString(s string) *Chars

NewCharsFromString creates a new Chars object from a string

func (*Chars) At added in v0.4.25

func (c *Chars) At(index int) (string, bool)

At returns the character at the given index as a string

func (*Chars) HashKey added in v0.4.25

func (c *Chars) HashKey() HashKey

HashKey returns the hash key for map operations

func (*Chars) Inspect added in v0.4.25

func (c *Chars) Inspect() string

Inspect returns the string representation

func (*Chars) Len added in v0.4.25

func (c *Chars) Len() int

Len returns the number of characters (runes)

func (*Chars) Slice added in v0.4.25

func (c *Chars) Slice(start, end int) *Chars

Slice returns a new Chars from start to end index

func (*Chars) String added in v0.4.25

func (c *Chars) String() string

String converts Chars back to a Go string

func (*Chars) ToBool added in v0.4.25

func (c *Chars) ToBool() *Bool

ToBool converts the chars to a boolean (true if non-empty)

func (*Chars) Type added in v0.4.25

func (c *Chars) Type() ObjectType

Type returns the object type

func (*Chars) TypeTag added in v0.4.25

func (c *Chars) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type Class

type Class struct {
	Name       string
	SuperClass *Class
	Methods    map[string]Object // methods are CompiledFunction objects
	InitMethod Object            // constructor method
	Fields     map[string]Object // default field values
}

Class represents a class definition

func (*Class) HashKey

func (c *Class) HashKey() HashKey

func (*Class) Inspect

func (c *Class) Inspect() string

func (*Class) ToBool

func (c *Class) ToBool() *Bool

func (*Class) Type

func (c *Class) Type() ObjectType

func (*Class) TypeTag

func (c *Class) TypeTag() TypeTag

type CompiledFunction

type CompiledFunction struct {
	Instructions  []byte
	NumLocals     int
	NumParameters int
	Name          string
}

CompiledFunction represents a compiled function for the VM

func (*CompiledFunction) HashKey

func (cf *CompiledFunction) HashKey() HashKey

func (*CompiledFunction) Inspect

func (cf *CompiledFunction) Inspect() string

func (*CompiledFunction) ToBool

func (cf *CompiledFunction) ToBool() *Bool

func (*CompiledFunction) Type

func (cf *CompiledFunction) Type() ObjectType

func (*CompiledFunction) TypeTag

func (cf *CompiledFunction) TypeTag() TypeTag

type Cond added in v0.4.25

type Cond struct {
	// contains filtered or unexported fields
}

Cond wraps sync.Cond for use in Xxlang

func NewCond added in v0.4.25

func NewCond(m *Mutex) *Cond

NewCond creates a new Cond associated with the given Mutex

func (*Cond) Broadcast added in v0.4.25

func (c *Cond) Broadcast()

Broadcast wakes all goroutines waiting on the condition

func (*Cond) HashKey added in v0.4.25

func (c *Cond) HashKey() HashKey

func (*Cond) Inspect added in v0.4.25

func (c *Cond) Inspect() string

func (*Cond) Signal added in v0.4.25

func (c *Cond) Signal()

Signal wakes one goroutine waiting on the condition

func (*Cond) ToBool added in v0.4.25

func (c *Cond) ToBool() *Bool

func (*Cond) Type added in v0.4.25

func (c *Cond) Type() ObjectType

Object interface implementation

func (*Cond) TypeTag added in v0.4.25

func (c *Cond) TypeTag() TypeTag

func (*Cond) Wait added in v0.4.25

func (c *Cond) Wait()

Wait atomically unlocks the mutex and suspends execution

type Context added in v0.4.25

type Context struct {
	// contains filtered or unexported fields
}

Context represents a cancellation context

func NewBackgroundContext added in v0.4.25

func NewBackgroundContext() *Context

NewBackgroundContext creates a background context (never cancels)

func NewContext added in v0.4.25

func NewContext(ctx context.Context, cancel context.CancelFunc) *Context

NewContext creates a new context

func NewContextWithCancel added in v0.4.25

func NewContextWithCancel(parent *Context) *Context

NewContextWithCancel creates a context that can be cancelled manually

func NewContextWithDeadline added in v0.4.25

func NewContextWithDeadline(parent *Context, deadline time.Time) *Context

NewContextWithDeadline creates a context that cancels at deadline

func NewContextWithTimeout added in v0.4.25

func NewContextWithTimeout(parent *Context, timeout time.Duration) *Context

NewContextWithTimeout creates a context that cancels after duration

func (*Context) Cancel added in v0.4.25

func (c *Context) Cancel()

Cancel cancels the context

func (*Context) Deadline added in v0.4.25

func (c *Context) Deadline() (time.Time, bool)

Deadline returns the deadline time and whether a deadline is set

func (*Context) DeadlineString added in v0.4.25

func (c *Context) DeadlineString() string

DeadlineString returns the deadline as a string

func (*Context) Done added in v0.4.25

func (c *Context) Done() *Tube

Done returns the done tube (creates it lazily) The tube is a zero-buffer tube that gets closed when context is done

func (*Context) Err added in v0.4.25

func (c *Context) Err() error

Err returns the context error (nil if not done)

func (*Context) ErrString added in v0.4.25

func (c *Context) ErrString() string

ErrString returns the error as a string

func (*Context) GoContext added in v0.4.25

func (c *Context) GoContext() context.Context

GoContext returns the underlying Go context

func (*Context) HashKey added in v0.4.25

func (c *Context) HashKey() HashKey

HashKey returns a hash key for the context

func (*Context) Inspect added in v0.4.25

func (c *Context) Inspect() string

Inspect returns a string representation

func (*Context) IsDone added in v0.4.25

func (c *Context) IsDone() bool

IsDone returns true if context is done

func (*Context) ToBool added in v0.4.25

func (c *Context) ToBool() *Bool

ToBool returns true if context is not done

func (*Context) Type added in v0.4.25

func (c *Context) Type() ObjectType

Type returns the object type

func (*Context) TypeTag added in v0.4.25

func (c *Context) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

func (*Context) Value added in v0.4.25

func (c *Context) Value(key interface{}) interface{}

Value returns the value associated with key (for context values)

type DB added in v0.4.36

type DB struct {
	// Value is the underlying Go sql.DB connection
	Value *sql.DB
	// DriverName is the name of the database driver (e.g., "sqlite3", "mysql")
	DriverName string
	// DataSourceName is the connection string
	DataSourceName string
	// contains filtered or unexported fields
}

DB represents a database connection. It wraps the standard sql.DB and provides methods for querying and executing SQL.

func NewDB added in v0.4.36

func NewDB(db *sql.DB, driverName, dataSourceName string) *DB

NewDB creates a new DB object from an sql.DB connection.

func (*DB) Close added in v0.4.36

func (db *DB) Close() error

Close closes the database connection.

func (*DB) GetMember added in v0.4.36

func (db *DB) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*DB) HashKey added in v0.4.36

func (db *DB) HashKey() HashKey

HashKey returns a hash key for the DB.

func (*DB) Inspect added in v0.4.36

func (db *DB) Inspect() string

Inspect returns a string representation of the database connection.

func (*DB) IsClosed added in v0.4.36

func (db *DB) IsClosed() bool

IsClosed returns whether the connection is closed.

func (*DB) ToBool added in v0.4.36

func (db *DB) ToBool() *Bool

ToBool converts the DB to a boolean (true if connected).

func (*DB) Type added in v0.4.36

func (db *DB) Type() ObjectType

Type returns the object type.

func (*DB) TypeTag added in v0.4.36

func (db *DB) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type DBRows added in v0.4.36

type DBRows struct {
	// Value is the underlying Go sql.Rows
	Value *sql.Rows
	// contains filtered or unexported fields
}

DBRows represents database query results. It wraps sql.Rows and provides iteration methods.

func NewDBRows added in v0.4.36

func NewDBRows(rows *sql.Rows) *DBRows

NewDBRows creates a new DBRows object from sql.Rows.

func (*DBRows) Close added in v0.4.36

func (r *DBRows) Close() error

Close closes the rows.

func (*DBRows) Columns added in v0.4.36

func (r *DBRows) Columns() ([]string, error)

Columns returns the column names.

func (*DBRows) GetMember added in v0.4.36

func (r *DBRows) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*DBRows) HashKey added in v0.4.36

func (r *DBRows) HashKey() HashKey

HashKey returns a hash key for the rows.

func (*DBRows) Inspect added in v0.4.36

func (r *DBRows) Inspect() string

Inspect returns a string representation of the rows.

func (*DBRows) IsClosed added in v0.4.36

func (r *DBRows) IsClosed() bool

IsClosed returns whether the rows are closed.

func (*DBRows) ToBool added in v0.4.36

func (r *DBRows) ToBool() *Bool

ToBool converts the rows to a boolean (true if not closed).

func (*DBRows) Type added in v0.4.36

func (r *DBRows) Type() ObjectType

Type returns the object type.

func (*DBRows) TypeTag added in v0.4.36

func (r *DBRows) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type DBStmt added in v0.4.36

type DBStmt struct {
	// Value is the underlying Go sql.Stmt
	Value *sql.Stmt
	// DB is the parent database connection
	DB *DB
	// contains filtered or unexported fields
}

DBStmt represents a prepared statement. It wraps sql.Stmt and provides execution methods.

func NewDBStmt added in v0.4.36

func NewDBStmt(stmt *sql.Stmt, db *DB) *DBStmt

NewDBStmt creates a new DBStmt object from sql.Stmt.

func (*DBStmt) Close added in v0.4.36

func (s *DBStmt) Close() error

Close closes the statement.

func (*DBStmt) GetMember added in v0.4.36

func (s *DBStmt) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*DBStmt) HashKey added in v0.4.36

func (s *DBStmt) HashKey() HashKey

HashKey returns a hash key for the statement.

func (*DBStmt) Inspect added in v0.4.36

func (s *DBStmt) Inspect() string

Inspect returns a string representation of the statement.

func (*DBStmt) IsClosed added in v0.4.36

func (s *DBStmt) IsClosed() bool

IsClosed returns whether the statement is closed.

func (*DBStmt) ToBool added in v0.4.36

func (s *DBStmt) ToBool() *Bool

ToBool converts the statement to a boolean (true if not closed).

func (*DBStmt) Type added in v0.4.36

func (s *DBStmt) Type() ObjectType

Type returns the object type.

func (*DBStmt) TypeTag added in v0.4.36

func (s *DBStmt) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type DBTx added in v0.4.36

type DBTx struct {
	// Value is the underlying Go sql.Tx
	Value *sql.Tx
	// DB is the parent database connection
	DB *DB
	// contains filtered or unexported fields
}

DBTx represents a database transaction. It provides methods for transactional operations.

func NewDBTx added in v0.4.36

func NewDBTx(tx *sql.Tx, db *DB) *DBTx

NewDBTx creates a new DBTx object from an sql.Tx.

func (*DBTx) GetMember added in v0.4.36

func (tx *DBTx) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*DBTx) HashKey added in v0.4.36

func (tx *DBTx) HashKey() HashKey

HashKey returns a hash key for the transaction.

func (*DBTx) Inspect added in v0.4.36

func (tx *DBTx) Inspect() string

Inspect returns a string representation of the transaction.

func (*DBTx) IsClosed added in v0.4.36

func (tx *DBTx) IsClosed() bool

IsClosed returns whether the transaction is closed.

func (*DBTx) MarkClosed added in v0.4.36

func (tx *DBTx) MarkClosed()

MarkClosed marks the transaction as closed.

func (*DBTx) ToBool added in v0.4.36

func (tx *DBTx) ToBool() *Bool

ToBool converts the transaction to a boolean (true if active).

func (*DBTx) Type added in v0.4.36

func (tx *DBTx) Type() ObjectType

Type returns the object type.

func (*DBTx) TypeTag added in v0.4.36

func (tx *DBTx) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type Environment

type Environment struct {
	Store map[string]Object
	Outer *Environment
}

Environment represents a variable scope

func NewEnclosedEnvironment

func NewEnclosedEnvironment(outer *Environment) *Environment

NewEnclosedEnvironment creates a new environment with an outer scope

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment creates a new environment

func (*Environment) Get

func (e *Environment) Get(name string) (Object, bool)

Get retrieves a variable from the environment

func (*Environment) Set

func (e *Environment) Set(name string, val Object) Object

Set sets a variable in the environment

type Error

type Error struct {
	Message string
}

Error represents a runtime error

func (*Error) HashKey

func (e *Error) HashKey() HashKey

func (*Error) Inspect

func (e *Error) Inspect() string

func (*Error) ToBool

func (e *Error) ToBool() *Bool

func (*Error) Type

func (e *Error) Type() ObjectType

func (*Error) TypeTag

func (e *Error) TypeTag() TypeTag

type File added in v0.4.25

type File struct {
	Handle   *os.File     // The underlying OS file handle
	Path     string       // The file path
	Mode     FileMode     // The mode the file was opened with
	Open     bool         // Whether the file is currently open
	Position int64        // Current position in the file
	LockType FileLockType // Current lock type (0 = unlocked)
	// contains filtered or unexported fields
}

File represents an open file handle for streaming I/O operations. It wraps os.File and provides methods for reading, writing, seeking, and managing file state.

func NewFile added in v0.4.25

func NewFile(handle *os.File, path string, mode FileMode) *File

NewFile creates a new File object from an os.File handle.

func (*File) Close added in v0.4.25

func (f *File) Close() error

Close closes the file handle. Returns nil on success, error otherwise.

func (*File) Flush added in v0.4.25

func (f *File) Flush() error

Flush flushes any buffered data to disk.

func (*File) GetMode added in v0.4.25

func (f *File) GetMode() FileMode

GetMode returns the file mode.

func (*File) GetName added in v0.4.25

func (f *File) GetName() string

GetName returns the file name (base name).

func (*File) HashKey added in v0.4.25

func (f *File) HashKey() HashKey

HashKey returns a hash key for the File object.

func (*File) Inspect added in v0.4.25

func (f *File) Inspect() string

Inspect returns a string representation of the File object.

func (*File) IsOpen added in v0.4.25

func (f *File) IsOpen() bool

IsOpen returns whether the file is open.

func (*File) Lock added in v0.4.25

func (f *File) Lock(lockType FileLockType, blocking bool) error

Lock places a lock on the file. lockType: 1 = shared, 2 = exclusive Non-blocking: returns immediately if lock cannot be acquired.

func (*File) Read added in v0.4.25

func (f *File) Read(n int) ([]byte, error)

Read reads up to n bytes from the file. Returns the bytes read as an array of integers.

func (*File) ReadAll added in v0.4.25

func (f *File) ReadAll() ([]byte, error)

ReadAll reads all remaining content from the file.

func (*File) ReadLine added in v0.4.25

func (f *File) ReadLine() (string, error)

ReadLine reads a single line from the file. Returns the line as a string without the trailing newline.

func (*File) Seek added in v0.4.25

func (f *File) Seek(offset int64, whence int) (int64, error)

Seek sets the file position. Whence: 0 = start, 1 = current, 2 = end

func (*File) Stat added in v0.4.25

func (f *File) Stat() (os.FileInfo, error)

Stat returns file information.

func (*File) Tell added in v0.4.25

func (f *File) Tell() int64

Tell returns the current file position.

func (*File) ToBool added in v0.4.25

func (f *File) ToBool() *Bool

ToBool returns true if the file is open, false otherwise.

func (*File) Truncate added in v0.4.25

func (f *File) Truncate(size int64) error

Truncate truncates the file to the specified size.

func (*File) Type added in v0.4.25

func (f *File) Type() ObjectType

Type returns the object type.

func (*File) TypeTag added in v0.4.25

func (f *File) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

func (*File) Unlock added in v0.4.25

func (f *File) Unlock() error

Unlock releases the file lock.

func (*File) Write added in v0.4.25

func (f *File) Write(data []byte) (int, error)

Write writes data to the file at the current position. Returns the number of bytes written.

func (*File) WriteString added in v0.4.25

func (f *File) WriteString(s string) (int, error)

WriteString writes a string to the file.

type FileInfo added in v0.4.25

type FileInfo struct {
	Name     string    // Base name of the file
	Size     int64     // Length in bytes
	Mode     uint32    // File mode bits
	ModTime  time.Time // Modification time
	IsDir    bool      // Whether it's a directory
	FullPath string    // Full path to the file
}

FileInfo wraps os.FileInfo for use in Xxlang.

func NewFileInfo added in v0.4.25

func NewFileInfo(info os.FileInfo, fullPath string) *FileInfo

NewFileInfo creates a new FileInfo from os.FileInfo.

func (*FileInfo) GetModTimeString added in v0.4.25

func (fi *FileInfo) GetModTimeString() string

GetModTimeString returns the modification time as a formatted string.

func (*FileInfo) GetModTimeUnix added in v0.4.25

func (fi *FileInfo) GetModTimeUnix() int64

GetModTimeUnix returns the modification time as Unix timestamp (milliseconds).

func (*FileInfo) GetModeString added in v0.4.25

func (fi *FileInfo) GetModeString() string

GetModeString returns the file mode as an octal string.

func (*FileInfo) HashKey added in v0.4.25

func (fi *FileInfo) HashKey() HashKey

HashKey returns a hash key for the FileInfo.

func (*FileInfo) Inspect added in v0.4.25

func (fi *FileInfo) Inspect() string

Inspect returns a string representation of the FileInfo.

func (*FileInfo) IsRegular added in v0.4.25

func (fi *FileInfo) IsRegular() bool

IsRegular returns true if this is a regular file.

func (fi *FileInfo) IsSymlink() bool

IsSymlink returns true if this is a symbolic link.

func (*FileInfo) ToBool added in v0.4.25

func (fi *FileInfo) ToBool() *Bool

ToBool always returns true for FileInfo.

func (*FileInfo) Type added in v0.4.25

func (fi *FileInfo) Type() ObjectType

Type returns the object type.

func (*FileInfo) TypeTag added in v0.4.25

func (fi *FileInfo) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type FileLockType added in v0.4.25

type FileLockType int

FileLockType represents the type of file lock

const (
	LockNone      FileLockType = iota // No lock
	LockShared                        // Shared (read) lock
	LockExclusive                     // Exclusive (write) lock
)

type FileMode added in v0.4.25

type FileMode string

FileMode represents the mode in which a file is opened

const (
	ModeRead   FileMode = "r"   // Read-only
	ModeWrite  FileMode = "w"   // Write-only (truncate)
	ModeAppend FileMode = "a"   // Append-only
	ModeRW     FileMode = "rw"  // Read and write
	ModeRWPlus FileMode = "rw+" // Read and write (create if not exists)
)

type FileUpload added in v0.4.25

type FileUpload struct {
	// Header is the underlying multipart.FileHeader
	Header *multipart.FileHeader
	// Members holds dynamically accessed members for script use
	Members map[string]Object
	// contains filtered or unexported fields
}

FileUpload represents an uploaded file from an HTTP request. It wraps the multipart.FileHeader and provides methods for accessing file information and saving the file to disk.

func NewFileUpload added in v0.4.25

func NewFileUpload(header *multipart.FileHeader) *FileUpload

NewFileUpload creates a new FileUpload object from a multipart.FileHeader.

func (*FileUpload) GetMember added in v0.4.25

func (f *FileUpload) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*FileUpload) HashKey added in v0.4.25

func (f *FileUpload) HashKey() HashKey

HashKey returns a hash key for the file upload.

func (*FileUpload) HashSHA256 added in v0.4.25

func (f *FileUpload) HashSHA256() (string, error)

HashSHA256 calculates the SHA256 hash of the uploaded file.

func (*FileUpload) Inspect added in v0.4.25

func (f *FileUpload) Inspect() string

Inspect returns a string representation of the file upload.

func (*FileUpload) Open added in v0.4.25

func (f *FileUpload) Open() (multipart.File, error)

Open opens the uploaded file for reading. Returns an io.ReadCloser or an error.

func (*FileUpload) ReadAll added in v0.4.25

func (f *FileUpload) ReadAll() ([]byte, error)

ReadAll reads the entire content of the uploaded file. Returns the file content as a byte slice or an error.

func (*FileUpload) ReadAsString added in v0.4.25

func (f *FileUpload) ReadAsString() (string, error)

ReadAsString reads the entire content of the uploaded file as a string.

func (*FileUpload) Save added in v0.4.25

func (f *FileUpload) Save(destPath string) (string, error)

Save saves the uploaded file to the specified path. Returns the absolute path of the saved file or an error.

func (*FileUpload) SaveToDir added in v0.4.25

func (f *FileUpload) SaveToDir(dir string, autoRename bool) (string, error)

SaveToDir saves the uploaded file to the specified directory with the original filename. If autoRename is true, adds timestamp prefix to avoid name conflicts. Returns the full path of the saved file or an error.

func (*FileUpload) ToBool added in v0.4.25

func (f *FileUpload) ToBool() *Bool

ToBool converts the file upload to a boolean (true if file exists).

func (*FileUpload) Type added in v0.4.25

func (f *FileUpload) Type() ObjectType

Type returns the object type.

func (*FileUpload) TypeTag added in v0.4.25

func (f *FileUpload) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type FileUploadConfig added in v0.4.25

type FileUploadConfig struct {
	// MaxSize is the maximum file size in bytes (0 = unlimited)
	MaxSize int64
	// AllowedExtensions is a list of allowed file extensions (empty = all allowed)
	AllowedExtensions []string
	// UploadDir is the default directory for file uploads
	UploadDir string
	// AutoRename indicates whether to automatically rename files on conflict
	AutoRename bool
	// AllowedMimeTypes is a list of allowed MIME types (empty = all allowed)
	AllowedMimeTypes []string
}

FileUploadConfig holds configuration for file upload handling.

func DefaultFileUploadConfig added in v0.4.25

func DefaultFileUploadConfig() *FileUploadConfig

DefaultFileUploadConfig returns the default file upload configuration.

func (*FileUploadConfig) Validate added in v0.4.25

func (c *FileUploadConfig) Validate(file *FileUpload) error

Validate validates a file upload against the configuration.

type FileUploadResult added in v0.4.25

type FileUploadResult struct {
	// Success indicates whether the operation was successful
	Success bool
	// Message contains the result message or error description
	Message string
	// FilePath is the path where the file was saved
	FilePath string
	// OriginalName is the original filename
	OriginalName string
	// Size is the file size in bytes
	Size int64
}

FileUploadResult represents the result of a file upload operation.

func NewFileUploadResult added in v0.4.25

func NewFileUploadResult(success bool, message, filePath, originalName string, size int64) *FileUploadResult

NewFileUploadResult creates a new FileUploadResult object.

func (*FileUploadResult) GetMember added in v0.4.25

func (r *FileUploadResult) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*FileUploadResult) HashKey added in v0.4.25

func (r *FileUploadResult) HashKey() HashKey

HashKey returns a hash key for the upload result.

func (*FileUploadResult) Inspect added in v0.4.25

func (r *FileUploadResult) Inspect() string

Inspect returns a string representation of the upload result.

func (*FileUploadResult) ToBool added in v0.4.25

func (r *FileUploadResult) ToBool() *Bool

ToBool converts the upload result to a boolean.

func (*FileUploadResult) Type added in v0.4.25

func (r *FileUploadResult) Type() ObjectType

Type returns the object type.

func (*FileUploadResult) TypeTag added in v0.4.25

func (r *FileUploadResult) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type Float

type Float struct {
	Value float64
}

Float represents a floating-point value

func GetBufferedFloat added in v0.4.23

func GetBufferedFloat(val float64) *Float

GetBufferedFloat gets a temporary Float using the global buffer

func NewFloat added in v0.4.23

func NewFloat(val float64) *Float

NewFloat creates a new Float object, using cached values for common floats

func NewFloatSlice added in v0.4.23

func NewFloatSlice(values []float64) []*Float

NewFloatSlice creates multiple Float objects efficiently This is optimized for batch operations

func (*Float) HashKey

func (f *Float) HashKey() HashKey

HashKey returns the hash key for map operations

func (*Float) Inspect

func (f *Float) Inspect() string

Inspect returns the string representation

func (*Float) ToBool

func (f *Float) ToBool() *Bool

ToBool converts the float to a boolean

func (*Float) Type

func (f *Float) Type() ObjectType

Type returns the object type

func (*Float) TypeTag

func (f *Float) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type FloatPoolStats added in v0.4.23

type FloatPoolStats struct {
	// CacheHits is the number of times a cached float was returned
	CacheHits int64
	// PoolHits is the number of times a pooled float was reused
	PoolHits int64
	// Created is the number of new floats allocated by the pool
	Created int64
	// Released is the number of floats returned to the pool
	Released int64
}

FloatPoolStats tracks statistics about float pool usage

func GetFloatPoolStats added in v0.4.23

func GetFloatPoolStats() FloatPoolStats

GetFloatPoolStats returns current statistics about float pool usage

type Function

type Function struct {
	Parameters []*Identifier
	Body       interface{} // Will be *ast.BlockStatement, using interface{} to avoid import cycle
	Env        *Environment
	Name       string // Optional: for named functions
}

Function represents a user-defined function

func (*Function) HashKey

func (f *Function) HashKey() HashKey

func (*Function) Inspect

func (f *Function) Inspect() string

func (*Function) ToBool

func (f *Function) ToBool() *Bool

func (*Function) Type

func (f *Function) Type() ObjectType

func (*Function) TypeTag

func (f *Function) TypeTag() TypeTag

type Goroutine added in v0.4.25

type Goroutine struct {
	// contains filtered or unexported fields
}

Goroutine represents a goroutine started with 'run'

func NewGoroutine added in v0.4.25

func NewGoroutine() *Goroutine

NewGoroutine creates a new Goroutine record

func (*Goroutine) HashKey added in v0.4.25

func (g *Goroutine) HashKey() HashKey

func (*Goroutine) ID added in v0.4.25

func (g *Goroutine) ID() uint64

ID returns the goroutine's unique identifier

func (*Goroutine) Inspect added in v0.4.25

func (g *Goroutine) Inspect() string

func (*Goroutine) MarkFinished added in v0.4.25

func (g *Goroutine) MarkFinished()

MarkFinished marks the goroutine as finished

func (*Goroutine) MarkPanicked added in v0.4.25

func (g *Goroutine) MarkPanicked(v interface{})

MarkPanicked marks the goroutine as panicked

func (*Goroutine) PanicValue added in v0.4.25

func (g *Goroutine) PanicValue() interface{}

PanicValue returns the panic value if the goroutine panicked

func (*Goroutine) Status added in v0.4.25

func (g *Goroutine) Status() GoroutineStatus

Status returns the current status of the goroutine

func (*Goroutine) ToBool added in v0.4.25

func (g *Goroutine) ToBool() *Bool

func (*Goroutine) Type added in v0.4.25

func (g *Goroutine) Type() ObjectType

Object interface implementation

func (*Goroutine) TypeTag added in v0.4.25

func (g *Goroutine) TypeTag() TypeTag

func (*Goroutine) Wait added in v0.4.25

func (g *Goroutine) Wait()

Wait blocks until the goroutine completes

type GoroutineStatus added in v0.4.25

type GoroutineStatus int

GoroutineStatus represents the state of a goroutine

const (
	GoroutineRunning GoroutineStatus = iota
	GoroutineFinished
	GoroutinePanicked
)

type HashKey

type HashKey struct {
	Type  ObjectType
	Value uint64
}

HashKey is used for map keys

type HttpMux added in v0.4.25

type HttpMux struct {
	// Value is the underlying Go http.ServeMux
	Value *http.ServeMux
}

HttpMux wraps http.ServeMux for route registration. It allows scripts to register custom route handlers.

func NewHttpMux added in v0.4.25

func NewHttpMux() *HttpMux

NewHttpMux creates a new HttpMux object.

func (*HttpMux) HashKey added in v0.4.25

func (m *HttpMux) HashKey() HashKey

HashKey returns a hash key for the HTTP mux. HTTP muxes are not hashable in a meaningful way.

func (*HttpMux) Inspect added in v0.4.25

func (m *HttpMux) Inspect() string

Inspect returns a string representation of the HTTP mux.

func (*HttpMux) ToBool added in v0.4.25

func (m *HttpMux) ToBool() *Bool

ToBool converts the HTTP mux to a boolean (always true).

func (*HttpMux) Type added in v0.4.25

func (m *HttpMux) Type() ObjectType

Type returns the object type.

func (*HttpMux) TypeTag added in v0.4.25

func (m *HttpMux) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type HttpReq added in v0.4.25

type HttpReq struct {
	// Value is the underlying Go http.Request
	Value *http.Request
	// Members holds dynamically accessed members for script use
	Members map[string]Object
}

HttpReq wraps http.Request for script access. It provides methods and member access for reading HTTP request data.

func NewHttpReq added in v0.4.25

func NewHttpReq(req *http.Request) *HttpReq

NewHttpReq creates a new HttpReq object from an http.Request.

func (*HttpReq) GetMember added in v0.4.25

func (r *HttpReq) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*HttpReq) HashKey added in v0.4.25

func (r *HttpReq) HashKey() HashKey

HashKey returns a hash key for the HTTP request. HTTP requests are not hashable in a meaningful way.

func (*HttpReq) Inspect added in v0.4.25

func (r *HttpReq) Inspect() string

Inspect returns a string representation of the HTTP request.

func (*HttpReq) ToBool added in v0.4.25

func (r *HttpReq) ToBool() *Bool

ToBool converts the HTTP request to a boolean (always true).

func (*HttpReq) Type added in v0.4.25

func (r *HttpReq) Type() ObjectType

Type returns the object type.

func (*HttpReq) TypeTag added in v0.4.25

func (r *HttpReq) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type HttpResp added in v0.4.25

type HttpResp struct {
	// Value is the underlying Go http.ResponseWriter
	Value http.ResponseWriter
	// Members holds dynamically accessed members for script use
	Members map[string]Object
	// contains filtered or unexported fields
}

HttpResp wraps http.ResponseWriter for script access. It provides methods for writing responses and setting headers.

func NewHttpResp added in v0.4.25

func NewHttpResp(res http.ResponseWriter) *HttpResp

NewHttpResp creates a new HttpResp object from an http.ResponseWriter.

func (*HttpResp) GetMember added in v0.4.25

func (r *HttpResp) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*HttpResp) HashKey added in v0.4.25

func (r *HttpResp) HashKey() HashKey

HashKey returns a hash key for the HTTP response. HTTP responses are not hashable in a meaningful way.

func (*HttpResp) Inspect added in v0.4.25

func (r *HttpResp) Inspect() string

Inspect returns a string representation of the HTTP response.

func (*HttpResp) SetWritten added in v0.4.25

func (r *HttpResp) SetWritten()

SetWritten marks the response as written.

func (*HttpResp) ToBool added in v0.4.25

func (r *HttpResp) ToBool() *Bool

ToBool converts the HTTP response to a boolean (always true).

func (*HttpResp) Type added in v0.4.25

func (r *HttpResp) Type() ObjectType

Type returns the object type.

func (*HttpResp) TypeTag added in v0.4.25

func (r *HttpResp) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

func (*HttpResp) Written added in v0.4.25

func (r *HttpResp) Written() bool

Written returns whether the response has been written to.

type Identifier

type Identifier struct {
	Value string
}

Identifier represents an identifier (used in function parameters)

func (*Identifier) String

func (i *Identifier) String() string

type ImageInfo added in v0.5.2

type ImageInfo struct {
	Col, Row       int    // Top-left position
	ColEnd, RowEnd int    // Bottom-right position
	Filename       string // Original filename in xlsx
	Data           []byte // Image data
}

ImageInfo represents an image in a sheet.

type Instance

type Instance struct {
	Class  *Class
	Fields map[string]Object
}

Instance represents an instance of a class

func (*Instance) HashKey

func (i *Instance) HashKey() HashKey

func (*Instance) Inspect

func (i *Instance) Inspect() string

func (*Instance) ToBool

func (i *Instance) ToBool() *Bool

func (*Instance) Type

func (i *Instance) Type() ObjectType

func (*Instance) TypeTag

func (i *Instance) TypeTag() TypeTag

type Int

type Int struct {
	Value int64
}

Int represents an integer value

func GetBufferedInt added in v0.4.23

func GetBufferedInt(val int64) *Int

GetBufferedInt gets a temporary Int using the global buffer

func NewInt

func NewInt(val int64) *Int

NewInt creates a new Int object, using cache for small values

func NewIntSlice added in v0.4.23

func NewIntSlice(values []int64) []*Int

NewIntSlice creates multiple Int objects efficiently This is optimized for batch operations

func (*Int) HashKey

func (i *Int) HashKey() HashKey

HashKey returns the hash key for map operations

func (*Int) Inspect

func (i *Int) Inspect() string

Inspect returns the string representation

func (*Int) ToBool

func (i *Int) ToBool() *Bool

ToBool converts the integer to a boolean

func (*Int) Type

func (i *Int) Type() ObjectType

Type returns the object type

func (*Int) TypeTag

func (i *Int) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type IntPoolStats added in v0.4.23

type IntPoolStats struct {
	// CacheHits is the number of times a cached integer was returned
	CacheHits int64
	// PoolHits is the number of times a pooled integer was reused
	PoolHits int64
	// PoolMisses is the number of times a new integer had to be allocated
	PoolMisses int64
	// Created is the number of new integers allocated by the pool
	Created int64
	// Released is the number of integers returned to the pool
	Released int64
}

IntPoolStats tracks statistics about integer pool usage

func GetIntPoolStats added in v0.4.23

func GetIntPoolStats() IntPoolStats

GetIntPoolStats returns current statistics about integer pool usage

type Map

type Map struct {
	Pairs map[HashKey]MapPair
	// contains filtered or unexported fields
}

Map represents a map value

func NewMap added in v0.4.23

func NewMap(pairs map[HashKey]MapPair) *Map

NewMap creates a new Map object with the given pairs

func NewMapWithCapacity added in v0.4.23

func NewMapWithCapacity(capacity int) *Map

NewMapWithCapacity creates a new Map with pre-allocated capacity

func (*Map) GetSortedKeys added in v0.4.23

func (m *Map) GetSortedKeys() []Object

GetSortedKeys returns the keys in sorted order, caching the result

func (*Map) HashKey

func (m *Map) HashKey() HashKey

HashKey returns the hash key for map operations

func (*Map) Inspect

func (m *Map) Inspect() string

Inspect returns the string representation

func (*Map) InvalidateKeysCache added in v0.4.23

func (m *Map) InvalidateKeysCache()

InvalidateKeysCache marks the sorted keys cache as invalid Call this when the map is modified

func (*Map) ToBool

func (m *Map) ToBool() *Bool

ToBool converts the map to a boolean

func (*Map) Type

func (m *Map) Type() ObjectType

Type returns the object type

func (*Map) TypeTag

func (m *Map) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type MapPair

type MapPair struct {
	Key   Object
	Value Object
}

MapPair represents a key-value pair in a map

type MapPoolStats added in v0.4.23

type MapPoolStats struct {
	CacheHits int64
	PoolHits  int64
	Created   int64
	Released  int64
}

MapPoolStats tracks statistics about map pool usage

func GetMapPoolStats added in v0.4.23

func GetMapPoolStats() MapPoolStats

GetMapPoolStats returns current statistics about map pool usage

type MergeRange added in v0.5.2

type MergeRange struct {
	StartCol, StartRow int
	EndCol, EndRow     int
}

MergeRange represents merged cells.

type Module

type Module struct {
	// Name is the module's identifier (typically the file path)
	Name string

	// Exports maps exported symbol names to their values
	Exports map[string]Object

	// Globals holds the module's global variables state.
	// This is needed so exported functions can access module-level variables.
	Globals []Object
}

Module represents a loaded module with its exported symbols. Modules are created when a source file is imported and compiled, and they hold all exported values accessible to importers.

func (*Module) HashKey

func (m *Module) HashKey() HashKey

HashKey returns a hash key for the module. Modules are not hashable in a meaningful way, so we return a constant.

func (*Module) Inspect

func (m *Module) Inspect() string

Inspect returns a string representation of the module.

func (*Module) ToBool

func (m *Module) ToBool() *Bool

ToBool converts the module to a boolean (always true).

func (*Module) Type

func (m *Module) Type() ObjectType

Type returns the object type.

func (*Module) TypeTag

func (m *Module) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type Mutex added in v0.4.25

type Mutex struct {
	// contains filtered or unexported fields
}

Mutex wraps sync.Mutex for use in Xxlang

func NewMutex added in v0.4.25

func NewMutex() *Mutex

NewMutex creates a new Mutex

func (*Mutex) HashKey added in v0.4.25

func (m *Mutex) HashKey() HashKey

func (*Mutex) Inspect added in v0.4.25

func (m *Mutex) Inspect() string

func (*Mutex) Lock added in v0.4.25

func (m *Mutex) Lock()

Lock acquires the mutex, blocking if necessary

func (*Mutex) ToBool added in v0.4.25

func (m *Mutex) ToBool() *Bool

func (*Mutex) TryLock added in v0.4.25

func (m *Mutex) TryLock() bool

TryLock attempts to acquire the mutex without blocking Returns true if successful, false otherwise

func (*Mutex) Type added in v0.4.25

func (m *Mutex) Type() ObjectType

Object interface implementation

func (*Mutex) TypeTag added in v0.4.25

func (m *Mutex) TypeTag() TypeTag

func (*Mutex) Unlock added in v0.4.25

func (m *Mutex) Unlock()

Unlock releases the mutex

type Null

type Null struct{}

Null represents the null value

func (*Null) HashKey

func (n *Null) HashKey() HashKey

func (*Null) Inspect

func (n *Null) Inspect() string

func (*Null) ToBool

func (n *Null) ToBool() *Bool

func (*Null) Type

func (n *Null) Type() ObjectType

func (*Null) TypeTag

func (n *Null) TypeTag() TypeTag

type Object

type Object interface {
	Type() ObjectType
	TypeTag() TypeTag // Fast type check without string comparison
	Inspect() string
	ToBool() *Bool
	HashKey() HashKey
}

Object is the base interface for all values in Xxlang

func CallUserFunc added in v0.4.25

func CallUserFunc(fn Object, args ...Object) (Object, error)

CallUserFunc calls a user-defined function from within a builtin method Returns an error if the callback is not set or if the call fails

func GoValueToObject added in v0.4.25

func GoValueToObject(v interface{}) Object

GoValueToObject converts a Go value (from JSON unmarshaling) to an Xxlang Object. This function is exported for use by other packages that need to convert Go values to Xxlang objects.

func IoCopy added in v0.4.25

func IoCopy(dst *Writer, src *Reader) Object

IoCopy copies data from reader to writer. This is exposed as a builtin function.

func JSONToObject added in v0.4.25

func JSONToObject(s string) (Object, error)

JSONToObject parses a JSON string and returns an Xxlang Object. This is the primary function for JSON deserialization in Xxlang.

func RowsToArrays added in v0.4.36

func RowsToArrays(rows *sql.Rows) (Object, error)

RowsToArrays converts sql.Rows to an array of arrays. Each row is an array of values in column order.

func RowsToMaps added in v0.4.36

func RowsToMaps(rows *sql.Rows) (Object, error)

RowsToMaps converts sql.Rows to an array of maps. Each row is a map with column names as keys.

func Scan added in v0.4.25

func Scan(prompt string) Object

Scan reads a line from stdin and returns it as a string. If a prompt string is provided, it is printed first.

func ScanBool added in v0.4.25

func ScanBool(prompt string) Object

ScanBool reads a boolean from stdin.

func ScanFloat added in v0.4.25

func ScanFloat(prompt string) Object

ScanFloat reads a float from stdin.

func ScanInt added in v0.4.25

func ScanInt(prompt string) Object

ScanInt reads an integer from stdin.

func ScanN added in v0.4.25

func ScanN(n int) Object

ScanN reads n whitespace-delimited tokens from stdin.

func ScanSplit added in v0.4.25

func ScanSplit(sep string) Object

ScanSplit reads a line and splits it by the given separator.

func Scanf added in v0.4.25

func Scanf(format string) Object

Scanf reads input according to a format string. The format string can contain {} placeholders for values. Returns an array of parsed values.

type ObjectToJSONOptions added in v0.4.25

type ObjectToJSONOptions struct {
	Indent     bool
	SortKeys   bool
	IndentStr  string
	StartLevel int
}

ObjectToJSONOptions contains options for JSON serialization

type ObjectType

type ObjectType string

ObjectType represents the type of an object

const (
	NullType             ObjectType = "NULL"
	IntType              ObjectType = "INT"
	FloatType            ObjectType = "FLOAT"
	StringType           ObjectType = "STRING"
	CharsType            ObjectType = "CHARS"
	BoolType             ObjectType = "BOOL"
	ArrayType            ObjectType = "ARRAY"
	MapType              ObjectType = "MAP"
	FunctionType         ObjectType = "FUNCTION"
	BuiltinType          ObjectType = "BUILTIN"
	BytesType            ObjectType = "BYTES"
	ClassType            ObjectType = "CLASS"
	InstanceType         ObjectType = "INSTANCE"
	ErrorType            ObjectType = "ERROR"
	ReturnType           ObjectType = "RETURN"
	ClosureType          ObjectType = "CLOSURE"
	ModuleType           ObjectType = "MODULE"
	StringBuilderType    ObjectType = "STRING_BUILDER"
	BytesBufferType      ObjectType = "BYTES_BUFFER"
	BigIntType           ObjectType = "BIGINT"
	BigFloatType         ObjectType = "BIGFLOAT"
	HttpReqType          ObjectType = "HTTP_REQ"
	HttpRespType         ObjectType = "HTTP_RESP"
	HttpMuxType          ObjectType = "HTTP_MUX"
	WebSocketType        ObjectType = "WEBSOCKET"
	TubeType             ObjectType = "TUBE"
	MutexType            ObjectType = "MUTEX"
	RWMutexType          ObjectType = "RWMUTEX"
	WaitGroupType        ObjectType = "WAITGROUP"
	OnceType             ObjectType = "ONCE"
	CondType             ObjectType = "COND"
	AtomicIntType        ObjectType = "ATOMICINT"
	GoroutineType        ObjectType = "GOROUTINE"
	ContextType          ObjectType = "CONTEXT"
	FileUploadType       ObjectType = "FILE_UPLOAD"
	FileUploadResultType ObjectType = "FILE_UPLOAD_RESULT"
	FileType             ObjectType = "FILE"
	FileInfoType         ObjectType = "FILE_INFO"
	ReaderType           ObjectType = "READER"
	WriterType           ObjectType = "WRITER"
	ScannerType          ObjectType = "SCANNER"
	DBType               ObjectType = "DB"
	DBTxType             ObjectType = "DB_TX"
	DBRowsType           ObjectType = "DB_ROWS"
	DBStmtType           ObjectType = "DB_STMT"
	OrderedMapType       ObjectType = "ORDERED_MAP"
	QueueType            ObjectType = "QUEUE"
	SetType              ObjectType = "SET"
	XLSXType             ObjectType = "XLSX"
	XMLDocumentType      ObjectType = "XML_DOCUMENT"
	XMLNodeType          ObjectType = "XML_NODE"
	DocxDocumentType     ObjectType = "DOCX_DOCUMENT"
	DocxParagraphType    ObjectType = "DOCX_PARAGRAPH"
	DocxRunType          ObjectType = "DOCX_RUN"
	DocxTableType        ObjectType = "DOCX_TABLE"
	DocxTableRowType     ObjectType = "DOCX_TABLE_ROW"
	DocxTableCellType    ObjectType = "DOCX_TABLE_CELL"
	DocxImageType        ObjectType = "DOCX_IMAGE"
	DocxSectionType      ObjectType = "DOCX_SECTION"
	DocxHeaderType       ObjectType = "DOCX_HEADER"
	DocxFooterType       ObjectType = "DOCX_FOOTER"
	DocxStyleType        ObjectType = "DOCX_STYLE"
	DocxHyperlinkType    ObjectType = "DOCX_HYPERLINK"
	DocxBookmarkType     ObjectType = "DOCX_BOOKMARK"
	DocxTOCType          ObjectType = "DOCX_TOC"
	DocxTextBoxType      ObjectType = "DOCX_TEXT_BOX"
	DocxShapeType        ObjectType = "DOCX_SHAPE"
	DocxChartType        ObjectType = "DOCX_CHART"
	DocxCommentType      ObjectType = "DOCX_COMMENT"
	DocxRevisionType     ObjectType = "DOCX_REVISION"
	DocxFootnoteType     ObjectType = "DOCX_FOOTNOTE"
	DocxEndnoteType      ObjectType = "DOCX_ENDNOTE"
	// PPTX types
	PPTXDocumentType    ObjectType = "PPTX_DOCUMENT"
	PPTXSlideType       ObjectType = "PPTX_SLIDE"
	PPTXTextFrameType   ObjectType = "PPTX_TEXT_FRAME"
	PPTXParagraphType   ObjectType = "PPTX_PARAGRAPH"
	PPTXTextRunType     ObjectType = "PPTX_TEXT_RUN"
	PPTXShapeType       ObjectType = "PPTX_SHAPE"
	PPTXTableType       ObjectType = "PPTX_TABLE"
	PPTXTableCellType   ObjectType = "PPTX_TABLE_CELL"
	PPTXChartType       ObjectType = "PPTX_CHART"
	PPTXChartSeriesType ObjectType = "PPTX_CHART_SERIES"
	PPTXImageType       ObjectType = "PPTX_IMAGE"
	PPTXVideoType       ObjectType = "PPTX_VIDEO"
	PPTXAudioType       ObjectType = "PPTX_AUDIO"
	PPTXSlideLayoutType ObjectType = "PPTX_SLIDE_LAYOUT"
	PPTXSlideMasterType ObjectType = "PPTX_SLIDE_MASTER"
	PPTXThemeType       ObjectType = "PPTX_THEME"
	// PDF types
	PDFType         ObjectType = "PDF"
	PDFDocumentType ObjectType = "PDF_DOCUMENT"
	PDFPageType     ObjectType = "PDF_PAGE"
	PDFInfoType     ObjectType = "PDF_INFO"
)

Object types

const CompiledFunctionType ObjectType = "COMPILED_FUNCTION"

CompiledFunctionType is the type for compiled functions

const WebViewType ObjectType = "WEBVIEW"

WebViewType is the object type for WebView.

type Once added in v0.4.25

type Once struct {
	// contains filtered or unexported fields
}

Once wraps sync.Once for use in Xxlang

func NewOnce added in v0.4.25

func NewOnce() *Once

NewOnce creates a new Once

func (*Once) Do added in v0.4.25

func (o *Once) Do(fn func())

Do executes the function only once

func (*Once) HashKey added in v0.4.25

func (o *Once) HashKey() HashKey

func (*Once) Inspect added in v0.4.25

func (o *Once) Inspect() string

func (*Once) ToBool added in v0.4.25

func (o *Once) ToBool() *Bool

func (*Once) Type added in v0.4.25

func (o *Once) Type() ObjectType

Object interface implementation

func (*Once) TypeTag added in v0.4.25

func (o *Once) TypeTag() TypeTag

type OrderedMap added in v0.5.7

type OrderedMap struct {
	Pairs map[HashKey]int // HashKey -> index in orderSlice
	// contains filtered or unexported fields
}

OrderedMap represents a map that preserves insertion order of key-value pairs. It supports O(1) lookup via a hash map and ordered iteration via a slice.

func AcquireOrderedMap added in v0.5.7

func AcquireOrderedMap() *OrderedMap

AcquireOrderedMap gets an OrderedMap from the pool

func NewOrderedMap added in v0.5.7

func NewOrderedMap() *OrderedMap

NewOrderedMap creates a new empty OrderedMap

func NewOrderedMapWithCapacity added in v0.5.7

func NewOrderedMapWithCapacity(capacity int) *OrderedMap

NewOrderedMapWithCapacity creates a new OrderedMap with pre-allocated capacity

func (*OrderedMap) Clone added in v0.5.7

func (om *OrderedMap) Clone() *OrderedMap

Clone creates a deep copy of the OrderedMap

func (*OrderedMap) Delete added in v0.5.7

func (om *OrderedMap) Delete(key Object) bool

Delete removes a key-value pair. Returns true if the key was found and removed.

func (*OrderedMap) Get added in v0.5.7

func (om *OrderedMap) Get(key Object) Object

Get retrieves a value by key. Returns NULL if key not found.

func (*OrderedMap) GetAt added in v0.5.7

func (om *OrderedMap) GetAt(index int) (Object, Object, error)

GetAt returns the key-value pair at a specific index. Returns nil, nil, error if index is out of bounds.

func (*OrderedMap) GetIndex added in v0.5.7

func (om *OrderedMap) GetIndex(key Object) int

GetIndex returns the index of a key (0-based). Returns -1 if key not found.

func (*OrderedMap) GetOrderedKeys added in v0.5.7

func (om *OrderedMap) GetOrderedKeys() []Object

GetOrderedKeys returns keys in insertion order

func (*OrderedMap) GetOrderedPairs added in v0.5.7

func (om *OrderedMap) GetOrderedPairs() []Object

GetOrderedPairs returns key-value pairs as array of [key, value] arrays

func (*OrderedMap) GetOrderedValues added in v0.5.7

func (om *OrderedMap) GetOrderedValues() []Object

GetOrderedValues returns values in insertion order

func (*OrderedMap) HasKey added in v0.5.7

func (om *OrderedMap) HasKey(key Object) bool

HasKey checks if a key exists

func (*OrderedMap) HashKey added in v0.5.7

func (om *OrderedMap) HashKey() HashKey

HashKey returns an empty HashKey (OrderedMaps are not hashable)

func (*OrderedMap) InsertAt added in v0.5.7

func (om *OrderedMap) InsertAt(key Object, value Object, index int) error

InsertAt inserts a key-value pair at a specific index. If the key already exists, it updates the value and moves it to the new position. Returns error if index is out of bounds.

func (*OrderedMap) Inspect added in v0.5.7

func (om *OrderedMap) Inspect() string

Inspect returns a string representation of the OrderedMap

func (*OrderedMap) Len added in v0.5.7

func (om *OrderedMap) Len() int

Len returns the number of key-value pairs

func (*OrderedMap) MoveAfter added in v0.5.7

func (om *OrderedMap) MoveAfter(key1, key2 Object) error

MoveAfter moves key1 to the position immediately after key2. Returns error if either key is not found.

func (*OrderedMap) MoveBefore added in v0.5.7

func (om *OrderedMap) MoveBefore(key1, key2 Object) error

MoveBefore moves key1 to the position immediately before key2. Returns error if either key is not found.

func (*OrderedMap) MoveToBack added in v0.5.7

func (om *OrderedMap) MoveToBack(key Object) error

MoveToBack moves a key to the back (last position). Returns error if key not found.

func (*OrderedMap) MoveToFront added in v0.5.7

func (om *OrderedMap) MoveToFront(key Object) error

MoveToFront moves a key to the front (position 0). Returns error if key not found.

func (*OrderedMap) Reverse added in v0.5.7

func (om *OrderedMap) Reverse()

Reverse reverses the order of all elements

func (*OrderedMap) Set added in v0.5.7

func (om *OrderedMap) Set(key Object, value Object)

Set adds or updates a key-value pair. If the key exists, it updates the value but preserves the position. If the key is new, it appends to the end.

func (*OrderedMap) SetAt added in v0.5.7

func (om *OrderedMap) SetAt(index int, value Object) error

SetAt updates the value at a specific index. Returns error if index is out of bounds.

func (*OrderedMap) SortByKey added in v0.5.7

func (om *OrderedMap) SortByKey()

SortByKey sorts the map by key (alphabetically by string representation)

func (*OrderedMap) Swap added in v0.5.7

func (om *OrderedMap) Swap(key1, key2 Object) error

Swap swaps the positions of two keys. Returns error if either key is not found.

func (*OrderedMap) ToBool added in v0.5.7

func (om *OrderedMap) ToBool() *Bool

ToBool returns TRUE if the map has elements, FALSE otherwise

func (*OrderedMap) ToMap added in v0.5.7

func (om *OrderedMap) ToMap() *Map

ToMap converts the OrderedMap to a regular Map

func (*OrderedMap) Type added in v0.5.7

func (om *OrderedMap) Type() ObjectType

Type returns the object type

func (*OrderedMap) TypeTag added in v0.5.7

func (om *OrderedMap) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type OrderedMapPair added in v0.5.7

type OrderedMapPair struct {
	Key   Object
	Value Object
}

OrderedMapPair represents a key-value pair in an OrderedMap

type PDF added in v0.5.7

type PDF struct {

	// Source information
	FilePath string    // Original file path (may be empty if from bytes)
	Source   []byte    // Raw PDF data
	Modified time.Time // Last modification time

	// Parsed structure
	Version   string            // PDF version (e.g., "1.4")
	Objects   map[int64]*PDFObj // Parsed PDF objects by object number
	XRefTable *PDFXRefTable     // Cross-reference table
	Trailer   *PDFDict          // Trailer dictionary
	RootObj   int64             // Root object number (Catalog)
	InfoObj   int64             // Info object number (metadata)
	PageCount int               // Number of pages
	Pages     []*PDFPage        // Cached page objects

	// State
	IsOpen     bool // Whether the PDF is currently open
	IsModified bool // Whether modifications have been made
	// contains filtered or unexported fields
}

PDF represents an opened PDF file for reading and manipulation. It holds the parsed PDF structure and provides methods for extracting text, getting page info, and performing operations.

func NewPDF added in v0.5.7

func NewPDF(data []byte, filePath string) *PDF

NewPDF creates a new PDF object from file data.

func NewPDFFromBytes added in v0.5.7

func NewPDFFromBytes(data []byte) (*PDF, error)

NewPDFFromBytes creates a PDF object from byte data.

func NewPDFFromFile added in v0.5.7

func NewPDFFromFile(filePath string) (*PDF, error)

NewPDFFromFile creates a PDF object from a file path.

func (*PDF) Close added in v0.5.7

func (p *PDF) Close() Object

Close closes the PDF and releases resources.

func (*PDF) ExtractAllText added in v0.5.7

func (p *PDF) ExtractAllText() Object

ExtractAllText extracts text from all pages.

func (*PDF) ExtractText added in v0.5.7

func (p *PDF) ExtractText(pageIndex int) Object

ExtractText extracts text from a specific page.

func (*PDF) GetInfo added in v0.5.7

func (p *PDF) GetInfo() *PDFInfo

GetInfo returns the document information.

func (*PDF) GetMember added in v0.5.7

func (p *PDF) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*PDF) GetPage added in v0.5.7

func (p *PDF) GetPage(index int) Object

GetPage returns a page by index.

func (*PDF) HashKey added in v0.5.7

func (p *PDF) HashKey() HashKey

HashKey returns a hash key for the PDF object.

func (*PDF) Inspect added in v0.5.7

func (p *PDF) Inspect() string

Inspect returns a string representation of the PDF object.

func (*PDF) Parse added in v0.5.7

func (p *PDF) Parse() error

Parse parses the PDF structure.

func (*PDF) RotatePage added in v0.5.7

func (p *PDF) RotatePage(pageIndex int, angle int) Object

RotatePage rotates a page by the specified angle.

func (*PDF) SaveAs added in v0.5.7

func (p *PDF) SaveAs(filePath string) Object

SaveAs saves the PDF to a file.

func (*PDF) ToBool added in v0.5.7

func (p *PDF) ToBool() *Bool

ToBool returns true if the PDF is open.

func (*PDF) ToBytes added in v0.5.7

func (p *PDF) ToBytes() Object

ToBytes returns the PDF as a byte array.

func (*PDF) Type added in v0.5.7

func (p *PDF) Type() ObjectType

Type returns the object type.

func (*PDF) TypeTag added in v0.5.7

func (p *PDF) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type PDFArray added in v0.5.7

type PDFArray struct {
	Elements []interface{}
}

PDFArray represents a PDF array object.

type PDFDict added in v0.5.7

type PDFDict struct {
	Entries map[string]interface{}
}

PDFDict represents a PDF dictionary object.

type PDFDocument added in v0.5.7

type PDFDocument struct {

	// Document properties
	Version  string // PDF version (default "1.4")
	Title    string
	Author   string
	Subject  string
	Creator  string
	Producer string

	// Pages
	Pages []*PDFPageData // Page data for new document

	// Object tracking
	NextObjNum int64         // Next object number to assign
	Objects    []interface{} // Objects to write

	// Font settings
	DefaultFont string  // Default font name
	FontSize    float64 // Default font size
	// contains filtered or unexported fields
}

PDFDocument represents a new PDF document being created. Use this to create PDFs from scratch with text and pages.

func NewPDFDocument added in v0.5.7

func NewPDFDocument() *PDFDocument

NewPDFDocument creates a new PDF document.

func (*PDFDocument) AddPage added in v0.5.7

func (d *PDFDocument) AddPage(width, height float64) Object

AddPage adds a new page to the document.

func (*PDFDocument) GetMember added in v0.5.7

func (d *PDFDocument) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*PDFDocument) HashKey added in v0.5.7

func (d *PDFDocument) HashKey() HashKey

HashKey returns a hash key.

func (*PDFDocument) Inspect added in v0.5.7

func (d *PDFDocument) Inspect() string

Inspect returns a string representation.

func (*PDFDocument) Save added in v0.5.7

func (d *PDFDocument) Save(filePath string) Object

Save saves the document to a file.

func (*PDFDocument) SetFont added in v0.5.7

func (d *PDFDocument) SetFont(name string, size float64) Object

SetFont sets the default font and size.

func (*PDFDocument) ToBool added in v0.5.7

func (d *PDFDocument) ToBool() *Bool

ToBool always returns true.

func (*PDFDocument) ToBytes added in v0.5.7

func (d *PDFDocument) ToBytes() Object

ToBytes returns the document as a byte array.

func (*PDFDocument) Type added in v0.5.7

func (d *PDFDocument) Type() ObjectType

Type returns the object type.

func (*PDFDocument) TypeTag added in v0.5.7

func (d *PDFDocument) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

func (*PDFDocument) WriteText added in v0.5.7

func (d *PDFDocument) WriteText(pageIndex int, text string, x, y float64, opts map[string]interface{}) Object

WriteText writes text to a page.

type PDFHexStr added in v0.5.7

type PDFHexStr string

PDFHexStr represents a PDF hexadecimal string.

type PDFInfo added in v0.5.7

type PDFInfo struct {
	Title        string
	Author       string
	Subject      string
	Keywords     string
	Creator      string
	Producer     string
	CreationDate string
	ModDate      string
	PageCount    int
	Version      string
	Encrypted    bool
	FileSize     int64
}

PDFInfo contains metadata information about a PDF document.

func (*PDFInfo) GetMember added in v0.5.7

func (i *PDFInfo) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*PDFInfo) HashKey added in v0.5.7

func (i *PDFInfo) HashKey() HashKey

HashKey returns a hash key.

func (*PDFInfo) Inspect added in v0.5.7

func (i *PDFInfo) Inspect() string

Inspect returns a string representation.

func (*PDFInfo) ToBool added in v0.5.7

func (i *PDFInfo) ToBool() *Bool

ToBool always returns true.

func (*PDFInfo) Type added in v0.5.7

func (i *PDFInfo) Type() ObjectType

Type returns the object type.

func (*PDFInfo) TypeTag added in v0.5.7

func (i *PDFInfo) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type PDFName added in v0.5.7

type PDFName string

PDFName represents a PDF name object.

type PDFObj added in v0.5.7

type PDFObj struct {
	Number     int64       // Object number
	Generation int64       // Generation number
	Value      interface{} // The actual value (PDFDict, PDFArray, PDFStream, etc.)
	Offset     int64       // Byte offset in file (for reference)
}

PDFObj represents a parsed PDF object.

type PDFPage added in v0.5.7

type PDFPage struct {

	// Parent reference
	PDF     *PDF // Reference to parent PDF
	PageNum int  // Page number (0-indexed)

	// Page properties from PDF
	Width     float64   // Page width in points
	Height    float64   // Page height in points
	Rotation  int       // Page rotation (0, 90, 180, 270)
	MediaBox  *PDFArray // MediaBox array
	CropBox   *PDFArray // CropBox array (optional)
	Contents  []int64   // Content stream object numbers
	Resources *PDFDict  // Page resources dictionary

	// Cached content
	Text   string // Cached extracted text
	Parsed bool   // Whether content has been parsed
	// contains filtered or unexported fields
}

PDFPage represents a page in an existing PDF document. It provides methods for extracting content and getting page properties.

func (*PDFPage) ExtractText added in v0.5.7

func (pg *PDFPage) ExtractText() Object

ExtractText extracts text from the page.

func (*PDFPage) GetMember added in v0.5.7

func (pg *PDFPage) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*PDFPage) HashKey added in v0.5.7

func (pg *PDFPage) HashKey() HashKey

HashKey returns a hash key.

func (*PDFPage) Inspect added in v0.5.7

func (pg *PDFPage) Inspect() string

Inspect returns a string representation.

func (*PDFPage) ToBool added in v0.5.7

func (pg *PDFPage) ToBool() *Bool

ToBool always returns true.

func (*PDFPage) Type added in v0.5.7

func (pg *PDFPage) Type() ObjectType

Type returns the object type.

func (*PDFPage) TypeTag added in v0.5.7

func (pg *PDFPage) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type PDFPageData added in v0.5.7

type PDFPageData struct {
	Width     float64
	Height    float64
	Contents  *strings.Builder // Content stream
	Resources map[string]interface{}
	Rotation  int
}

PDFPageData represents a page in a PDFDocument being created.

type PDFRef added in v0.5.7

type PDFRef struct {
	ObjectNum  int64
	Generation int64
}

PDFRef represents an indirect object reference.

type PDFStream added in v0.5.7

type PDFStream struct {
	Dict    *PDFDict
	Data    []byte
	RawData []byte // Uncompressed data
}

PDFStream represents a PDF stream object.

type PDFString added in v0.5.7

type PDFString string

PDFString represents a PDF string object.

type PDFXRefEntry added in v0.5.7

type PDFXRefEntry struct {
	Type       int   // 0 = free, 1 = in-use, 2 = compressed
	Offset     int64 // Byte offset (type 1) or object stream number (type 2)
	Generation int64 // Generation number
	Index      int   // Index within object stream (type 2 only)
}

PDFXRefEntry represents an entry in the cross-reference table.

type PDFXRefTable added in v0.5.7

type PDFXRefTable struct {
	Entries map[int64]*PDFXRefEntry
}

PDFXRefTable represents the cross-reference table.

type PPTXAudio added in v0.5.7

type PPTXAudio struct {
	// contains filtered or unexported fields
}

PPTXAudio represents an audio on a slide.

func (*PPTXAudio) GetData added in v0.5.7

func (a *PPTXAudio) GetData() []byte

GetData returns the audio data.

func (*PPTXAudio) GetFormat added in v0.5.7

func (a *PPTXAudio) GetFormat() string

GetFormat returns the audio format.

func (*PPTXAudio) GetPosition added in v0.5.7

func (a *PPTXAudio) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXAudio) HashKey added in v0.5.7

func (a *PPTXAudio) HashKey() HashKey

func (*PPTXAudio) Inspect added in v0.5.7

func (a *PPTXAudio) Inspect() string

func (*PPTXAudio) Save added in v0.5.7

func (a *PPTXAudio) Save(path string) error

Save saves the audio to a file.

func (*PPTXAudio) SetPosition added in v0.5.7

func (a *PPTXAudio) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXAudio) ToBool added in v0.5.7

func (a *PPTXAudio) ToBool() *Bool

func (*PPTXAudio) Type added in v0.5.7

func (a *PPTXAudio) Type() ObjectType

Type implementations for PPTXAudio

func (*PPTXAudio) TypeTag added in v0.5.7

func (a *PPTXAudio) TypeTag() TypeTag

type PPTXBulletStyle added in v0.5.7

type PPTXBulletStyle struct {
	Type    string // "bullet", "numbered", "none"
	Char    string // bullet character
	StartAt int    // starting number for numbered lists
	Font    PPTXFont
	Color   PPTXColor
}

PPTXBulletStyle represents bullet/numbering style.

type PPTXCellStyle added in v0.5.7

type PPTXCellStyle struct {
	Fill        *PPTXColor
	BorderColor *PPTXColor
	BorderWidth int64
	Font        PPTXFont
	Alignment   string
	Vertical    string
}

PPTXCellStyle represents table cell styling.

type PPTXChart added in v0.5.7

type PPTXChart struct {
	// contains filtered or unexported fields
}

PPTXChart represents a chart on a slide.

func (*PPTXChart) GetKind added in v0.5.7

func (c *PPTXChart) GetKind() PPTXChartKind

GetKind returns the chart kind.

func (*PPTXChart) GetPosition added in v0.5.7

func (c *PPTXChart) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXChart) GetSeries added in v0.5.7

func (c *PPTXChart) GetSeries() []*PPTXChartSeries

GetSeries returns all series.

func (*PPTXChart) GetSeriesCount added in v0.5.7

func (c *PPTXChart) GetSeriesCount() int

GetSeriesCount returns the number of series.

func (*PPTXChart) GetSize added in v0.5.7

func (c *PPTXChart) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXChart) GetTitle added in v0.5.7

func (c *PPTXChart) GetTitle() string

GetTitle returns the chart title.

func (*PPTXChart) HashKey added in v0.5.7

func (c *PPTXChart) HashKey() HashKey

func (*PPTXChart) Inspect added in v0.5.7

func (c *PPTXChart) Inspect() string

func (*PPTXChart) SetPosition added in v0.5.7

func (c *PPTXChart) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXChart) SetSize added in v0.5.7

func (c *PPTXChart) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXChart) SetTitle added in v0.5.7

func (c *PPTXChart) SetTitle(title string)

SetTitle sets the chart title.

func (*PPTXChart) ToBool added in v0.5.7

func (c *PPTXChart) ToBool() *Bool

func (*PPTXChart) Type added in v0.5.7

func (c *PPTXChart) Type() ObjectType

Type implementations for PPTXChart

func (*PPTXChart) TypeTag added in v0.5.7

func (c *PPTXChart) TypeTag() TypeTag

type PPTXChartData added in v0.5.7

type PPTXChartData struct {
	// contains filtered or unexported fields
}

PPTXChartData represents chart data.

type PPTXChartKind added in v0.5.7

type PPTXChartKind string

PPTXChartKind defines chart types.

const (
	PPTXChartBar        PPTXChartKind = "bar"
	PPTXChartBarStacked PPTXChartKind = "barStacked"
	PPTXChartColumn     PPTXChartKind = "column"
	PPTXChartLine       PPTXChartKind = "line"
	PPTXChartPie        PPTXChartKind = "pie"
	PPTXChartArea       PPTXChartKind = "area"
	PPTXChartScatter    PPTXChartKind = "scatter"
	PPTXChartRadar      PPTXChartKind = "radar"
	PPTXChartCombo      PPTXChartKind = "combo"
)

type PPTXChartSeries added in v0.5.7

type PPTXChartSeries struct {
	// contains filtered or unexported fields
}

PPTXChartSeries represents a data series in a chart.

func (*PPTXChartSeries) GetName added in v0.5.7

func (s *PPTXChartSeries) GetName() string

GetName returns the series name.

func (*PPTXChartSeries) GetValues added in v0.5.7

func (s *PPTXChartSeries) GetValues() []float64

GetValues returns the values.

func (*PPTXChartSeries) HashKey added in v0.5.7

func (s *PPTXChartSeries) HashKey() HashKey

func (*PPTXChartSeries) Inspect added in v0.5.7

func (s *PPTXChartSeries) Inspect() string

func (*PPTXChartSeries) SetName added in v0.5.7

func (s *PPTXChartSeries) SetName(name string)

SetName sets the series name.

func (*PPTXChartSeries) SetValues added in v0.5.7

func (s *PPTXChartSeries) SetValues(values []float64)

SetValues sets the values.

func (*PPTXChartSeries) ToBool added in v0.5.7

func (s *PPTXChartSeries) ToBool() *Bool

func (*PPTXChartSeries) Type added in v0.5.7

func (s *PPTXChartSeries) Type() ObjectType

Type implementations for PPTXChartSeries

func (*PPTXChartSeries) TypeTag added in v0.5.7

func (s *PPTXChartSeries) TypeTag() TypeTag

type PPTXChartSeriesData added in v0.5.7

type PPTXChartSeriesData struct {
	Name   string
	Values []float64
}

PPTXChartSeriesData represents a data series input.

type PPTXChartStyle added in v0.5.7

type PPTXChartStyle struct {
	// contains filtered or unexported fields
}

PPTXChartStyle represents chart styling.

type PPTXColor added in v0.5.7

type PPTXColor struct {
	R, G, B uint8
}

PPTXColor represents RGB color.

type PPTXDocument added in v0.5.7

type PPTXDocument struct {
	// contains filtered or unexported fields
}

PPTXDocument represents a PowerPoint presentation. A .pptx file is a ZIP archive containing XML files.

func NewPPTX added in v0.5.7

func NewPPTX() *PPTXDocument

NewPPTX creates a new empty presentation.

func OpenPPTX added in v0.5.7

func OpenPPTX(path string) (*PPTXDocument, error)

OpenPPTX opens an existing PPTX file from a file path.

func OpenPPTXFromBytes added in v0.5.7

func OpenPPTXFromBytes(data []byte) (*PPTXDocument, error)

OpenPPTXFromBytes opens a PPTX presentation from a byte slice.

func (*PPTXDocument) AddSlide added in v0.5.7

func (d *PPTXDocument) AddSlide() *PPTXSlide

AddSlide adds a new slide to the presentation.

func (*PPTXDocument) Close added in v0.5.7

func (d *PPTXDocument) Close() error

Close closes the document and releases resources.

func (*PPTXDocument) DeleteSlide added in v0.5.7

func (d *PPTXDocument) DeleteSlide(index int) bool

DeleteSlide deletes a slide by index (1-based).

func (*PPTXDocument) DuplicateSlide added in v0.5.7

func (d *PPTXDocument) DuplicateSlide(index int) *PPTXSlide

DuplicateSlide creates a copy of a slide.

func (*PPTXDocument) GetProperties added in v0.5.7

func (d *PPTXDocument) GetProperties() *PPTXProperties

GetProperties returns the document properties.

func (*PPTXDocument) GetSlide added in v0.5.7

func (d *PPTXDocument) GetSlide(index int) *PPTXSlide

GetSlide returns a slide by index (1-based).

func (*PPTXDocument) GetSlideCount added in v0.5.7

func (d *PPTXDocument) GetSlideCount() int

GetSlideCount returns the number of slides.

func (*PPTXDocument) GetSlides added in v0.5.7

func (d *PPTXDocument) GetSlides() []*PPTXSlide

GetSlides returns all slides.

func (*PPTXDocument) HashKey added in v0.5.7

func (d *PPTXDocument) HashKey() HashKey

func (*PPTXDocument) Inspect added in v0.5.7

func (d *PPTXDocument) Inspect() string

func (*PPTXDocument) MoveSlide added in v0.5.7

func (d *PPTXDocument) MoveSlide(from, to int) bool

MoveSlide moves a slide from one position to another.

func (*PPTXDocument) Save added in v0.5.7

func (d *PPTXDocument) Save(path string) error

Save saves the document to a file.

func (*PPTXDocument) SetProperties added in v0.5.7

func (d *PPTXDocument) SetProperties(props *PPTXProperties)

SetProperties sets the document properties.

func (*PPTXDocument) ToBool added in v0.5.7

func (d *PPTXDocument) ToBool() *Bool

func (*PPTXDocument) ToBytes added in v0.5.7

func (d *PPTXDocument) ToBytes() ([]byte, error)

ToBytes converts the document to a byte slice.

func (*PPTXDocument) Type added in v0.5.7

func (d *PPTXDocument) Type() ObjectType

func (*PPTXDocument) TypeTag added in v0.5.7

func (d *PPTXDocument) TypeTag() TypeTag

type PPTXFont added in v0.5.7

type PPTXFont struct {
	Name   string
	Size   int // in points
	Bold   bool
	Italic bool
}

PPTXFont represents font properties.

type PPTXFormatScheme added in v0.5.7

type PPTXFormatScheme struct {
	// contains filtered or unexported fields
}

PPTXFormatScheme defines format scheme.

type PPTXGradient added in v0.5.7

type PPTXGradient struct {
	// contains filtered or unexported fields
}

PPTXGradient represents gradient fill.

type PPTXImage added in v0.5.7

type PPTXImage struct {
	// contains filtered or unexported fields
}

PPTXImage represents an image on a slide.

func (*PPTXImage) GetData added in v0.5.7

func (i *PPTXImage) GetData() []byte

GetData returns the image data.

func (*PPTXImage) GetDataBase64 added in v0.5.7

func (i *PPTXImage) GetDataBase64() string

GetDataBase64 returns the image data as base64.

func (*PPTXImage) GetFormat added in v0.5.7

func (i *PPTXImage) GetFormat() string

GetFormat returns the image format.

func (*PPTXImage) GetPosition added in v0.5.7

func (i *PPTXImage) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXImage) GetSize added in v0.5.7

func (i *PPTXImage) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXImage) HashKey added in v0.5.7

func (i *PPTXImage) HashKey() HashKey

func (*PPTXImage) Inspect added in v0.5.7

func (i *PPTXImage) Inspect() string

func (*PPTXImage) Save added in v0.5.7

func (i *PPTXImage) Save(path string) error

Save saves the image to a file.

func (*PPTXImage) SetPosition added in v0.5.7

func (i *PPTXImage) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXImage) SetSize added in v0.5.7

func (i *PPTXImage) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXImage) ToBool added in v0.5.7

func (i *PPTXImage) ToBool() *Bool

func (*PPTXImage) Type added in v0.5.7

func (i *PPTXImage) Type() ObjectType

Type implementations for PPTXImage

func (*PPTXImage) TypeTag added in v0.5.7

func (i *PPTXImage) TypeTag() TypeTag

type PPTXParagraph added in v0.5.7

type PPTXParagraph struct {
	// contains filtered or unexported fields
}

PPTXParagraph represents a paragraph within a text frame.

func (*PPTXParagraph) GetAlignment added in v0.5.7

func (p *PPTXParagraph) GetAlignment() string

GetAlignment returns the alignment.

func (*PPTXParagraph) GetRuns added in v0.5.7

func (p *PPTXParagraph) GetRuns() []*PPTXTextRun

GetRuns returns all text runs.

func (*PPTXParagraph) GetText added in v0.5.7

func (p *PPTXParagraph) GetText() string

GetText returns the text content.

func (*PPTXParagraph) HashKey added in v0.5.7

func (p *PPTXParagraph) HashKey() HashKey

func (*PPTXParagraph) Inspect added in v0.5.7

func (p *PPTXParagraph) Inspect() string

func (*PPTXParagraph) SetAlignment added in v0.5.7

func (p *PPTXParagraph) SetAlignment(align string)

SetAlignment sets the alignment.

func (*PPTXParagraph) ToBool added in v0.5.7

func (p *PPTXParagraph) ToBool() *Bool

func (*PPTXParagraph) Type added in v0.5.7

func (p *PPTXParagraph) Type() ObjectType

Type implementations for PPTXParagraph

func (*PPTXParagraph) TypeTag added in v0.5.7

func (p *PPTXParagraph) TypeTag() TypeTag

type PPTXPosition added in v0.5.7

type PPTXPosition struct {
	X int64 // left position in EMUs
	Y int64 // top position in EMUs
}

PPTXPosition represents element position in EMUs (English Metric Units).

type PPTXProperties added in v0.5.7

type PPTXProperties struct {
	Title       string
	Subject     string
	Author      string
	Keywords    string
	Description string
	Created     string
	Modified    string
	LastModBy   string
	Revision    int
	Category    string
	Company     string
}

PPTXProperties holds document metadata.

type PPTXShadow added in v0.5.7

type PPTXShadow struct {
	Type     string
	Color    PPTXColor
	Blur     int64
	Distance int64
	Angle    int
}

PPTXShadow represents shadow effect.

type PPTXShape added in v0.5.7

type PPTXShape struct {
	// contains filtered or unexported fields
}

PPTXShape represents a shape on a slide.

func (*PPTXShape) AddTextFrame added in v0.5.7

func (s *PPTXShape) AddTextFrame(text string) *PPTXTextFrame

AddTextFrame adds a text frame to the shape.

func (*PPTXShape) GetFill added in v0.5.7

func (s *PPTXShape) GetFill() *PPTXColor

GetFill returns the fill color.

func (*PPTXShape) GetKind added in v0.5.7

func (s *PPTXShape) GetKind() PPTXShapeKind

GetKind returns the shape kind.

func (*PPTXShape) GetPosition added in v0.5.7

func (s *PPTXShape) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXShape) GetSize added in v0.5.7

func (s *PPTXShape) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXShape) GetTextFrame added in v0.5.7

func (s *PPTXShape) GetTextFrame() *PPTXTextFrame

GetTextFrame returns the text frame.

func (*PPTXShape) HashKey added in v0.5.7

func (s *PPTXShape) HashKey() HashKey

func (*PPTXShape) Inspect added in v0.5.7

func (s *PPTXShape) Inspect() string

func (*PPTXShape) SetFill added in v0.5.7

func (s *PPTXShape) SetFill(color string)

SetFill sets the fill color.

func (*PPTXShape) SetPosition added in v0.5.7

func (s *PPTXShape) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXShape) SetSize added in v0.5.7

func (s *PPTXShape) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXShape) ToBool added in v0.5.7

func (s *PPTXShape) ToBool() *Bool

func (*PPTXShape) Type added in v0.5.7

func (s *PPTXShape) Type() ObjectType

Type implementations for PPTXShape

func (*PPTXShape) TypeTag added in v0.5.7

func (s *PPTXShape) TypeTag() TypeTag

type PPTXShapeKind added in v0.5.7

type PPTXShapeKind string

PPTXShapeKind defines shape types.

const (
	PPTXShapeRectangle PPTXShapeKind = "rect"
	PPTXShapeOval      PPTXShapeKind = "ellipse"
	PPTXShapeRoundRect PPTXShapeKind = "roundRect"
	PPTXShapeTriangle  PPTXShapeKind = "triangle"
	PPTXShapeLine      PPTXShapeKind = "line"
	PPTXShapeArrow     PPTXShapeKind = "arrow"
	PPTXShapeTextBox   PPTXShapeKind = "textBox"
	PPTXShapePicture   PPTXShapeKind = "picture"
)

type PPTXShapeStyle added in v0.5.7

type PPTXShapeStyle struct {
	Fill             *PPTXColor
	FillTransparency float64
	BorderColor      *PPTXColor
	BorderWidth      int64
	BorderStyle      string // "solid", "dashed", "none"
	Shadow           *PPTXShadow
}

PPTXShapeStyle represents shape styling.

type PPTXSize added in v0.5.7

type PPTXSize struct {
	Width  int64
	Height int64
}

PPTXSize represents element dimensions in EMUs.

type PPTXSlide added in v0.5.7

type PPTXSlide struct {
	// contains filtered or unexported fields
}

PPTXSlide represents a single slide in a presentation.

func (*PPTXSlide) AddChart added in v0.5.7

func (s *PPTXSlide) AddChart(chartKind PPTXChartKind, data PPTXChartData, options map[string]interface{}) *PPTXChart

AddChart adds a chart to the slide.

func (*PPTXSlide) AddImage added in v0.5.7

func (s *PPTXSlide) AddImage(path string, options map[string]interface{}) *PPTXImage

AddImage adds an image to the slide from a file.

func (*PPTXSlide) AddImageFromBytes added in v0.5.7

func (s *PPTXSlide) AddImageFromBytes(data []byte, format string, options map[string]interface{}) *PPTXImage

AddImageFromBytes adds an image to the slide from byte data.

func (*PPTXSlide) AddShape added in v0.5.7

func (s *PPTXSlide) AddShape(shapeKind PPTXShapeKind, options map[string]interface{}) *PPTXShape

AddShape adds a shape to the slide.

func (*PPTXSlide) AddTable added in v0.5.7

func (s *PPTXSlide) AddTable(rows, cols int, options map[string]interface{}) *PPTXTable

AddTable adds a table to the slide.

func (*PPTXSlide) AddText added in v0.5.7

func (s *PPTXSlide) AddText(text string, options map[string]interface{}) *PPTXTextFrame

AddText adds a text frame to the slide.

func (*PPTXSlide) GetAllText added in v0.5.7

func (s *PPTXSlide) GetAllText() string

GetAllText returns all text content combined.

func (*PPTXSlide) GetCharts added in v0.5.7

func (s *PPTXSlide) GetCharts() []*PPTXChart

GetCharts returns all charts on the slide.

func (*PPTXSlide) GetImages added in v0.5.7

func (s *PPTXSlide) GetImages() []*PPTXImage

GetImages returns all images on the slide.

func (*PPTXSlide) GetIndex added in v0.5.7

func (s *PPTXSlide) GetIndex() int

GetIndex returns the slide index (1-based).

func (*PPTXSlide) GetNotes added in v0.5.7

func (s *PPTXSlide) GetNotes() string

GetNotes returns the speaker notes.

func (*PPTXSlide) GetShapes added in v0.5.7

func (s *PPTXSlide) GetShapes() []*PPTXShape

GetShapes returns all shapes on the slide.

func (*PPTXSlide) GetTables added in v0.5.7

func (s *PPTXSlide) GetTables() []*PPTXTable

GetTables returns all tables on the slide.

func (*PPTXSlide) GetTexts added in v0.5.7

func (s *PPTXSlide) GetTexts() []*PPTXTextFrame

GetTexts returns all text frames on the slide.

func (*PPTXSlide) HashKey added in v0.5.7

func (s *PPTXSlide) HashKey() HashKey

func (*PPTXSlide) Inspect added in v0.5.7

func (s *PPTXSlide) Inspect() string

func (*PPTXSlide) SetNotes added in v0.5.7

func (s *PPTXSlide) SetNotes(text string)

SetNotes sets the speaker notes.

func (*PPTXSlide) ToBool added in v0.5.7

func (s *PPTXSlide) ToBool() *Bool

func (*PPTXSlide) Type added in v0.5.7

func (s *PPTXSlide) Type() ObjectType

Type implementations for PPTXSlide

func (*PPTXSlide) TypeTag added in v0.5.7

func (s *PPTXSlide) TypeTag() TypeTag

type PPTXSlideBackground added in v0.5.7

type PPTXSlideBackground struct {
	// contains filtered or unexported fields
}

PPTXSlideBackground represents slide background.

type PPTXSlideLayout added in v0.5.7

type PPTXSlideLayout struct {
	// contains filtered or unexported fields
}

PPTXSlideLayout represents a slide layout template.

func (*PPTXSlideLayout) HashKey added in v0.5.7

func (l *PPTXSlideLayout) HashKey() HashKey

func (*PPTXSlideLayout) Inspect added in v0.5.7

func (l *PPTXSlideLayout) Inspect() string

func (*PPTXSlideLayout) ToBool added in v0.5.7

func (l *PPTXSlideLayout) ToBool() *Bool

func (*PPTXSlideLayout) Type added in v0.5.7

func (l *PPTXSlideLayout) Type() ObjectType

Type implementations for PPTXSlideLayout

func (*PPTXSlideLayout) TypeTag added in v0.5.7

func (l *PPTXSlideLayout) TypeTag() TypeTag

type PPTXSlideMaster added in v0.5.7

type PPTXSlideMaster struct {
	// contains filtered or unexported fields
}

PPTXSlideMaster represents a slide master.

func (*PPTXSlideMaster) HashKey added in v0.5.7

func (m *PPTXSlideMaster) HashKey() HashKey

func (*PPTXSlideMaster) Inspect added in v0.5.7

func (m *PPTXSlideMaster) Inspect() string

func (*PPTXSlideMaster) ToBool added in v0.5.7

func (m *PPTXSlideMaster) ToBool() *Bool

func (*PPTXSlideMaster) Type added in v0.5.7

func (m *PPTXSlideMaster) Type() ObjectType

Type implementations for PPTXSlideMaster

func (*PPTXSlideMaster) TypeTag added in v0.5.7

func (m *PPTXSlideMaster) TypeTag() TypeTag

type PPTXTable added in v0.5.7

type PPTXTable struct {
	// contains filtered or unexported fields
}

PPTXTable represents a table on a slide.

func (*PPTXTable) GetCell added in v0.5.7

func (t *PPTXTable) GetCell(row, col int) *PPTXTableCell

GetCell returns a cell by row and column (1-based).

func (*PPTXTable) GetColCount added in v0.5.7

func (t *PPTXTable) GetColCount() int

GetColCount returns the number of columns.

func (*PPTXTable) GetPosition added in v0.5.7

func (t *PPTXTable) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXTable) GetRowCount added in v0.5.7

func (t *PPTXTable) GetRowCount() int

GetRowCount returns the number of rows.

func (*PPTXTable) GetSize added in v0.5.7

func (t *PPTXTable) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXTable) GetValue added in v0.5.7

func (t *PPTXTable) GetValue(row, col int) string

GetValue returns a cell value.

func (*PPTXTable) HashKey added in v0.5.7

func (t *PPTXTable) HashKey() HashKey

func (*PPTXTable) Inspect added in v0.5.7

func (t *PPTXTable) Inspect() string

func (*PPTXTable) SetPosition added in v0.5.7

func (t *PPTXTable) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXTable) SetSize added in v0.5.7

func (t *PPTXTable) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXTable) SetValue added in v0.5.7

func (t *PPTXTable) SetValue(row, col int, value string)

SetValue sets a cell value.

func (*PPTXTable) ToBool added in v0.5.7

func (t *PPTXTable) ToBool() *Bool

func (*PPTXTable) Type added in v0.5.7

func (t *PPTXTable) Type() ObjectType

Type implementations for PPTXTable

func (*PPTXTable) TypeTag added in v0.5.7

func (t *PPTXTable) TypeTag() TypeTag

type PPTXTableCell added in v0.5.7

type PPTXTableCell struct {
	// contains filtered or unexported fields
}

PPTXTableCell represents a table cell.

func (*PPTXTableCell) HashKey added in v0.5.7

func (c *PPTXTableCell) HashKey() HashKey

func (*PPTXTableCell) Inspect added in v0.5.7

func (c *PPTXTableCell) Inspect() string

func (*PPTXTableCell) ToBool added in v0.5.7

func (c *PPTXTableCell) ToBool() *Bool

func (*PPTXTableCell) Type added in v0.5.7

func (c *PPTXTableCell) Type() ObjectType

Type implementations for PPTXTableCell

func (*PPTXTableCell) TypeTag added in v0.5.7

func (c *PPTXTableCell) TypeTag() TypeTag

type PPTXTableStyle added in v0.5.7

type PPTXTableStyle struct {
	HeaderRow PPTXCellStyle
	TotalRow  PPTXCellStyle
	FirstCol  PPTXCellStyle
	LastCol   PPTXCellStyle
	BandRow   bool
	BandCol   bool
}

PPTXTableStyle represents table styling.

type PPTXTextFrame added in v0.5.7

type PPTXTextFrame struct {
	// contains filtered or unexported fields
}

PPTXTextFrame represents a text box on a slide.

func (*PPTXTextFrame) GetParagraphs added in v0.5.7

func (tf *PPTXTextFrame) GetParagraphs() []*PPTXParagraph

GetParagraphs returns all paragraphs.

func (*PPTXTextFrame) GetPosition added in v0.5.7

func (tf *PPTXTextFrame) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXTextFrame) GetSize added in v0.5.7

func (tf *PPTXTextFrame) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXTextFrame) GetText added in v0.5.7

func (tf *PPTXTextFrame) GetText() string

GetText returns the text content.

func (*PPTXTextFrame) HashKey added in v0.5.7

func (tf *PPTXTextFrame) HashKey() HashKey

func (*PPTXTextFrame) Inspect added in v0.5.7

func (tf *PPTXTextFrame) Inspect() string

func (*PPTXTextFrame) SetPosition added in v0.5.7

func (tf *PPTXTextFrame) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXTextFrame) SetSize added in v0.5.7

func (tf *PPTXTextFrame) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXTextFrame) SetText added in v0.5.7

func (tf *PPTXTextFrame) SetText(text string)

SetText sets the text content.

func (*PPTXTextFrame) ToBool added in v0.5.7

func (tf *PPTXTextFrame) ToBool() *Bool

func (*PPTXTextFrame) Type added in v0.5.7

func (tf *PPTXTextFrame) Type() ObjectType

Type implementations for PPTXTextFrame

func (*PPTXTextFrame) TypeTag added in v0.5.7

func (tf *PPTXTextFrame) TypeTag() TypeTag

type PPTXTextRun added in v0.5.7

type PPTXTextRun struct {
	// contains filtered or unexported fields
}

PPTXTextRun represents a text run with uniform formatting.

func (*PPTXTextRun) GetColor added in v0.5.7

func (r *PPTXTextRun) GetColor() string

GetColor returns the color as hex string.

func (*PPTXTextRun) GetFontName added in v0.5.7

func (r *PPTXTextRun) GetFontName() string

GetFontName returns the font name.

func (*PPTXTextRun) GetFontSize added in v0.5.7

func (r *PPTXTextRun) GetFontSize() int

GetFontSize returns the font size.

func (*PPTXTextRun) GetText added in v0.5.7

func (r *PPTXTextRun) GetText() string

GetText returns the text content.

func (*PPTXTextRun) HashKey added in v0.5.7

func (r *PPTXTextRun) HashKey() HashKey

func (*PPTXTextRun) Inspect added in v0.5.7

func (r *PPTXTextRun) Inspect() string

func (*PPTXTextRun) IsBold added in v0.5.7

func (r *PPTXTextRun) IsBold() bool

IsBold returns whether the text is bold.

func (*PPTXTextRun) IsItalic added in v0.5.7

func (r *PPTXTextRun) IsItalic() bool

IsItalic returns whether the text is italic.

func (*PPTXTextRun) SetBold added in v0.5.7

func (r *PPTXTextRun) SetBold(bold bool)

SetBold sets the bold flag.

func (*PPTXTextRun) SetColor added in v0.5.7

func (r *PPTXTextRun) SetColor(hex string)

SetColor sets the color from hex string.

func (*PPTXTextRun) SetFontName added in v0.5.7

func (r *PPTXTextRun) SetFontName(name string)

SetFontName sets the font name.

func (*PPTXTextRun) SetFontSize added in v0.5.7

func (r *PPTXTextRun) SetFontSize(size int)

SetFontSize sets the font size.

func (*PPTXTextRun) SetItalic added in v0.5.7

func (r *PPTXTextRun) SetItalic(italic bool)

SetItalic sets the italic flag.

func (*PPTXTextRun) SetText added in v0.5.7

func (r *PPTXTextRun) SetText(text string)

SetText sets the text content.

func (*PPTXTextRun) ToBool added in v0.5.7

func (r *PPTXTextRun) ToBool() *Bool

func (*PPTXTextRun) Type added in v0.5.7

func (r *PPTXTextRun) Type() ObjectType

Type implementations for PPTXTextRun

func (*PPTXTextRun) TypeTag added in v0.5.7

func (r *PPTXTextRun) TypeTag() TypeTag

type PPTXTheme added in v0.5.7

type PPTXTheme struct {
	// contains filtered or unexported fields
}

PPTXTheme represents a presentation theme.

func (*PPTXTheme) HashKey added in v0.5.7

func (t *PPTXTheme) HashKey() HashKey

func (*PPTXTheme) Inspect added in v0.5.7

func (t *PPTXTheme) Inspect() string

func (*PPTXTheme) ToBool added in v0.5.7

func (t *PPTXTheme) ToBool() *Bool

func (*PPTXTheme) Type added in v0.5.7

func (t *PPTXTheme) Type() ObjectType

Type implementations for PPTXTheme

func (*PPTXTheme) TypeTag added in v0.5.7

func (t *PPTXTheme) TypeTag() TypeTag

type PPTXThemeColors added in v0.5.7

type PPTXThemeColors struct {
	// contains filtered or unexported fields
}

PPTXThemeColors defines theme color scheme.

type PPTXThemeFonts added in v0.5.7

type PPTXThemeFonts struct {
	// contains filtered or unexported fields
}

PPTXThemeFonts defines theme fonts.

type PPTXVideo added in v0.5.7

type PPTXVideo struct {
	// contains filtered or unexported fields
}

PPTXVideo represents a video on a slide.

func (*PPTXVideo) GetData added in v0.5.7

func (v *PPTXVideo) GetData() []byte

GetData returns the video data.

func (*PPTXVideo) GetFormat added in v0.5.7

func (v *PPTXVideo) GetFormat() string

GetFormat returns the video format.

func (*PPTXVideo) GetPosition added in v0.5.7

func (v *PPTXVideo) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXVideo) GetSize added in v0.5.7

func (v *PPTXVideo) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXVideo) HashKey added in v0.5.7

func (v *PPTXVideo) HashKey() HashKey

func (*PPTXVideo) Inspect added in v0.5.7

func (v *PPTXVideo) Inspect() string

func (*PPTXVideo) Save added in v0.5.7

func (v *PPTXVideo) Save(path string) error

Save saves the video to a file.

func (*PPTXVideo) SetPosition added in v0.5.7

func (v *PPTXVideo) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXVideo) SetSize added in v0.5.7

func (v *PPTXVideo) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXVideo) ToBool added in v0.5.7

func (v *PPTXVideo) ToBool() *Bool

func (*PPTXVideo) Type added in v0.5.7

func (v *PPTXVideo) Type() ObjectType

Type implementations for PPTXVideo

func (*PPTXVideo) TypeTag added in v0.5.7

func (v *PPTXVideo) TypeTag() TypeTag

type Queue added in v0.5.2

type Queue struct {
	// contains filtered or unexported fields
}

Queue represents a FIFO queue (not thread-safe).

func NewQueue added in v0.5.2

func NewQueue() *Queue

NewQueue creates a new empty queue.

func NewQueueFrom added in v0.5.2

func NewQueueFrom(arr *Array) *Queue

NewQueueFrom creates a new queue from an array.

func NewQueueWithCapacity added in v0.5.2

func NewQueueWithCapacity(capacity int) *Queue

NewQueueWithCapacity creates a new queue with the specified initial capacity.

func (*Queue) Clear added in v0.5.2

func (q *Queue) Clear()

Clear removes all elements from the queue.

func (*Queue) Clone added in v0.5.2

func (q *Queue) Clone() *Queue

Clone returns a shallow copy of the queue.

func (*Queue) HashKey added in v0.5.2

func (q *Queue) HashKey() HashKey

HashKey returns a hash key for the Queue.

func (*Queue) Inspect added in v0.5.2

func (q *Queue) Inspect() string

Inspect returns a string representation.

func (*Queue) IsEmpty added in v0.5.2

func (q *Queue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*Queue) Len added in v0.5.2

func (q *Queue) Len() int

Len returns the number of elements in the queue.

func (*Queue) Peek added in v0.5.2

func (q *Queue) Peek() Object

Peek returns the front element without removing it. Returns NULL if the queue is empty.

func (*Queue) PeekBack added in v0.5.2

func (q *Queue) PeekBack() Object

PeekBack returns the back element without removing it. Returns NULL if the queue is empty.

func (*Queue) Pop added in v0.5.2

func (q *Queue) Pop() Object

Pop removes and returns the front element of the queue. Returns NULL if the queue is empty.

func (*Queue) Push added in v0.5.2

func (q *Queue) Push(item Object)

Push adds an element to the back of the queue.

func (*Queue) ToArray added in v0.5.2

func (q *Queue) ToArray() *Array

ToArray returns all elements as an array (front to back).

func (*Queue) ToBool added in v0.5.2

func (q *Queue) ToBool() *Bool

ToBool returns true (Queue is always truthy).

func (*Queue) Type added in v0.5.2

func (q *Queue) Type() ObjectType

Type returns the object type.

func (*Queue) TypeTag added in v0.5.2

func (q *Queue) TypeTag() TypeTag

TypeTag returns the fast type tag.

type RWMutex added in v0.4.25

type RWMutex struct {
	// contains filtered or unexported fields
}

RWMutex wraps sync.RWMutex for use in Xxlang

func NewRWMutex added in v0.4.25

func NewRWMutex() *RWMutex

NewRWMutex creates a new RWMutex

func (*RWMutex) HashKey added in v0.4.25

func (m *RWMutex) HashKey() HashKey

func (*RWMutex) Inspect added in v0.4.25

func (m *RWMutex) Inspect() string

func (*RWMutex) Lock added in v0.4.25

func (m *RWMutex) Lock()

Lock acquires the write lock

func (*RWMutex) RLock added in v0.4.25

func (m *RWMutex) RLock()

RLock acquires the read lock

func (*RWMutex) RUnlock added in v0.4.25

func (m *RWMutex) RUnlock()

RUnlock releases the read lock

func (*RWMutex) ToBool added in v0.4.25

func (m *RWMutex) ToBool() *Bool

func (*RWMutex) TryLock added in v0.4.25

func (m *RWMutex) TryLock() bool

TryLock attempts to acquire the write lock without blocking

func (*RWMutex) TryRLock added in v0.4.25

func (m *RWMutex) TryRLock() bool

TryRLock attempts to acquire the read lock without blocking

func (*RWMutex) Type added in v0.4.25

func (m *RWMutex) Type() ObjectType

Object interface implementation

func (*RWMutex) TypeTag added in v0.4.25

func (m *RWMutex) TypeTag() TypeTag

func (*RWMutex) Unlock added in v0.4.25

func (m *RWMutex) Unlock()

Unlock releases the write lock

type Reader added in v0.4.25

type Reader struct {
	Value io.Reader
	// contains filtered or unexported fields
}

Reader wraps an io.Reader for streaming read operations. It implements io.ReadCloser interface.

func NewReader added in v0.4.25

func NewReader(r io.Reader) *Reader

NewReader creates a new Reader object.

func (*Reader) Close added in v0.4.25

func (r *Reader) Close() Object

Close closes the reader if it implements io.Closer.

func (*Reader) GetMember added in v0.4.25

func (r *Reader) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*Reader) HashKey added in v0.4.25

func (r *Reader) HashKey() HashKey

HashKey returns a hash key for the Reader.

func (*Reader) Inspect added in v0.4.25

func (r *Reader) Inspect() string

Inspect returns a string representation of the Reader.

func (*Reader) Read added in v0.4.25

func (r *Reader) Read(n int) Object

Read reads up to n bytes from the reader and returns as byte array.

func (*Reader) ReadAllBytes added in v0.4.25

func (r *Reader) ReadAllBytes() Object

ReadAllBytes reads all remaining content and returns as byte array.

func (*Reader) ReadAllStr added in v0.4.25

func (r *Reader) ReadAllStr() Object

ReadAll reads all remaining content and returns as string.

func (*Reader) ReadLine added in v0.4.25

func (r *Reader) ReadLine() Object

ReadLine reads a single line from the reader. Returns null on EOF, or error on failure.

func (*Reader) ReadStr added in v0.4.25

func (r *Reader) ReadStr(n int) Object

ReadStr reads up to n bytes and returns as string.

func (*Reader) ToBool added in v0.4.25

func (r *Reader) ToBool() *Bool

ToBool converts the Reader to a boolean (true if not nil).

func (*Reader) Type added in v0.4.25

func (r *Reader) Type() ObjectType

Type returns the object type.

func (*Reader) TypeTag added in v0.4.25

func (r *Reader) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type Return

type Return struct {
	Value Object
}

Return represents a return value (used internally)

func (*Return) HashKey

func (r *Return) HashKey() HashKey

func (*Return) Inspect

func (r *Return) Inspect() string

func (*Return) ToBool

func (r *Return) ToBool() *Bool

func (*Return) Type

func (r *Return) Type() ObjectType

func (*Return) TypeTag

func (r *Return) TypeTag() TypeTag

type Scanner added in v0.4.25

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner provides convenient methods for reading input. It wraps a bufio.Reader for efficient reading.

func NewScanner added in v0.4.25

func NewScanner(reader io.Reader) *Scanner

NewScanner creates a new Scanner from an io.Reader. If reader is nil, it defaults to os.Stdin.

func (*Scanner) GetMember added in v0.4.25

func (s *Scanner) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*Scanner) HashKey added in v0.4.25

func (s *Scanner) HashKey() HashKey

HashKey returns a hash key for the Scanner.

func (*Scanner) Inspect added in v0.4.25

func (s *Scanner) Inspect() string

Inspect returns a string representation of the Scanner.

func (*Scanner) ToBool added in v0.4.25

func (s *Scanner) ToBool() *Bool

ToBool converts the Scanner to a boolean (always true).

func (*Scanner) Type added in v0.4.25

func (s *Scanner) Type() ObjectType

Type returns the object type.

func (*Scanner) TypeTag added in v0.4.25

func (s *Scanner) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type Set added in v0.5.2

type Set struct {
	// contains filtered or unexported fields
}

Set represents an unordered collection of unique elements (not thread-safe).

func NewSet added in v0.5.2

func NewSet() *Set

NewSet creates a new empty set.

func NewSetFrom added in v0.5.2

func NewSetFrom(arr *Array) *Set

NewSetFrom creates a new set from an array.

func NewSetWithCapacity added in v0.5.2

func NewSetWithCapacity(capacity int) *Set

NewSetWithCapacity creates a new set with the specified initial capacity.

func (*Set) Add added in v0.5.2

func (s *Set) Add(item Object) bool

Add adds an element to the set. Returns true if added, false if already present.

func (*Set) Clear added in v0.5.2

func (s *Set) Clear()

Clear removes all elements from the set.

func (*Set) Clone added in v0.5.2

func (s *Set) Clone() *Set

Clone returns a shallow copy of the set.

func (*Set) Contains added in v0.5.2

func (s *Set) Contains(item Object) bool

Contains returns true if the set contains the element.

func (*Set) Difference added in v0.5.2

func (s *Set) Difference(other *Set) *Set

Difference returns a new set containing elements in s but not in other.

func (*Set) Equals added in v0.5.2

func (s *Set) Equals(other *Set) bool

Equals returns true if both sets contain the same elements.

func (*Set) HashKey added in v0.5.2

func (s *Set) HashKey() HashKey

HashKey returns a hash key for the Set.

func (*Set) Inspect added in v0.5.2

func (s *Set) Inspect() string

Inspect returns a string representation.

func (*Set) Intersect added in v0.5.2

func (s *Set) Intersect(other *Set) *Set

Intersect returns a new set containing elements present in both sets.

func (*Set) IsEmpty added in v0.5.2

func (s *Set) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (*Set) IsSubset added in v0.5.2

func (s *Set) IsSubset(other *Set) bool

IsSubset returns true if s is a subset of other.

func (*Set) IsSuperset added in v0.5.2

func (s *Set) IsSuperset(other *Set) bool

IsSuperset returns true if s is a superset of other.

func (*Set) Len added in v0.5.2

func (s *Set) Len() int

Len returns the number of elements in the set.

func (*Set) Remove added in v0.5.2

func (s *Set) Remove(item Object) bool

Remove removes an element from the set. Returns true if removed, false if not found.

func (*Set) SymmetricDifference added in v0.5.2

func (s *Set) SymmetricDifference(other *Set) *Set

SymmetricDifference returns a new set containing elements in either set but not both.

func (*Set) ToArray added in v0.5.2

func (s *Set) ToArray() *Array

ToArray returns all elements as an array.

func (*Set) ToBool added in v0.5.2

func (s *Set) ToBool() *Bool

ToBool returns true (Set is always truthy).

func (*Set) ToSortedArray added in v0.5.2

func (s *Set) ToSortedArray() *Array

ToSortedArray returns all elements as an array, sorted by Inspect() representation.

func (*Set) Type added in v0.5.2

func (s *Set) Type() ObjectType

Type returns the object type.

func (*Set) TypeTag added in v0.5.2

func (s *Set) TypeTag() TypeTag

TypeTag returns the fast type tag.

func (*Set) Union added in v0.5.2

func (s *Set) Union(other *Set) *Set

Union returns a new set containing all elements from both sets.

type Sheet added in v0.5.2

type Sheet struct {
	Name     string
	Cells    map[string]*Cell // key: "A1", "B2", etc.
	Merges   []MergeRange
	RowCount int
	ColCount int
	Images   []ImageInfo
}

Sheet represents a worksheet.

type String

type String struct {
	Value string
}

String represents a string value

func GetBufferedString added in v0.4.23

func GetBufferedString(val string) *String

GetBufferedString gets a temporary String using the global buffer

func InternBatch

func InternBatch(strings []string) []*String

InternBatch pre-interns a batch of strings

func InternString

func InternString(val string) *String

InternString returns a cached *String for the given value This provides permanent caching for strings that are used often Use this for strings that will be reused many times (e.g., identifiers, keywords)

func NewString added in v0.4.23

func NewString(val string) *String

NewString creates a new String object, using cached values for common strings

func NewStringSlice added in v0.4.23

func NewStringSlice(values []string) []*String

NewStringSlice creates multiple String objects efficiently This is optimized for batch operations

func (*String) HashKey

func (s *String) HashKey() HashKey

HashKey returns the hash key for map operations

func (*String) Inspect

func (s *String) Inspect() string

Inspect returns the string representation

func (*String) ToBool

func (s *String) ToBool() *Bool

ToBool converts the string to a boolean

func (*String) Type

func (s *String) Type() ObjectType

Type returns the object type

func (*String) TypeTag

func (s *String) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type StringBuilder added in v0.4.19

type StringBuilder struct {
	// contains filtered or unexported fields
}

StringBuilder is a mutable string builder for efficient string concatenation. Not thread-safe - use external synchronization if needed.

func NewStringBuilder added in v0.4.19

func NewStringBuilder() *StringBuilder

NewStringBuilder creates a new StringBuilder instance.

func (*StringBuilder) Cap added in v0.4.19

func (sb *StringBuilder) Cap() int

Cap returns the current capacity of the builder's internal buffer.

func (*StringBuilder) Clear added in v0.4.19

func (sb *StringBuilder) Clear()

Clear resets the builder, removing all content.

func (*StringBuilder) GetIOWriter added in v0.4.25

func (sb *StringBuilder) GetIOWriter() *stringBuilderWriter

GetIOWriter returns the builder as an io.Writer interface. This allows the StringBuilder to be used with Writer objects.

func (*StringBuilder) Grow added in v0.4.19

func (sb *StringBuilder) Grow(n int)

Grow grows the builder's capacity to hold at least n more bytes.

func (*StringBuilder) HashKey added in v0.4.19

func (sb *StringBuilder) HashKey() HashKey

HashKey returns a hash key for the StringBuilder.

func (*StringBuilder) Inspect added in v0.4.19

func (sb *StringBuilder) Inspect() string

Inspect returns a string representation.

func (*StringBuilder) Len added in v0.4.19

func (sb *StringBuilder) Len() int

Len returns the current length of the accumulated string.

func (*StringBuilder) Reset added in v0.4.19

func (sb *StringBuilder) Reset()

Reset is an alias for Clear.

func (*StringBuilder) String added in v0.4.19

func (sb *StringBuilder) String() string

String returns the accumulated string.

func (*StringBuilder) ToBool added in v0.4.19

func (sb *StringBuilder) ToBool() *Bool

ToBool returns true (StringBuilder is always truthy).

func (*StringBuilder) Type added in v0.4.19

func (sb *StringBuilder) Type() ObjectType

Type returns the object type.

func (*StringBuilder) TypeTag added in v0.4.19

func (sb *StringBuilder) TypeTag() TypeTag

TypeTag returns the fast type tag.

func (*StringBuilder) Write added in v0.4.19

func (sb *StringBuilder) Write(s string) int

Write appends a string to the builder.

func (*StringBuilder) WriteLine added in v0.4.19

func (sb *StringBuilder) WriteLine(s string) int

WriteLine appends a string followed by a newline to the builder.

type StringPoolStats added in v0.4.23

type StringPoolStats struct {
	// CacheHits is the number of times a cached string was returned
	CacheHits int64
	// InternHits is the number of times an interned string was returned
	InternHits int64
	// PoolHits is the number of times a pooled string was reused
	PoolHits int64
	// Created is the number of new strings allocated by the pool
	Created int64
	// Released is the number of strings returned to the pool
	Released int64
	// Interned is the number of strings currently in the intern cache
	Interned int64
}

StringPoolStats tracks statistics about string pool usage

func GetStringPoolStats added in v0.4.23

func GetStringPoolStats() StringPoolStats

GetStringPoolStats returns current statistics about string pool usage

type Tube added in v0.4.25

type Tube struct {
	// contains filtered or unexported fields
}

Tube represents a communication tube for concurrent message passing It wraps a Go channel for efficient implementation

func NewTube added in v0.4.25

func NewTube(elemType ObjectType, buffer int) *Tube

NewTube creates a new tube with optional type constraint and buffer size

func (*Tube) Cap added in v0.4.25

func (t *Tube) Cap() int

Cap returns the buffer capacity

func (*Tube) CapMethod added in v0.4.25

func (t *Tube) CapMethod(args ...Object) Object

CapMethod is the method called as tube.cap()

func (*Tube) Close added in v0.4.25

func (t *Tube) Close()

Close closes the tube After closing, no more sends are allowed but receives continue until empty

func (*Tube) CloseMethod added in v0.4.25

func (t *Tube) CloseMethod(args ...Object) Object

CloseMethod is the method called as tube.close()

func (*Tube) ElemType added in v0.4.25

func (t *Tube) ElemType() ObjectType

ElemType returns the element type constraint (empty string if untyped)

func (*Tube) HashKey added in v0.4.25

func (t *Tube) HashKey() HashKey

HashKey returns a hash key for the tube

func (*Tube) ID added in v0.4.25

func (t *Tube) ID() uint64

ID returns the unique identifier for this tube

func (*Tube) Inspect added in v0.4.25

func (t *Tube) Inspect() string

Inspect returns a string representation of the tube

func (*Tube) IsClosed added in v0.4.25

func (t *Tube) IsClosed() bool

IsClosed returns whether the tube is closed

func (*Tube) IsClosedMethod added in v0.4.25

func (t *Tube) IsClosedMethod(args ...Object) Object

IsClosedMethod is the method called as tube.isClosed()

func (*Tube) Len added in v0.4.25

func (t *Tube) Len() int

Len returns the number of elements currently in the buffer

func (*Tube) LenMethod added in v0.4.25

func (t *Tube) LenMethod(args ...Object) Object

LenMethod is the method called as tube.len()

func (*Tube) Receive added in v0.4.25

func (t *Tube) Receive() (Object, bool)

Receive receives a value from the tube (blocking) Returns (value, ok) where ok is false if tube is closed and empty

func (*Tube) ReceiveMethod added in v0.4.25

func (t *Tube) ReceiveMethod(args ...Object) Object

ReceiveMethod is the method called as tube.receive() Returns [value, ok] array

func (*Tube) ReflectValue added in v0.4.25

func (t *Tube) ReflectValue() reflect.Value

ReflectValue returns the underlying reflect.Value for use with reflect.Select

func (*Tube) Send added in v0.4.25

func (t *Tube) Send(val Object) bool

Send sends a value to the tube (blocking) Returns false if the tube is closed

func (*Tube) SendMethod added in v0.4.25

func (t *Tube) SendMethod(args ...Object) Object

SendMethod is the method called as tube.send(value)

func (*Tube) SendWithTimeout added in v0.4.25

func (t *Tube) SendWithTimeout(val Object, timeoutMs int) (sent bool, ok bool)

SendWithTimeout sends a value with timeout (in milliseconds) Returns (sent, ok) where ok is false if timeout or closed

func (*Tube) ToBool added in v0.4.25

func (t *Tube) ToBool() *Bool

ToBool returns true (tubes are always truthy)

func (*Tube) TryReceive added in v0.4.25

func (t *Tube) TryReceive() (Object, bool, bool)

TryReceive attempts to receive without blocking Returns (value, received, open) where open is false if tube is closed

func (*Tube) TryReceiveMethod added in v0.4.25

func (t *Tube) TryReceiveMethod(args ...Object) Object

TryReceiveMethod is the method called as tube.tryReceive() Returns [value, received, open] array

func (*Tube) TrySend added in v0.4.25

func (t *Tube) TrySend(val Object) (sent bool, ok bool)

TrySend attempts to send without blocking Returns (sent, ok) where ok is false if tube is closed

func (*Tube) Type added in v0.4.25

func (t *Tube) Type() ObjectType

Type returns the object type

func (*Tube) TypeTag added in v0.4.25

func (t *Tube) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type TypeTag

type TypeTag uint8

TypeTag is a fast integer type identifier for hot path checks

const (
	TagNull TypeTag = iota
	TagInt
	TagFloat
	TagString
	TagChars
	TagBool
	TagArray
	TagMap
	TagFunction
	TagBuiltin
	TagBytes
	TagClass
	TagInstance
	TagError
	TagReturn
	TagClosure
	TagModule
	TagStringBuilder
	TagBytesBuffer
	TagBigInt
	TagBigFloat
	TagHttpReq
	TagHttpResp
	TagHttpMux
	TagWebSocket
	TagTube
	TagMutex
	TagRWMutex
	TagWaitGroup
	TagOnce
	TagCond
	TagAtomicInt
	TagGoroutine
	TagContext
	TagFileUpload
	TagFileUploadResult
	TagFile
	TagFileInfo
	TagReader
	TagWriter
	TagScanner
	TagDB
	TagDBTx
	TagDBRows
	TagDBStmt
	TagOrderedMap
	TagQueue
	TagSet
	TagXLSX
	TagXMLDocument
	TagXMLNode
	TagDocxDocument
	TagDocxParagraph
	TagDocxRun
	TagDocxTable
	TagDocxTableRow
	TagDocxTableCell
	TagDocxImage
	TagDocxSection
	TagDocxHeader
	TagDocxFooter
	TagDocxStyle
	TagDocxHyperlink
	TagDocxBookmark
	TagDocxTOC
	TagDocxTextBox
	TagDocxShape
	TagDocxChart
	TagDocxComment
	TagDocxRevision
	TagDocxFootnote
	TagDocxEndnote
	// PPTX tags
	TagPPTXDocument
	TagPPTXSlide
	TagPPTXTextFrame
	TagPPTXParagraph
	TagPPTXTextRun
	TagPPTXShape
	TagPPTXTable
	TagPPTXTableCell
	TagPPTXChart
	TagPPTXChartSeries
	TagPPTXImage
	TagPPTXVideo
	TagPPTXAudio
	TagPPTXSlideLayout
	TagPPTXSlideMaster
	TagPPTXTheme
	// PDF tags
	TagPDF
	TagPDFDocument
	TagPDFPage
	TagPDFInfo
	TagUnknown
)

Type tags for fast type checking (must match ObjectType order)

const TagCompiledFunction TypeTag = TagClosure // Use same tag as Closure

TagCompiledFunction is the type tag for compiled functions

const TagWebView TypeTag = 101 // Continue from existing tags

TagWebView is the type tag for WebView objects.

type WaitGroup added in v0.4.25

type WaitGroup struct {
	// contains filtered or unexported fields
}

WaitGroup wraps sync.WaitGroup for use in Xxlang

func NewWaitGroup added in v0.4.25

func NewWaitGroup() *WaitGroup

NewWaitGroup creates a new WaitGroup

func (*WaitGroup) Add added in v0.4.25

func (w *WaitGroup) Add(delta int)

Add increments the WaitGroup counter

func (*WaitGroup) Done added in v0.4.25

func (w *WaitGroup) Done()

Done decrements the WaitGroup counter

func (*WaitGroup) HashKey added in v0.4.25

func (w *WaitGroup) HashKey() HashKey

func (*WaitGroup) Inspect added in v0.4.25

func (w *WaitGroup) Inspect() string

func (*WaitGroup) ToBool added in v0.4.25

func (w *WaitGroup) ToBool() *Bool

func (*WaitGroup) Type added in v0.4.25

func (w *WaitGroup) Type() ObjectType

Object interface implementation

func (*WaitGroup) TypeTag added in v0.4.25

func (w *WaitGroup) TypeTag() TypeTag

func (*WaitGroup) Wait added in v0.4.25

func (w *WaitGroup) Wait()

Wait blocks until the WaitGroup counter is zero

type WebSocket added in v0.4.25

type WebSocket struct {
	// Conn is the underlying WebSocket connection interface
	Conn WebSocketConn
	// contains filtered or unexported fields
}

WebSocket represents a WebSocket connection. It wraps the connection and provides methods for reading and writing messages.

func NewWebSocket added in v0.4.25

func NewWebSocket(conn WebSocketConn) *WebSocket

NewWebSocket creates a new WebSocket object.

func (*WebSocket) Close added in v0.4.25

func (ws *WebSocket) Close() Object

Close closes the WebSocket connection.

func (*WebSocket) HashKey added in v0.4.25

func (ws *WebSocket) HashKey() HashKey

HashKey returns a hash key for the WebSocket. WebSockets are not hashable in a meaningful way.

func (*WebSocket) Inspect added in v0.4.25

func (ws *WebSocket) Inspect() string

Inspect returns a string representation of the WebSocket.

func (*WebSocket) IsClosed added in v0.4.25

func (ws *WebSocket) IsClosed() bool

IsClosed returns whether the WebSocket is closed.

func (*WebSocket) ReadMessage added in v0.4.25

func (ws *WebSocket) ReadMessage() Object

ReadMessage reads a message from the WebSocket connection. Returns an array: [messageType, data]

func (*WebSocket) SendBinaryMessage added in v0.4.25

func (ws *WebSocket) SendBinaryMessage(data string) Object

SendBinaryMessage sends a binary message over the WebSocket.

func (*WebSocket) SendCloseMessage added in v0.4.25

func (ws *WebSocket) SendCloseMessage() Object

SendCloseMessage sends a close message over the WebSocket.

func (*WebSocket) SendTextMessage added in v0.4.25

func (ws *WebSocket) SendTextMessage(text string) Object

SendTextMessage sends a text message over the WebSocket.

func (*WebSocket) ToBool added in v0.4.25

func (ws *WebSocket) ToBool() *Bool

ToBool converts the WebSocket to a boolean (always true).

func (*WebSocket) Type added in v0.4.25

func (ws *WebSocket) Type() ObjectType

Type returns the object type.

func (*WebSocket) TypeTag added in v0.4.25

func (ws *WebSocket) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type WebSocketConn added in v0.4.25

type WebSocketConn interface {
	ReadMessage() (messageType int, p []byte, err error)
	WriteMessage(messageType int, data []byte) error
	Close() error
}

WebSocketConn defines the interface for WebSocket connections. This allows different implementations (gorilla, standard library, etc.)

type WebView added in v0.4.34

type WebView struct {
	Handle interface{} // *webview2.WebView2 on Windows
	// contains filtered or unexported fields
}

WebView represents a WebView2 window in Xxlang.

func NewWebView added in v0.4.34

func NewWebView(handle interface{}) *WebView

NewWebView creates a new WebView object.

func (*WebView) AddCallback added in v0.4.34

func (w *WebView) AddCallback(name string, fn *Function)

AddCallback adds a callback function.

func (*WebView) Close added in v0.4.34

func (w *WebView) Close()

Close closes the WebView.

func (*WebView) Equals added in v0.4.34

func (w *WebView) Equals(other Object) *Bool

Equals checks if two WebViews are equal.

func (*WebView) GetCallback added in v0.4.34

func (w *WebView) GetCallback(name string) (*Function, bool)

GetCallback gets a callback function.

func (*WebView) HashKey added in v0.4.34

func (w *WebView) HashKey() HashKey

HashKey returns a hash key for the WebView.

func (*WebView) Inspect added in v0.4.34

func (w *WebView) Inspect() string

Inspect returns a string representation.

func (*WebView) IsClosed added in v0.4.34

func (w *WebView) IsClosed() bool

IsClosed returns true if the WebView is closed.

func (*WebView) SetClosed added in v0.4.34

func (w *WebView) SetClosed(closed bool)

SetClosed sets the closed state.

func (*WebView) ToBool added in v0.4.34

func (w *WebView) ToBool() *Bool

ToBool returns true if the WebView is active.

func (*WebView) Type added in v0.4.34

func (w *WebView) Type() ObjectType

Type returns the object type.

func (*WebView) TypeTag added in v0.4.34

func (w *WebView) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type Writer added in v0.4.25

type Writer struct {
	Value io.Writer
}

Writer wraps an io.Writer for streaming write operations.

func NewWriter added in v0.4.25

func NewWriter(w io.Writer) *Writer

NewWriter creates a new Writer object.

func (*Writer) Close added in v0.4.25

func (w *Writer) Close() Object

Close closes the writer if it implements io.Closer.

func (*Writer) GetMember added in v0.4.25

func (w *Writer) GetMember(name string) Object

GetMember returns a member by name for script access.

func (*Writer) HashKey added in v0.4.25

func (w *Writer) HashKey() HashKey

HashKey returns a hash key for the Writer.

func (*Writer) Inspect added in v0.4.25

func (w *Writer) Inspect() string

Inspect returns a string representation of the Writer.

func (*Writer) ToBool added in v0.4.25

func (w *Writer) ToBool() *Bool

ToBool converts the Writer to a boolean (true if not nil).

func (*Writer) Type added in v0.4.25

func (w *Writer) Type() ObjectType

Type returns the object type.

func (*Writer) TypeTag added in v0.4.25

func (w *Writer) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

func (*Writer) Write added in v0.4.25

func (w *Writer) Write(data []byte) Object

Write writes bytes to the writer.

func (*Writer) WriteBytes added in v0.4.25

func (w *Writer) WriteBytes(arr *Array) Object

WriteBytes writes a byte array (array of integers) to the writer.

func (*Writer) WriteStr added in v0.4.25

func (w *Writer) WriteStr(s string) Object

WriteStr writes a string to the writer.

type XLSX added in v0.5.2

type XLSX struct {
	// contains filtered or unexported fields
}

XLSX represents an Excel workbook.

func NewXLSX added in v0.5.2

func NewXLSX() *XLSX

NewXLSX creates a new empty workbook.

func OpenXLSX added in v0.5.2

func OpenXLSX(path string) (*XLSX, error)

OpenXLSX opens an existing xlsx file.

func (*XLSX) Close added in v0.5.2

func (x *XLSX) Close()

Close closes the workbook.

func (*XLSX) DeleteCol added in v0.5.2

func (x *XLSX) DeleteCol(sheetName string, col int) error

DeleteCol deletes a column.

func (*XLSX) DeleteRow added in v0.5.2

func (x *XLSX) DeleteRow(sheetName string, row int) error

DeleteRow deletes a row.

func (*XLSX) DeleteSheet added in v0.5.2

func (x *XLSX) DeleteSheet(name string) bool

DeleteSheet deletes a sheet.

func (*XLSX) ExtractImage added in v0.5.2

func (x *XLSX) ExtractImage(sheetName string, imageIndex int, outputPath string) error

ExtractImage extracts an image to a file.

func (*XLSX) GetCell added in v0.5.2

func (x *XLSX) GetCell(sheetName, ref string) Object

GetCell returns a cell value.

func (*XLSX) GetCellByIndex added in v0.5.2

func (x *XLSX) GetCellByIndex(sheetName string, row, col int) Object

GetCellByIndex returns a cell value by row/col indices (1-based).

func (*XLSX) GetCol added in v0.5.2

func (x *XLSX) GetCol(sheetName string, col int) *Array

GetCol returns a column as an array.

func (*XLSX) GetColCount added in v0.5.2

func (x *XLSX) GetColCount(sheetName string) int

GetColCount returns the number of columns in a sheet.

func (*XLSX) GetImageData added in v0.5.2

func (x *XLSX) GetImageData(sheetName string, imageIndex int) (string, error)

GetImageData returns image data as base64.

func (*XLSX) GetImages added in v0.5.2

func (x *XLSX) GetImages(sheetName string) *Array

GetImages returns images in a sheet.

func (*XLSX) GetMerges added in v0.5.2

func (x *XLSX) GetMerges(sheetName string) *Array

GetMerges returns merge ranges in a sheet.

func (*XLSX) GetRange added in v0.5.2

func (x *XLSX) GetRange(sheetName, rangeStr string) *Array

GetRange returns a range of cells as a 2D array.

func (*XLSX) GetRow added in v0.5.2

func (x *XLSX) GetRow(sheetName string, row int) *Array

GetRow returns a row as an array.

func (*XLSX) GetRowCount added in v0.5.2

func (x *XLSX) GetRowCount(sheetName string) int

GetRowCount returns the number of rows in a sheet.

func (*XLSX) GetSheet added in v0.5.2

func (x *XLSX) GetSheet(name string) *Sheet

GetSheet returns a sheet by name.

func (*XLSX) GetSheetByIndex added in v0.5.3

func (x *XLSX) GetSheetByIndex(index int) *Sheet

GetSheetByIndex returns a sheet by index (1-based).

func (*XLSX) GetSheetCount added in v0.5.3

func (x *XLSX) GetSheetCount() int

GetSheetCount returns the number of sheets.

func (*XLSX) GetSheetList added in v0.5.2

func (x *XLSX) GetSheetList() []string

GetSheetList returns the list of sheet names.

func (*XLSX) GetSheetName added in v0.5.3

func (x *XLSX) GetSheetName(index int) string

GetSheetName returns the sheet name by index (1-based).

func (*XLSX) HashKey added in v0.5.2

func (x *XLSX) HashKey() HashKey

HashKey returns a hash key for the XLSX.

func (*XLSX) InsertCol added in v0.5.2

func (x *XLSX) InsertCol(sheetName string, col int) error

InsertCol inserts a column at the specified position.

func (*XLSX) InsertRow added in v0.5.2

func (x *XLSX) InsertRow(sheetName string, row int) error

InsertRow inserts a row at the specified position.

func (*XLSX) Inspect added in v0.5.2

func (x *XLSX) Inspect() string

Inspect returns a string representation.

func (*XLSX) MergeCell added in v0.5.2

func (x *XLSX) MergeCell(sheetName string, startRef, endRef string) error

MergeCell merges a range of cells.

func (*XLSX) NewSheet added in v0.5.2

func (x *XLSX) NewSheet(name string) bool

NewSheet creates a new sheet.

func (*XLSX) Save added in v0.5.2

func (x *XLSX) Save(path string) error

Save saves the workbook to a file.

func (*XLSX) SetCell added in v0.5.2

func (x *XLSX) SetCell(sheetName, ref string, value Object) error

SetCell sets a cell value.

func (*XLSX) SetCellByIndex added in v0.5.2

func (x *XLSX) SetCellByIndex(sheetName string, row, col int, value Object) error

SetCellByIndex sets a cell value by row/col indices (1-based).

func (*XLSX) SetRow added in v0.5.2

func (x *XLSX) SetRow(sheetName string, row int, values *Array) error

SetRow sets a row from an array.

func (*XLSX) ToBool added in v0.5.2

func (x *XLSX) ToBool() *Bool

ToBool returns true (XLSX is always truthy).

func (*XLSX) Type added in v0.5.2

func (x *XLSX) Type() ObjectType

Type returns the object type.

func (*XLSX) TypeTag added in v0.5.2

func (x *XLSX) TypeTag() TypeTag

TypeTag returns the fast type tag.

func (*XLSX) UnmergeCell added in v0.5.2

func (x *XLSX) UnmergeCell(sheetName string, ref string) error

UnmergeCell removes a merge from cells.

type XMLDocument added in v0.5.4

type XMLDocument struct {
	// contains filtered or unexported fields
}

XMLDocument represents an XML document.

func NewXMLDocument added in v0.5.4

func NewXMLDocument() *XMLDocument

NewXMLDocument creates a new XML document.

func NewXMLDocumentWithRoot added in v0.5.4

func NewXMLDocumentWithRoot(rootName string) *XMLDocument

NewXMLDocumentWithRoot creates a new XML document with a root element.

func ParseXML added in v0.5.4

func ParseXML(xmlStr string) (*XMLDocument, error)

ParseXML parses an XML string and returns an XMLDocument.

func ParseXMLFile added in v0.5.4

func ParseXMLFile(path string) (*XMLDocument, error)

ParseXMLFile parses an XML file and returns an XMLDocument.

func (*XMLDocument) Encoding added in v0.5.4

func (d *XMLDocument) Encoding() string

Encoding returns the XML encoding.

func (*XMLDocument) Find added in v0.5.4

func (d *XMLDocument) Find(path string) *Array

Find finds nodes by path expression.

func (*XMLDocument) FindElement added in v0.5.4

func (d *XMLDocument) FindElement(path string) *XMLNode

FindElement is an alias for FindFirst.

func (*XMLDocument) FindFirst added in v0.5.4

func (d *XMLDocument) FindFirst(path string) *XMLNode

FindFirst finds the first matching node by path.

func (*XMLDocument) HashKey added in v0.5.4

func (d *XMLDocument) HashKey() HashKey

HashKey returns a hash key for the XMLDocument.

func (*XMLDocument) Inspect added in v0.5.4

func (d *XMLDocument) Inspect() string

Inspect returns a string representation.

func (*XMLDocument) Root added in v0.5.4

func (d *XMLDocument) Root() *XMLNode

Root returns the root node.

func (*XMLDocument) Save added in v0.5.4

func (d *XMLDocument) Save(path string) error

Save saves the document to a file.

func (*XMLDocument) SetRoot added in v0.5.4

func (d *XMLDocument) SetRoot(node *XMLNode)

SetRoot sets the root node.

func (*XMLDocument) ToBool added in v0.5.4

func (d *XMLDocument) ToBool() *Bool

ToBool returns true (XMLDocument is always truthy).

func (*XMLDocument) ToIndented added in v0.5.4

func (d *XMLDocument) ToIndented() string

ToIndented converts the document to indented XML string.

func (*XMLDocument) ToMap added in v0.5.4

func (d *XMLDocument) ToMap() *Map

ToMap converts the document to a Map.

func (*XMLDocument) ToString added in v0.5.4

func (d *XMLDocument) ToString() string

ToString converts the document to XML string.

func (*XMLDocument) Type added in v0.5.4

func (d *XMLDocument) Type() ObjectType

Type returns the object type.

func (*XMLDocument) TypeTag added in v0.5.4

func (d *XMLDocument) TypeTag() TypeTag

TypeTag returns the fast type tag.

func (*XMLDocument) Version added in v0.5.4

func (d *XMLDocument) Version() string

Version returns the XML version.

type XMLNode added in v0.5.4

type XMLNode struct {
	// contains filtered or unexported fields
}

XMLNode represents an XML element node.

func NewXMLNode added in v0.5.4

func NewXMLNode(name string) *XMLNode

NewXMLNode creates a new XML node.

func (*XMLNode) AddChild added in v0.5.4

func (n *XMLNode) AddChild(child *XMLNode)

AddChild adds a child node.

func (*XMLNode) Attr added in v0.5.4

func (n *XMLNode) Attr(name string) string

Attr returns the attribute value by name.

func (*XMLNode) Attrs added in v0.5.4

func (n *XMLNode) Attrs() *Map

Attrs returns all attributes as a Map.

func (*XMLNode) ChildCount added in v0.5.4

func (n *XMLNode) ChildCount() int

ChildCount returns the number of children.

func (*XMLNode) Children added in v0.5.4

func (n *XMLNode) Children() *Array

Children returns all child nodes.

func (*XMLNode) Clear added in v0.5.4

func (n *XMLNode) Clear()

Clear removes all children.

func (*XMLNode) DelAttr added in v0.5.4

func (n *XMLNode) DelAttr(name string)

DelAttr deletes an attribute.

func (*XMLNode) Find added in v0.5.4

func (n *XMLNode) Find(path string) *Array

Find finds nodes by path expression.

func (*XMLNode) FindFirst added in v0.5.4

func (n *XMLNode) FindFirst(path string) *XMLNode

FindFirst finds the first matching node by path.

func (*XMLNode) HashKey added in v0.5.4

func (n *XMLNode) HashKey() HashKey

HashKey returns a hash key for the XMLNode.

func (*XMLNode) Inspect added in v0.5.4

func (n *XMLNode) Inspect() string

Inspect returns a string representation.

func (*XMLNode) Name added in v0.5.4

func (n *XMLNode) Name() string

Name returns the node name.

func (*XMLNode) Parent added in v0.5.4

func (n *XMLNode) Parent() *XMLNode

Parent returns the parent node.

func (*XMLNode) RemoveChild added in v0.5.4

func (n *XMLNode) RemoveChild(index int) bool

RemoveChild removes a child node by index.

func (*XMLNode) SetAttr added in v0.5.4

func (n *XMLNode) SetAttr(name, value string)

SetAttr sets an attribute.

func (*XMLNode) SetName added in v0.5.4

func (n *XMLNode) SetName(name string)

SetName sets the node name.

func (*XMLNode) SetText added in v0.5.4

func (n *XMLNode) SetText(text string)

SetText sets the text content.

func (*XMLNode) Text added in v0.5.4

func (n *XMLNode) Text() string

Text returns the text content.

func (*XMLNode) ToBool added in v0.5.4

func (n *XMLNode) ToBool() *Bool

ToBool returns true if the node has content.

func (*XMLNode) ToIndented added in v0.5.4

func (n *XMLNode) ToIndented() string

ToIndented converts the node to indented XML string.

func (*XMLNode) ToMap added in v0.5.4

func (n *XMLNode) ToMap() *Map

ToMap converts the node to a Map for easy JSON conversion.

func (*XMLNode) ToString added in v0.5.4

func (n *XMLNode) ToString() string

ToString converts the node to XML string.

func (*XMLNode) Type added in v0.5.4

func (n *XMLNode) Type() ObjectType

Type returns the object type.

func (*XMLNode) TypeTag added in v0.5.4

func (n *XMLNode) TypeTag() TypeTag

TypeTag returns the fast type tag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL