objects

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 59 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_check.go Check/validate and bytes built-in functions for Xxlang

pkg/objects/builtin_collection.go Array and collection enhancement built-in functions for Xxlang

pkg/objects/builtin_compress.go Compression and archive built-in functions for Xxlang

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

pkg/objects/builtin_data_format.go Data format built-in functions for Xxlang Note: XML functions moved to xml module, YAML functions moved to yaml module, TOML functions moved to toml module. Use module functions instead: xml.parse(), yaml.parse(), toml.parse(), etc.

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_encode.go Encoding and encryption related built-in functions for Xxlang

pkg/objects/builtin_env.go Environment and OS information related built-in functions for Xxlang

pkg/objects/builtin_file.go File system related built-in functions for Xxlang

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_image.go Image processing built-in functions for Xxlang. Note: genQr, scanQr, getImageInfo, resizeImage have been moved to the 'image' stdlib module. createImage is kept as a builtin function (which is an alias to image.createImage).

pkg/objects/builtin_input.go Clipboard and input built-in functions for Xxlang

pkg/objects/builtin_json.go JSON enhancement built-in functions for Xxlang

pkg/objects/builtin_jwt.go JWT (JSON Web Token) functions for Xxlang Note: genJwtToken and parseJwtToken have been moved to crypto module

pkg/objects/builtin_mail.go Email types for Xxlang (MailClient object type) The mail functions have been moved to the mail module.

pkg/objects/builtin_math.go Math enhancement built-in functions for Xxlang Note: sin, cos, tan, asin, acos, atan, atan2, exp, log, log10, log2, pi, e, degToRad, radToDeg have been removed - use math module instead

pkg/objects/builtin_misc.go Miscellaneous built-in functions for Xxlang (random, temp, url, security)

pkg/objects/builtin_network.go Network communication built-in functions for Xxlang (FTP, SSH) Note: newFtpClient and newSshClient have been moved to ftp and ssh modules. Use ftp.connect() or ssh.connect() instead for one-step connection.

pkg/objects/builtin_regex.go Regular expression related built-in functions for Xxlang

pkg/objects/builtin_string.go String enhancement built-in functions for Xxlang

pkg/objects/builtin_string2.go String processing enhancement built-in functions for Xxlang

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_task.go Task and scheduling functions for Xxlang. Note: These functions have been moved to the 'task' stdlib module. This file retains the cron parser for use by the task module.

pkg/objects/builtin_testing.go Test assertion built-in functions for Xxlang Note: These functions have been moved to the testing and debug modules. This file is kept for backward compatibility placeholders.

pkg/objects/builtin_time.go Time related built-in functions for Xxlang

pkg/objects/builtin_unicode.go Unicode and text processing built-in functions for Xxlang Note: toPinYin, kanaToRomaji, kanjiToKana, kanjiToRomaji have been moved to locale module

pkg/objects/builtin_util.go Utility built-in functions for Xxlang

pkg/objects/builtin_xlsx.go Excel/XLSX and CSV built-in functions for Xxlang. Note: newExcel, openExcel, readCsv, writeCsv have been moved to xlsx and csv modules. Use xlsx.create(), xlsx.open(), csv.read(), csv.write() instead.

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/docx.go DOCX object types for Xxlang - Microsoft Word document handling.

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/ftp_client.go FtpClient object for Xxlang - FTP client functionality.

pkg/objects/ftp_server.go FtpServer object for Xxlang - FTP server functionality.

pkg/objects/function.go

pkg/objects/html_obj.go HTML types for Xxlang - HTML document and element handling.

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/line_editor.go LineEditor object for Xxlang - line-based text editing functionality.

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/pinyin.go Chinese character to Pinyin converter - pure Go implementation

pkg/objects/pinyin_data.go Auto-generated Chinese character to Pinyin mapping data Contains 20000+ Chinese characters DO NOT EDIT - generated from go-pinyin database

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

pkg/objects/qrcode.go QR Code generator and decoder - pure Go implementation without external dependencies Based on ISO/IEC 18004 standard

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/sftp_client.go SftpClient object for Xxlang - SFTP client functionality.

pkg/objects/sftp_server.go SftpServer object for Xxlang - SFTP server functionality.

pkg/objects/socket_addr.go SocketAddr object type for network address representation.

pkg/objects/socket_unix.go Socket options implementation for Unix-like systems (Linux, macOS, BSD, etc.)

pkg/objects/ssh_client.go SSHClient object for Xxlang - SSH client functionality.

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/tcp_client.go TcpClient object type for TCP client connections.

pkg/objects/tcp_server.go TcpServer object type for TCP server operations.

pkg/objects/time_obj.go Time object type for Xxlang

pkg/objects/toml_encoder.go TOML encoder - pure Go implementation

pkg/objects/toml_lexer.go TOML lexer - pure Go implementation

pkg/objects/toml_obj.go TOML document object for Xxlang - pure Go implementation without CGO

pkg/objects/toml_parser.go TOML parser - pure Go implementation

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

pkg/objects/udp_socket.go UdpSocket object type for UDP socket operations.

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.

pkg/objects/yaml_obj.go YAML object types and utility functions for Xxlang. This file implements comprehensive YAML 1.2 parsing and serialization without third-party libraries.

Supported features: - Basic types: strings, integers, floats, booleans, null - Collections: mappings, sequences - Block styles: literal (|), folded (>), with chomping indicators (+,-) and indent indicators - Flow styles: inline mappings {}, inline sequences [] - Anchors and aliases: &anchor, *alias - Merge keys: << - Complex keys: ? explicit key syntax - Tags: !!str, !!int, !!float, !!bool, !!null, !!seq, !!map, !!timestamp, !!binary, !!set, !!omap - Multi-document: --- and ... - Comments: # - Special values: .inf, -.inf, .nan - Number formats: hex (0x), octal (0o), binary (0b), sexagesimal (60:00:00) - Precise error reporting with line and column numbers

Index

Constants

View Source
const (
	NS_W    = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
	NS_R    = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
	NS_WP   = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
	NS_A    = "http://schemas.openxmlformats.org/drawingml/2006/main"
	NS_PIC  = "http://schemas.openxmlformats.org/drawingml/2006/picture"
	NS_V    = "urn:schemas-microsoft-com:vml"
	NS_O    = "urn:schemas-microsoft-com:office:office"
	NS_W10  = "urn:schemas-microsoft-com:office:word"
	NS_W14  = "http://schemas.microsoft.com/office/word/2010/wordml"
	NS_W15  = "http://schemas.microsoft.com/office/word/2012/wordml"
	NS_MC   = "http://schemas.openxmlformats.org/markup-compatibility/2006"
	NS_CT   = "http://schemas.openxmlformats.org/package/2006/content-types"
	NS_RELS = "http://schemas.openxmlformats.org/package/2006/relationships"
)

XML Namespaces for DOCX

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 (
	SSH_FXP_INIT           = 1
	SSH_FXP_VERSION        = 2
	SSH_FXP_OPEN           = 3
	SSH_FXP_CLOSE          = 4
	SSH_FXP_READ           = 5
	SSH_FXP_WRITE          = 6
	SSH_FXP_LSTAT          = 7
	SSH_FXP_FSTAT          = 8
	SSH_FXP_SETSTAT        = 9
	SSH_FXP_FSETSTAT       = 10
	SSH_FXP_OPENDIR        = 11
	SSH_FXP_READDIR        = 12
	SSH_FXP_REMOVE         = 13
	SSH_FXP_MKDIR          = 14
	SSH_FXP_RMDIR          = 15
	SSH_FXP_REALPATH       = 16
	SSH_FXP_STAT           = 17
	SSH_FXP_RENAME         = 18
	SSH_FXP_READLINK       = 19
	SSH_FXP_SYMLINK        = 20
	SSH_FXP_STATUS         = 101
	SSH_FXP_HANDLE         = 102
	SSH_FXP_DATA           = 103
	SSH_FXP_NAME           = 104
	SSH_FXP_ATTRS          = 105
	SSH_FXP_EXTENDED       = 200
	SSH_FXP_EXTENDED_REPLY = 201
)

SFTP packet types

View Source
const (
	SSH_FXF_READ   = 0x00000001
	SSH_FXF_WRITE  = 0x00000002
	SSH_FXF_APPEND = 0x00000004
	SSH_FXF_CREAT  = 0x00000008
	SSH_FXF_TRUNC  = 0x00000010
	SSH_FXF_EXCL   = 0x00000020
)

File open flags

View Source
const (
	SSH_FILEXFER_ATTR_SIZE        = 0x00000001
	SSH_FILEXFER_ATTR_UIDGID      = 0x00000002
	SSH_FILEXFER_ATTR_PERMISSIONS = 0x00000004
	SSH_FILEXFER_ATTR_ACMODTIME   = 0x00000008
)

File attribute flags

View Source
const (
	SSH_FX_OK                = 0
	SSH_FX_EOF               = 1
	SSH_FX_NO_SUCH_FILE      = 2
	SSH_FX_PERMISSION_DENIED = 3
	SSH_FX_FAILURE           = 4
	SSH_FX_BAD_MESSAGE       = 5
	SSH_FX_NO_CONNECTION     = 6
	SSH_FX_CONNECTION_LOST   = 7
	SSH_FX_OP_UNSUPPORTED    = 8
)

SFTP status codes

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)
			}

			om := NewOrderedMap()
			for i, col := range columns {
				om.Set(NewString(col), NewString(dbValueToString(values[i])))
			}
			result = append(result, om)
		}

		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 OrderedMaps. Column order is preserved in each OrderedMap. 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", path)
			if workingDir != "" {
				cmd.Dir = workingDir
			}
			cmd.Stdout = nil
			cmd.Stderr = nil

			setDetachedAttr(cmd)

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

			if cmd.Process != nil {
				cmd.Process.Release()
			}
			result := NewOrderedMap()
			result.Set(NewString("success"), TRUE)
			result.Set(NewString("error"), NewString(""))
			return result

		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{}/* 206 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 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)
		},
	},

	"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
		},
	},

	"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)
		},
	},
}

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,

	SocketAddrType: socketAddrMethods,
	TcpServerType:  tcpServerMethods,
	TcpClientType:  tcpClientMethods,
	UdpSocketType:  udpSocketMethods,

	LineEditorType: lineEditorMethods,

	SSHClientType: sshClientMethods,

	FtpClientType:  ftpClientMethods,
	FtpServerType:  ftpServerMethods,
	SftpClientType: sftpClientMethods,
	SftpServerType: sftpServerMethods,

	HTMLDocumentType: htmlDocumentMethods,
	HTMLElementType:  htmlElementMethods,

	TomlDocumentType: tomlDocumentMethods,

	TimeType: timeMethods,
}

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 ConvertToPinyin added in v0.5.13

func ConvertToPinyin(text string, withTone bool, initialsOnly bool) string

ConvertToPinyin converts Chinese characters to Pinyin withTone: if true, returns pinyin with tone marks (deprecated, use ConvertToPinyinEx) initialsOnly: if true, returns only the first letter (initial)

func ConvertToPinyinEx added in v0.5.13

func ConvertToPinyinEx(text string, toneStyle ToneStyle, initialsOnly bool) string

ConvertToPinyinEx converts Chinese characters to Pinyin with extended options toneStyle: how to represent tones (ToneNone, ToneMark, ToneNumber) initialsOnly: if true, returns only the first letter (initial)

func ConvertToPinyinWithSeparator added in v0.5.13

func ConvertToPinyinWithSeparator(text string, withTone bool, initialsOnly bool, separator string) string

ConvertToPinyinWithSeparator converts Chinese characters to Pinyin with a separator

func ConvertToPinyinWithSeparatorEx added in v0.5.13

func ConvertToPinyinWithSeparatorEx(text string, toneStyle ToneStyle, initialsOnly bool, separator string) string

ConvertToPinyinWithSeparatorEx converts Chinese characters to Pinyin with extended options

func DecodeQRCode added in v0.5.13

func DecodeQRCode(img image.Image) (string, error)

DecodeQRCode decodes a QR code from an image This is a simplified decoder that works with basic QR codes

func DetectYAMLValueType added in v0.5.10

func DetectYAMLValueType(s string) string

DetectYAMLValueType detects the type of a YAML value string

func EncodeToHTML added in v0.5.10

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

EncodeToHTML converts an Object to HTML string.

func EncodeToToml added in v0.5.13

func EncodeToToml(v interface{}) string

EncodeToToml encodes any value to TOML

func EncodeToXML added in v0.5.4

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

EncodeToXML converts an Object to XML string.

func EncodeToml added in v0.5.13

func EncodeToml(root *TomlValue) string

EncodeToml encodes a TomlValue to a TOML string

func ErrIndexOutOfRange added in v0.5.6

func ErrIndexOutOfRange(index, length int) error

ErrIndexOutOfRange creates an error for an out of range index

func ErrKeyNotFound added in v0.5.6

func ErrKeyNotFound(key Object) error

ErrKeyNotFound creates an error for a missing key

func EscapeHTML added in v0.5.10

func EscapeHTML(s string) string

EscapeHTML escapes special characters for HTML content.

func EscapeHTMLAttr added in v0.5.10

func EscapeHTMLAttr(s string) string

EscapeHTMLAttr escapes special characters for HTML attributes.

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 ExtractYAMLAnchors added in v0.5.10

func ExtractYAMLAnchors(s string) map[string]Object

ExtractYAMLAnchors extracts all anchor definitions from a YAML document

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 GenJwtToken added in v0.5.13

func GenJwtToken(payload *Map, secret []byte, withType, base64Secret bool, expireSeconds int64) (string, error)

GenJwtToken generates a JWT token from payload and secret. Exported for use by crypto module.

func GenerateQRCode added in v0.5.13

func GenerateQRCode(data string, level QRCodeLevel, size int) ([]byte, error)

GenerateQRCode generates a QR code from the given data

func GetPinyinInitials added in v0.5.13

func GetPinyinInitials(text string) string

GetPinyinInitials returns the initials (first letters) of pinyin

func GetPinyinWithTone added in v0.5.13

func GetPinyinWithTone(text string) string

GetPinyinWithTone returns pinyin with tone marks

func GetPinyinWithToneNumber added in v0.5.13

func GetPinyinWithToneNumber(text string) string

GetPinyinWithToneNumber returns pinyin with tone numbers (e.g., zhong1guo2)

func HexToByte added in v0.5.13

func HexToByte(s string) uint8

HexToByte converts a hex string to a byte.

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 IsValidKey added in v0.5.13

func IsValidKey(s string) bool

IsValidKey checks if a string is a valid bare key

func IsYAMLSet added in v0.5.10

func IsYAMLSet(m *Map) bool

IsYAMLSet checks if a map represents a YAML set (all values are null)

func JSONToYAML added in v0.5.10

func JSONToYAML(jsonStr string, indent int) (string, error)

JSONToYAML converts a JSON string to YAML

func JoinYAMLDocuments added in v0.5.10

func JoinYAMLDocuments(docs []Object, indent int) string

JoinYAMLDocuments joins multiple YAML documents into a multi-document YAML string

func KanaToRomaji added in v0.5.13

func KanaToRomaji(input string) string

KanaToRomaji converts Hiragana/Katakana to Romaji

func KanjiToKana added in v0.5.13

func KanjiToKana(input string) string

KanjiToKana converts Kanji to Kana (Hiragana)

func KanjiToRomaji added in v0.5.13

func KanjiToRomaji(input string) string

KanjiToRomaji converts Kanji directly to Romaji

func LoadImageFromReader added in v0.5.13

func LoadImageFromReader(r io.Reader) (image.Image, string, error)

LoadImageFromReader loads an image from an io.Reader. This is exported for use by the image stdlib module.

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 NormalizeYAML added in v0.5.10

func NormalizeYAML(s string, indent int) (string, error)

NormalizeYAML normalizes YAML content by parsing and re-serializing

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 ParseCronRange added in v0.5.13

func ParseCronRange(cf *CronField, part string, min, max int) error

ParseCronRange parses a cron range expression (e.g., "1-5")

func ParseCronStep added in v0.5.13

func ParseCronStep(cf *CronField, part string, min, max int) error

ParseCronStep parses a cron step expression (e.g., "*/5" or "0-30/5")

func ParseCronValue added in v0.5.13

func ParseCronValue(s string, min, max int) (int, error)

ParseCronValue parses a single cron value

func ParseHexColor added in v0.5.13

func ParseHexColor(s string) color.Color

ParseHexColor parses a hex color string. This is exported for use by the image stdlib module.

func ParseJwtToken added in v0.5.13

func ParseJwtToken(tokenStr string, secret []byte, base64Secret, noValidate bool) (map[string]interface{}, error)

ParseJwtToken parses and validates a JWT token with secret. Exported for use by crypto module.

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.6

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 SanitizeHTML added in v0.5.10

func SanitizeHTML(html string) string

SanitizeHTML removes potentially dangerous HTML content.

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 SerializeYAML added in v0.5.10

func SerializeYAML(obj Object, indent int) string

SerializeYAML converts an Xxlang Object to a YAML string.

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 SplitYAMLDocuments added in v0.5.10

func SplitYAMLDocuments(s string) []string

SplitYAMLDocuments splits a YAML string into individual documents

func StripTags added in v0.5.10

func StripTags(html string) string

StripTags removes all HTML tags from a string.

func TestUdpSocket_Bind added in v0.6.0

func TestUdpSocket_Bind(t *testing.T)

func TestUdpSocket_BindAlreadyBound added in v0.6.0

func TestUdpSocket_BindAlreadyBound(t *testing.T)

func TestUdpSocket_BindClosed added in v0.6.0

func TestUdpSocket_BindClosed(t *testing.T)

func TestUdpSocket_Close added in v0.6.0

func TestUdpSocket_Close(t *testing.T)

func TestUdpSocket_HashKey added in v0.6.0

func TestUdpSocket_HashKey(t *testing.T)

func TestUdpSocket_Inspect added in v0.6.0

func TestUdpSocket_Inspect(t *testing.T)

func TestUdpSocket_New added in v0.6.0

func TestUdpSocket_New(t *testing.T)

func TestUdpSocket_ReceiveFromBytesClosed added in v0.6.0

func TestUdpSocket_ReceiveFromBytesClosed(t *testing.T)

func TestUdpSocket_ReceiveFromBytesUnbound added in v0.6.0

func TestUdpSocket_ReceiveFromBytesUnbound(t *testing.T)

func TestUdpSocket_ReceiveFromClosed added in v0.6.0

func TestUdpSocket_ReceiveFromClosed(t *testing.T)

func TestUdpSocket_ReceiveFromUnbound added in v0.6.0

func TestUdpSocket_ReceiveFromUnbound(t *testing.T)

func TestUdpSocket_SendToBytesClosed added in v0.6.0

func TestUdpSocket_SendToBytesClosed(t *testing.T)

func TestUdpSocket_SendToClosed added in v0.6.0

func TestUdpSocket_SendToClosed(t *testing.T)

func TestUdpSocket_SetTimeout added in v0.6.0

func TestUdpSocket_SetTimeout(t *testing.T)

func TestUdpSocket_ToBool added in v0.6.0

func TestUdpSocket_ToBool(t *testing.T)

func TestUdpSocket_Type added in v0.6.0

func TestUdpSocket_Type(t *testing.T)

func TestUdpSocket_TypeTag added in v0.6.0

func TestUdpSocket_TypeTag(t *testing.T)

func ToPinYin added in v0.5.13

func ToPinYin(text string, toneStyle ToneStyle, initialsOnly bool, separator string) string

ToPinYin converts Chinese characters to Pinyin

func UnescapeHTML added in v0.5.10

func UnescapeHTML(s string) string

UnescapeHTML unescapes HTML entities.

func ValidateToml added in v0.5.13

func ValidateToml(input string) (bool, string)

ValidateToml validates a TOML string

func ValidateYAML added in v0.5.10

func ValidateYAML(s string) error

ValidateYAML validates a YAML string and returns detailed error information

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

func YAMLToJSON added in v0.5.10

func YAMLToJSON(yamlStr string) (string, error)

YAMLToJSON converts a YAML string to JSON

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 CronField added in v0.5.13

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

CronField represents a cron field with valid values

func ParseCronField added in v0.5.13

func ParseCronField(parts []string, min, max int) (*CronField, error)

ParseCronField parses a single cron field This is exported for use by the task stdlib module

type CronSchedule added in v0.5.13

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

CronSchedule represents a parsed cron schedule

func ParseCron added in v0.5.13

func ParseCron(expr string) (*CronSchedule, error)

ParseCron parses a cron expression and returns a schedule This is exported for use by the task stdlib module

func (*CronSchedule) Matches added in v0.5.13

func (s *CronSchedule) Matches(t time.Time) bool

Matches checks if the given time matches the cron schedule

func (*CronSchedule) Next added in v0.5.13

func (s *CronSchedule) Next(after time.Time) time.Time

Next returns the next time the cron schedule will fire after the given time

func (*CronSchedule) String added in v0.5.13

func (s *CronSchedule) String() string

String returns the string representation of the cron schedule

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 DocxBookmark added in v0.5.13

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

DocxBookmark represents a bookmark in the document.

func (*DocxBookmark) HashKey added in v0.5.13

func (b *DocxBookmark) HashKey() HashKey

func (*DocxBookmark) Inspect added in v0.5.13

func (b *DocxBookmark) Inspect() string

func (*DocxBookmark) ToBool added in v0.5.13

func (b *DocxBookmark) ToBool() *Bool

func (*DocxBookmark) Type added in v0.5.13

func (b *DocxBookmark) Type() ObjectType

Type implementations for DocxBookmark

func (*DocxBookmark) TypeTag added in v0.5.13

func (b *DocxBookmark) TypeTag() TypeTag

type DocxChart added in v0.5.13

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

DocxChart represents a chart.

func (*DocxChart) HashKey added in v0.5.13

func (c *DocxChart) HashKey() HashKey

func (*DocxChart) Inspect added in v0.5.13

func (c *DocxChart) Inspect() string

func (*DocxChart) ToBool added in v0.5.13

func (c *DocxChart) ToBool() *Bool

func (*DocxChart) Type added in v0.5.13

func (c *DocxChart) Type() ObjectType

Type implementations for DocxChart

func (*DocxChart) TypeTag added in v0.5.13

func (c *DocxChart) TypeTag() TypeTag

type DocxComment added in v0.5.13

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

DocxComment represents a comment.

func (*DocxComment) HashKey added in v0.5.13

func (c *DocxComment) HashKey() HashKey

func (*DocxComment) Inspect added in v0.5.13

func (c *DocxComment) Inspect() string

func (*DocxComment) ToBool added in v0.5.13

func (c *DocxComment) ToBool() *Bool

func (*DocxComment) Type added in v0.5.13

func (c *DocxComment) Type() ObjectType

Type implementations for DocxComment

func (*DocxComment) TypeTag added in v0.5.13

func (c *DocxComment) TypeTag() TypeTag

type DocxDocument added in v0.5.13

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

DocxDocument represents a Microsoft Word document (.docx). A .docx file is a ZIP archive containing XML files.

func NewDocxDocument added in v0.5.13

func NewDocxDocument() *DocxDocument

NewDocxDocument creates a new empty Word document.

func OpenDocx added in v0.5.13

func OpenDocx(path string) (*DocxDocument, error)

OpenDocx opens an existing Word document from a file path.

func OpenDocxFromBytes added in v0.5.13

func OpenDocxFromBytes(data []byte) (*DocxDocument, error)

OpenDocxFromBytes opens a Word document from a byte slice.

func (*DocxDocument) AddMediaFile added in v0.5.13

func (d *DocxDocument) AddMediaFile(data []byte, ext string) string

AddMediaFile adds a media file to the document.

func (*DocxDocument) AddRelationship added in v0.5.13

func (d *DocxDocument) AddRelationship(relType, target string) string

AddRelationship adds a relationship to the document.

func (*DocxDocument) Close added in v0.5.13

func (d *DocxDocument) Close() error

Close closes the document and releases resources.

func (*DocxDocument) FindElements added in v0.5.13

func (d *DocxDocument) FindElements(path string) *Array

FindElements finds elements by name, trying both with and without namespace prefix.

func (*DocxDocument) FindFirstElement added in v0.5.13

func (d *DocxDocument) FindFirstElement(path string) *XMLNode

FindFirstElement finds the first element by name, trying both with and without namespace prefix.

func (*DocxDocument) GetBody added in v0.5.13

func (d *DocxDocument) GetBody() *XMLNode

GetBody returns the body element of the document.

func (*DocxDocument) GetProperties added in v0.5.13

func (d *DocxDocument) GetProperties() *DocxProperties

GetProperties returns the document properties.

func (*DocxDocument) GetXMLDoc added in v0.5.13

func (d *DocxDocument) GetXMLDoc() *XMLDocument

GetXMLDoc returns the underlying XML document.

func (*DocxDocument) HashKey added in v0.5.13

func (d *DocxDocument) HashKey() HashKey

func (*DocxDocument) Inspect added in v0.5.13

func (d *DocxDocument) Inspect() string

func (*DocxDocument) IsModified added in v0.5.13

func (d *DocxDocument) IsModified() bool

IsModified returns whether the document has been modified.

func (*DocxDocument) Save added in v0.5.13

func (d *DocxDocument) Save(path string) error

Save saves the document to a file.

func (*DocxDocument) SetModified added in v0.5.13

func (d *DocxDocument) SetModified(modified bool)

SetModified sets the modified flag.

func (*DocxDocument) ToBool added in v0.5.13

func (d *DocxDocument) ToBool() *Bool

func (*DocxDocument) ToBytes added in v0.5.13

func (d *DocxDocument) ToBytes() ([]byte, error)

ToBytes converts the document to a byte slice.

func (*DocxDocument) Type added in v0.5.13

func (d *DocxDocument) Type() ObjectType

Type implementations for DocxDocument

func (*DocxDocument) TypeTag added in v0.5.13

func (d *DocxDocument) TypeTag() TypeTag

type DocxEndnote added in v0.5.13

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

DocxEndnote represents an endnote.

func (*DocxEndnote) HashKey added in v0.5.13

func (e *DocxEndnote) HashKey() HashKey

func (*DocxEndnote) Inspect added in v0.5.13

func (e *DocxEndnote) Inspect() string

func (*DocxEndnote) ToBool added in v0.5.13

func (e *DocxEndnote) ToBool() *Bool

func (*DocxEndnote) Type added in v0.5.13

func (e *DocxEndnote) Type() ObjectType

Type implementations for DocxEndnote

func (*DocxEndnote) TypeTag added in v0.5.13

func (e *DocxEndnote) TypeTag() TypeTag

type DocxFooter added in v0.5.13

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

DocxFooter represents a document footer.

func (*DocxFooter) HashKey added in v0.5.13

func (f *DocxFooter) HashKey() HashKey

func (*DocxFooter) Inspect added in v0.5.13

func (f *DocxFooter) Inspect() string

func (*DocxFooter) ToBool added in v0.5.13

func (f *DocxFooter) ToBool() *Bool

func (*DocxFooter) Type added in v0.5.13

func (f *DocxFooter) Type() ObjectType

Type implementations for DocxFooter

func (*DocxFooter) TypeTag added in v0.5.13

func (f *DocxFooter) TypeTag() TypeTag

type DocxFootnote added in v0.5.13

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

DocxFootnote represents a footnote.

func (*DocxFootnote) HashKey added in v0.5.13

func (f *DocxFootnote) HashKey() HashKey

func (*DocxFootnote) Inspect added in v0.5.13

func (f *DocxFootnote) Inspect() string

func (*DocxFootnote) ToBool added in v0.5.13

func (f *DocxFootnote) ToBool() *Bool

func (*DocxFootnote) Type added in v0.5.13

func (f *DocxFootnote) Type() ObjectType

Type implementations for DocxFootnote

func (*DocxFootnote) TypeTag added in v0.5.13

func (f *DocxFootnote) TypeTag() TypeTag

type DocxHeader added in v0.5.13

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

DocxHeader represents a document header.

func (*DocxHeader) HashKey added in v0.5.13

func (h *DocxHeader) HashKey() HashKey

func (*DocxHeader) Inspect added in v0.5.13

func (h *DocxHeader) Inspect() string

func (*DocxHeader) ToBool added in v0.5.13

func (h *DocxHeader) ToBool() *Bool

func (*DocxHeader) Type added in v0.5.13

func (h *DocxHeader) Type() ObjectType

Type implementations for DocxHeader

func (*DocxHeader) TypeTag added in v0.5.13

func (h *DocxHeader) TypeTag() TypeTag
type DocxHyperlink struct {
	// contains filtered or unexported fields
}

DocxHyperlink represents a hyperlink in the document.

func (*DocxHyperlink) HashKey added in v0.5.13

func (h *DocxHyperlink) HashKey() HashKey

func (*DocxHyperlink) Inspect added in v0.5.13

func (h *DocxHyperlink) Inspect() string

func (*DocxHyperlink) ToBool added in v0.5.13

func (h *DocxHyperlink) ToBool() *Bool

func (*DocxHyperlink) Type added in v0.5.13

func (h *DocxHyperlink) Type() ObjectType

Type implementations for DocxHyperlink

func (*DocxHyperlink) TypeTag added in v0.5.13

func (h *DocxHyperlink) TypeTag() TypeTag

type DocxImage added in v0.5.13

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

DocxImage represents an image in a Word document.

func (*DocxImage) HashKey added in v0.5.13

func (i *DocxImage) HashKey() HashKey

func (*DocxImage) Inspect added in v0.5.13

func (i *DocxImage) Inspect() string

func (*DocxImage) ToBool added in v0.5.13

func (i *DocxImage) ToBool() *Bool

func (*DocxImage) Type added in v0.5.13

func (i *DocxImage) Type() ObjectType

Type implementations for DocxImage

func (*DocxImage) TypeTag added in v0.5.13

func (i *DocxImage) TypeTag() TypeTag

type DocxParagraph added in v0.5.13

type DocxParagraph struct {
	Document *DocxDocument
	XmlNode  *XMLNode
	// contains filtered or unexported fields
}

DocxParagraph represents a paragraph in a Word document.

func (*DocxParagraph) HashKey added in v0.5.13

func (p *DocxParagraph) HashKey() HashKey

func (*DocxParagraph) Inspect added in v0.5.13

func (p *DocxParagraph) Inspect() string

func (*DocxParagraph) ToBool added in v0.5.13

func (p *DocxParagraph) ToBool() *Bool

func (*DocxParagraph) Type added in v0.5.13

func (p *DocxParagraph) Type() ObjectType

Type implementations for DocxParagraph

func (*DocxParagraph) TypeTag added in v0.5.13

func (p *DocxParagraph) TypeTag() TypeTag

type DocxProperties added in v0.5.13

type DocxProperties struct {
	Title       string
	Subject     string
	Author      string
	Keywords    string
	Description string
	Created     string
	Modified    string
	LastModBy   string
	Revision    int
	Category    string
	ContentStat string
	Application string
	AppVersion  string
	Pages       int
	Words       int
	Characters  int
	Lines       int
	Paragraphs  int
}

DocxProperties holds document metadata.

type DocxRevision added in v0.5.13

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

DocxRevision represents a revision (tracked change).

func (*DocxRevision) HashKey added in v0.5.13

func (r *DocxRevision) HashKey() HashKey

func (*DocxRevision) Inspect added in v0.5.13

func (r *DocxRevision) Inspect() string

func (*DocxRevision) ToBool added in v0.5.13

func (r *DocxRevision) ToBool() *Bool

func (*DocxRevision) Type added in v0.5.13

func (r *DocxRevision) Type() ObjectType

Type implementations for DocxRevision

func (*DocxRevision) TypeTag added in v0.5.13

func (r *DocxRevision) TypeTag() TypeTag

type DocxRun added in v0.5.13

type DocxRun struct {
	Paragraph *DocxParagraph
	XmlNode   *XMLNode
	// contains filtered or unexported fields
}

DocxRun represents a text run within a paragraph.

func (*DocxRun) HashKey added in v0.5.13

func (r *DocxRun) HashKey() HashKey

func (*DocxRun) Inspect added in v0.5.13

func (r *DocxRun) Inspect() string

func (*DocxRun) ToBool added in v0.5.13

func (r *DocxRun) ToBool() *Bool

func (*DocxRun) Type added in v0.5.13

func (r *DocxRun) Type() ObjectType

Type implementations for DocxRun

func (*DocxRun) TypeTag added in v0.5.13

func (r *DocxRun) TypeTag() TypeTag

type DocxSection added in v0.5.13

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

DocxSection represents a document section.

func (*DocxSection) HashKey added in v0.5.13

func (s *DocxSection) HashKey() HashKey

func (*DocxSection) Inspect added in v0.5.13

func (s *DocxSection) Inspect() string

func (*DocxSection) ToBool added in v0.5.13

func (s *DocxSection) ToBool() *Bool

func (*DocxSection) Type added in v0.5.13

func (s *DocxSection) Type() ObjectType

Type implementations for DocxSection

func (*DocxSection) TypeTag added in v0.5.13

func (s *DocxSection) TypeTag() TypeTag

type DocxShape added in v0.5.13

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

DocxShape represents a shape.

func (*DocxShape) HashKey added in v0.5.13

func (s *DocxShape) HashKey() HashKey

func (*DocxShape) Inspect added in v0.5.13

func (s *DocxShape) Inspect() string

func (*DocxShape) ToBool added in v0.5.13

func (s *DocxShape) ToBool() *Bool

func (*DocxShape) Type added in v0.5.13

func (s *DocxShape) Type() ObjectType

Type implementations for DocxShape

func (*DocxShape) TypeTag added in v0.5.13

func (s *DocxShape) TypeTag() TypeTag

type DocxStyle added in v0.5.13

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

DocxStyle represents a document style.

func (*DocxStyle) HashKey added in v0.5.13

func (s *DocxStyle) HashKey() HashKey

func (*DocxStyle) Inspect added in v0.5.13

func (s *DocxStyle) Inspect() string

func (*DocxStyle) ToBool added in v0.5.13

func (s *DocxStyle) ToBool() *Bool

func (*DocxStyle) Type added in v0.5.13

func (s *DocxStyle) Type() ObjectType

Type implementations for DocxStyle

func (*DocxStyle) TypeTag added in v0.5.13

func (s *DocxStyle) TypeTag() TypeTag

type DocxTOC added in v0.5.13

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

DocxTOC represents a table of contents.

func (*DocxTOC) HashKey added in v0.5.13

func (t *DocxTOC) HashKey() HashKey

func (*DocxTOC) Inspect added in v0.5.13

func (t *DocxTOC) Inspect() string

func (*DocxTOC) ToBool added in v0.5.13

func (t *DocxTOC) ToBool() *Bool

func (*DocxTOC) Type added in v0.5.13

func (t *DocxTOC) Type() ObjectType

Type implementations for DocxTOC

func (*DocxTOC) TypeTag added in v0.5.13

func (t *DocxTOC) TypeTag() TypeTag

type DocxTable added in v0.5.13

type DocxTable struct {
	Document *DocxDocument
	XmlNode  *XMLNode

	// Cached dimensions
	Rows int
	Cols int
}

DocxTable represents a table in a Word document.

func (*DocxTable) HashKey added in v0.5.13

func (t *DocxTable) HashKey() HashKey

func (*DocxTable) Inspect added in v0.5.13

func (t *DocxTable) Inspect() string

func (*DocxTable) ToBool added in v0.5.13

func (t *DocxTable) ToBool() *Bool

func (*DocxTable) Type added in v0.5.13

func (t *DocxTable) Type() ObjectType

Type implementations for DocxTable

func (*DocxTable) TypeTag added in v0.5.13

func (t *DocxTable) TypeTag() TypeTag

type DocxTableCell added in v0.5.13

type DocxTableCell struct {
	Row     *DocxTableRow
	XmlNode *XMLNode
	ColIdx  int
}

DocxTableCell represents a table cell.

func (*DocxTableCell) HashKey added in v0.5.13

func (c *DocxTableCell) HashKey() HashKey

func (*DocxTableCell) Inspect added in v0.5.13

func (c *DocxTableCell) Inspect() string

func (*DocxTableCell) ToBool added in v0.5.13

func (c *DocxTableCell) ToBool() *Bool

func (*DocxTableCell) Type added in v0.5.13

func (c *DocxTableCell) Type() ObjectType

Type implementations for DocxTableCell

func (*DocxTableCell) TypeTag added in v0.5.13

func (c *DocxTableCell) TypeTag() TypeTag

type DocxTableRow added in v0.5.13

type DocxTableRow struct {
	Table   *DocxTable
	XmlNode *XMLNode
	Index   int
}

DocxTableRow represents a table row.

func (*DocxTableRow) HashKey added in v0.5.13

func (r *DocxTableRow) HashKey() HashKey

func (*DocxTableRow) Inspect added in v0.5.13

func (r *DocxTableRow) Inspect() string

func (*DocxTableRow) ToBool added in v0.5.13

func (r *DocxTableRow) ToBool() *Bool

func (*DocxTableRow) Type added in v0.5.13

func (r *DocxTableRow) Type() ObjectType

Type implementations for DocxTableRow

func (*DocxTableRow) TypeTag added in v0.5.13

func (r *DocxTableRow) TypeTag() TypeTag

type DocxTextBox added in v0.5.13

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

DocxTextBox represents a text box.

func (*DocxTextBox) HashKey added in v0.5.13

func (t *DocxTextBox) HashKey() HashKey

func (*DocxTextBox) Inspect added in v0.5.13

func (t *DocxTextBox) Inspect() string

func (*DocxTextBox) ToBool added in v0.5.13

func (t *DocxTextBox) ToBool() *Bool

func (*DocxTextBox) Type added in v0.5.13

func (t *DocxTextBox) Type() ObjectType

Type implementations for DocxTextBox

func (*DocxTextBox) TypeTag added in v0.5.13

func (t *DocxTextBox) TypeTag() TypeTag

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 FtpClient added in v0.5.9

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

FtpClient represents an FTP client connection.

func NewFtpClient added in v0.5.9

func NewFtpClient() *FtpClient

NewFtpClient creates a new FtpClient (unconnected).

func (*FtpClient) ChangeDir added in v0.5.9

func (c *FtpClient) ChangeDir(path string) error

ChangeDir changes the current working directory.

func (*FtpClient) Close added in v0.5.9

func (c *FtpClient) Close() error

Close closes the FTP connection.

func (*FtpClient) Connect added in v0.5.9

func (c *FtpClient) Connect(host string, port int, user, password string) error

Connect establishes FTP connection with credentials.

func (*FtpClient) ConnectWithConfig added in v0.5.9

func (c *FtpClient) ConnectWithConfig(config *FtpConfig) error

ConnectWithConfig establishes FTP connection with full configuration.

func (*FtpClient) CurrentDir added in v0.5.9

func (c *FtpClient) CurrentDir() (string, error)

CurrentDir returns the current working directory.

func (*FtpClient) Delete added in v0.5.9

func (c *FtpClient) Delete(remotePath string) error

Delete deletes a remote file.

func (*FtpClient) Download added in v0.5.9

func (c *FtpClient) Download(remotePath, localPath string) error

Download downloads a remote file to the local filesystem.

func (*FtpClient) Exists added in v0.5.9

func (c *FtpClient) Exists(remotePath string) bool

Exists checks if a remote path exists.

func (*FtpClient) GetHost added in v0.5.9

func (c *FtpClient) GetHost() string

GetHost returns the connected host.

func (*FtpClient) GetPort added in v0.5.9

func (c *FtpClient) GetPort() int

GetPort returns the connected port.

func (*FtpClient) GetUser added in v0.5.9

func (c *FtpClient) GetUser() string

GetUser returns the username.

func (*FtpClient) HashKey added in v0.5.9

func (c *FtpClient) HashKey() HashKey

HashKey returns a hash key for the FtpClient.

func (*FtpClient) Inspect added in v0.5.9

func (c *FtpClient) Inspect() string

Inspect returns a string representation of the FtpClient.

func (*FtpClient) IsConnected added in v0.5.9

func (c *FtpClient) IsConnected() bool

IsConnected returns the connection status.

func (*FtpClient) IsDir added in v0.5.9

func (c *FtpClient) IsDir(remotePath string) bool

IsDir checks if a remote path is a directory.

func (*FtpClient) IsFile added in v0.5.9

func (c *FtpClient) IsFile(remotePath string) bool

IsFile checks if a remote path is a file.

func (*FtpClient) ListDir added in v0.5.9

func (c *FtpClient) ListDir(remotePath string) ([]FtpFileInfo, error)

ListDir lists the contents of a remote directory.

func (*FtpClient) Mkdir added in v0.5.9

func (c *FtpClient) Mkdir(remotePath string) error

Mkdir creates a remote directory.

func (*FtpClient) MkdirAll added in v0.5.9

func (c *FtpClient) MkdirAll(remotePath string) error

MkdirAll creates a remote directory with parents.

func (*FtpClient) ModTime added in v0.5.9

func (c *FtpClient) ModTime(remotePath string) (time.Time, error)

ModTime returns the modification time of a remote file.

func (*FtpClient) Rename added in v0.5.9

func (c *FtpClient) Rename(oldPath, newPath string) error

Rename renames a remote file.

func (*FtpClient) Rmdir added in v0.5.9

func (c *FtpClient) Rmdir(remotePath string) error

Rmdir removes an empty remote directory.

func (*FtpClient) RmdirAll added in v0.5.9

func (c *FtpClient) RmdirAll(remotePath string) error

RmdirAll removes a remote directory recursively.

func (*FtpClient) SetPassive added in v0.5.9

func (c *FtpClient) SetPassive(enabled bool) error

SetPassive enables or disables passive mode.

func (*FtpClient) SetType added in v0.5.9

func (c *FtpClient) SetType(transferType string) error

SetType sets the transfer type (binary or ascii).

func (*FtpClient) Size added in v0.5.9

func (c *FtpClient) Size(remotePath string) (int64, error)

Size returns the size of a remote file.

func (*FtpClient) ToBool added in v0.5.9

func (c *FtpClient) ToBool() *Bool

ToBool returns true if connected.

func (*FtpClient) Type added in v0.5.9

func (c *FtpClient) Type() ObjectType

Type returns the object type.

func (*FtpClient) TypeTag added in v0.5.9

func (c *FtpClient) TypeTag() TypeTag

TypeTag returns the fast type tag.

func (*FtpClient) Upload added in v0.5.9

func (c *FtpClient) Upload(localPath, remotePath string) error

Upload uploads a local file to the remote server.

type FtpConfig added in v0.5.9

type FtpConfig struct {
	Host     string
	Port     int
	User     string
	Password string
	Timeout  int // seconds
	Passive  bool
	Binary   bool
}

FtpConfig holds FTP connection configuration.

type FtpFileInfo added in v0.5.9

type FtpFileInfo struct {
	Name  string
	Size  int64
	IsDir bool
	Mode  string
}

FileInfo represents file information from FTP listing.

type FtpServer added in v0.5.9

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

FtpServer represents an FTP server.

func NewFtpServer added in v0.5.9

func NewFtpServer() *FtpServer

NewFtpServer creates a new FtpServer.

func (*FtpServer) AddUser added in v0.5.9

func (s *FtpServer) AddUser(username, password, homeDir string) error

AddUser adds a user account.

func (*FtpServer) Create added in v0.5.9

func (s *FtpServer) Create(addr string, config *FtpServerConfig) error

Create creates and configures the FTP server.

func (*FtpServer) HashKey added in v0.5.9

func (s *FtpServer) HashKey() HashKey

HashKey returns a hash key for the FtpServer.

func (*FtpServer) Inspect added in v0.5.9

func (s *FtpServer) Inspect() string

Inspect returns a string representation of the FtpServer.

func (*FtpServer) IsRunning added in v0.5.9

func (s *FtpServer) IsRunning() bool

IsRunning returns true if the server is running.

func (*FtpServer) RemoveUser added in v0.5.9

func (s *FtpServer) RemoveUser(username string) error

RemoveUser removes a user account.

func (*FtpServer) Start added in v0.5.9

func (s *FtpServer) Start() error

Start starts the FTP server.

func (*FtpServer) Stop added in v0.5.9

func (s *FtpServer) Stop() error

Stop stops the FTP server.

func (*FtpServer) ToBool added in v0.5.9

func (s *FtpServer) ToBool() *Bool

ToBool returns true if running.

func (*FtpServer) Type added in v0.5.9

func (s *FtpServer) Type() ObjectType

Type returns the object type.

func (*FtpServer) TypeTag added in v0.5.9

func (s *FtpServer) TypeTag() TypeTag

TypeTag returns the fast type tag.

type FtpServerConfig added in v0.5.9

type FtpServerConfig struct {
	Host           string
	Port           int
	PassivePorts   string // e.g., "50000-51000"
	MaxConnections int
	Timeout        int // seconds
	WelcomeMessage string
	PassivePortMin int
	PassivePortMax int
}

FtpServerConfig holds FTP server configuration.

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 HTMLDocument added in v0.5.10

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

HTMLDocument represents an HTML document.

func NewHTMLDocument added in v0.5.10

func NewHTMLDocument() *HTMLDocument

NewHTMLDocument creates a new HTML document.

func NewHTMLDocumentWithTitle added in v0.5.10

func NewHTMLDocumentWithTitle(title string) *HTMLDocument

NewHTMLDocumentWithTitle creates a new HTML document with a title.

func ParseHTML added in v0.5.10

func ParseHTML(htmlStr string) (*HTMLDocument, error)

ParseHTML parses an HTML string and returns an HTMLDocument.

func ParseHTMLFile added in v0.5.10

func ParseHTMLFile(path string) (*HTMLDocument, error)

ParseHTMLFile parses an HTML file and returns an HTMLDocument.

func ParseHTMLFromReader added in v0.5.10

func ParseHTMLFromReader(r io.Reader) (*HTMLDocument, error)

ParseHTMLFromReader parses HTML from an io.Reader.

func (*HTMLDocument) AddScript added in v0.5.10

func (d *HTMLDocument) AddScript(js string, src string)

AddScript adds a script tag to the body.

func (*HTMLDocument) AddStyle added in v0.5.10

func (d *HTMLDocument) AddStyle(css string)

AddStyle adds a style tag to the head.

func (*HTMLDocument) Body added in v0.5.10

func (d *HTMLDocument) Body() *HTMLElement

Body returns the body element.

func (*HTMLDocument) DocType added in v0.5.10

func (d *HTMLDocument) DocType() string

DocType returns the document type declaration.

func (*HTMLDocument) Find added in v0.5.10

func (d *HTMLDocument) Find(selector string) *Array

Find is an alias for QuerySelectorAll.

func (*HTMLDocument) FindFirst added in v0.5.10

func (d *HTMLDocument) FindFirst(selector string) *HTMLElement

FindFirst is an alias for QuerySelector.

func (*HTMLDocument) GetElementById added in v0.5.10

func (d *HTMLDocument) GetElementById(id string) *HTMLElement

GetElementById returns the element with the specified ID.

func (*HTMLDocument) GetElementsByClassName added in v0.5.10

func (d *HTMLDocument) GetElementsByClassName(className string) *Array

GetElementsByClassName returns all elements with the specified class name.

func (*HTMLDocument) GetElementsByTagName added in v0.5.10

func (d *HTMLDocument) GetElementsByTagName(tag string) *Array

GetElementsByTagName returns all elements with the specified tag name.

func (*HTMLDocument) HashKey added in v0.5.10

func (d *HTMLDocument) HashKey() HashKey

HashKey returns a hash key for the HTMLDocument.

func (*HTMLDocument) Head added in v0.5.10

func (d *HTMLDocument) Head() *HTMLElement

Head returns the head element.

func (*HTMLDocument) Inspect added in v0.5.10

func (d *HTMLDocument) Inspect() string

Inspect returns a string representation.

func (*HTMLDocument) QuerySelector added in v0.5.10

func (d *HTMLDocument) QuerySelector(selector string) *HTMLElement

QuerySelector returns the first element matching the CSS selector.

func (*HTMLDocument) QuerySelectorAll added in v0.5.10

func (d *HTMLDocument) QuerySelectorAll(selector string) *Array

QuerySelectorAll returns all elements matching the CSS selector.

func (*HTMLDocument) Root added in v0.5.10

func (d *HTMLDocument) Root() *HTMLElement

Root returns the root element.

func (*HTMLDocument) Save added in v0.5.10

func (d *HTMLDocument) Save(path string) error

Save saves the document to a file.

func (*HTMLDocument) SetMeta added in v0.5.10

func (d *HTMLDocument) SetMeta(name, content string)

SetMeta sets a meta tag in the head.

func (*HTMLDocument) SetRoot added in v0.5.10

func (d *HTMLDocument) SetRoot(root *HTMLElement)

SetRoot sets the root element.

func (*HTMLDocument) SetTitle added in v0.5.10

func (d *HTMLDocument) SetTitle(title string)

SetTitle sets the document title.

func (*HTMLDocument) Title added in v0.5.10

func (d *HTMLDocument) Title() string

Title returns the document title.

func (*HTMLDocument) ToBool added in v0.5.10

func (d *HTMLDocument) ToBool() *Bool

ToBool returns true (HTMLDocument is always truthy).

func (*HTMLDocument) ToIndented added in v0.5.10

func (d *HTMLDocument) ToIndented() string

ToIndented converts the document to indented HTML string.

func (*HTMLDocument) ToMap added in v0.5.10

func (d *HTMLDocument) ToMap() *Map

ToMap converts the document to a Map.

func (*HTMLDocument) ToString added in v0.5.10

func (d *HTMLDocument) ToString() string

ToString converts the document to HTML string.

func (*HTMLDocument) Type added in v0.5.10

func (d *HTMLDocument) Type() ObjectType

Type returns the object type.

func (*HTMLDocument) TypeTag added in v0.5.10

func (d *HTMLDocument) TypeTag() TypeTag

TypeTag returns the fast type tag.

type HTMLElement added in v0.5.10

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

HTMLElement represents an HTML element node.

func NewHTMLComment added in v0.5.10

func NewHTMLComment(text string) *HTMLElement

NewHTMLComment creates a new comment node.

func NewHTMLElement added in v0.5.10

func NewHTMLElement(tagName string) *HTMLElement

NewHTMLElement creates a new HTML element.

func NewHTMLTextNode added in v0.5.10

func NewHTMLTextNode(text string) *HTMLElement

NewHTMLTextNode creates a new text node.

func ParseHTMLFragment added in v0.5.10

func ParseHTMLFragment(htmlStr string) ([]*HTMLElement, error)

ParseHTMLFragment parses an HTML fragment and returns elements.

func (*HTMLElement) AddClass added in v0.5.10

func (e *HTMLElement) AddClass(className string)

AddClass adds a class to the element.

func (*HTMLElement) AppendChild added in v0.5.10

func (e *HTMLElement) AppendChild(child *HTMLElement)

AppendChild appends a child element.

func (*HTMLElement) Attribute added in v0.5.10

func (e *HTMLElement) Attribute(name string) string

Attribute returns the attribute value by name.

func (*HTMLElement) Attributes added in v0.5.10

func (e *HTMLElement) Attributes() *Map

Attributes returns all attributes as a Map.

func (*HTMLElement) ChildCount added in v0.5.10

func (e *HTMLElement) ChildCount() int

ChildCount returns the number of children.

func (*HTMLElement) Children added in v0.5.10

func (e *HTMLElement) Children() *Array

Children returns all child elements.

func (*HTMLElement) Class added in v0.5.10

func (e *HTMLElement) Class() string

Class returns the class attribute.

func (*HTMLElement) Clear added in v0.5.10

func (e *HTMLElement) Clear()

Clear removes all children.

func (*HTMLElement) Clone added in v0.5.10

func (e *HTMLElement) Clone() *HTMLElement

Clone returns a deep clone of the element.

func (*HTMLElement) Find added in v0.5.10

func (e *HTMLElement) Find(selector string) *Array

Find is an alias for QuerySelectorAll.

func (*HTMLElement) FindFirst added in v0.5.10

func (e *HTMLElement) FindFirst(selector string) *HTMLElement

FindFirst is an alias for QuerySelector.

func (*HTMLElement) FirstChild added in v0.5.10

func (e *HTMLElement) FirstChild() *HTMLElement

FirstChild returns the first child element.

func (*HTMLElement) HasAttribute added in v0.5.10

func (e *HTMLElement) HasAttribute(name string) bool

HasAttribute checks if an attribute exists.

func (*HTMLElement) HasClass added in v0.5.10

func (e *HTMLElement) HasClass(className string) bool

HasClass checks if the element has a class.

func (*HTMLElement) HashKey added in v0.5.10

func (e *HTMLElement) HashKey() HashKey

HashKey returns a hash key for the HTMLElement.

func (*HTMLElement) ID added in v0.5.10

func (e *HTMLElement) ID() string

ID returns the id attribute.

func (*HTMLElement) InnerHTML added in v0.5.10

func (e *HTMLElement) InnerHTML() string

InnerHTML returns the inner HTML.

func (*HTMLElement) InsertAfter added in v0.5.10

func (e *HTMLElement) InsertAfter(newElem, refElem *HTMLElement) bool

InsertAfter inserts a new element after a reference element.

func (*HTMLElement) InsertBefore added in v0.5.10

func (e *HTMLElement) InsertBefore(newElem, refElem *HTMLElement) bool

InsertBefore inserts a new element before a reference element.

func (*HTMLElement) Inspect added in v0.5.10

func (e *HTMLElement) Inspect() string

Inspect returns a string representation.

func (*HTMLElement) LastChild added in v0.5.10

func (e *HTMLElement) LastChild() *HTMLElement

LastChild returns the last child element.

func (*HTMLElement) NodeType added in v0.5.10

func (e *HTMLElement) NodeType() HTMLNodeType

NodeType returns the node type.

func (*HTMLElement) OuterHTML added in v0.5.10

func (e *HTMLElement) OuterHTML() string

OuterHTML returns the outer HTML.

func (*HTMLElement) Parent added in v0.5.10

func (e *HTMLElement) Parent() *HTMLElement

Parent returns the parent element.

func (*HTMLElement) QuerySelector added in v0.5.10

func (e *HTMLElement) QuerySelector(selector string) *HTMLElement

QuerySelector returns the first element matching the CSS selector.

func (*HTMLElement) QuerySelectorAll added in v0.5.10

func (e *HTMLElement) QuerySelectorAll(selector string) *Array

QuerySelectorAll returns all elements matching the CSS selector.

func (*HTMLElement) Remove added in v0.5.10

func (e *HTMLElement) Remove()

Remove removes the element from its parent.

func (*HTMLElement) RemoveAttribute added in v0.5.10

func (e *HTMLElement) RemoveAttribute(name string)

RemoveAttribute removes an attribute.

func (*HTMLElement) RemoveChild added in v0.5.10

func (e *HTMLElement) RemoveChild(index int) bool

RemoveChild removes a child element by index.

func (*HTMLElement) RemoveClass added in v0.5.10

func (e *HTMLElement) RemoveClass(className string)

RemoveClass removes a class from the element.

func (*HTMLElement) ReplaceChild added in v0.5.10

func (e *HTMLElement) ReplaceChild(newElem, oldElem *HTMLElement) bool

ReplaceChild replaces a child element with a new element.

func (*HTMLElement) SetAttribute added in v0.5.10

func (e *HTMLElement) SetAttribute(name, value string)

SetAttribute sets an attribute.

func (*HTMLElement) SetClass added in v0.5.10

func (e *HTMLElement) SetClass(class string)

SetClass sets the class attribute.

func (*HTMLElement) SetID added in v0.5.10

func (e *HTMLElement) SetID(id string)

SetID sets the id attribute.

func (*HTMLElement) SetInnerHTML added in v0.5.10

func (e *HTMLElement) SetInnerHTML(html string) error

SetInnerHTML sets the inner HTML by parsing it.

func (*HTMLElement) SetTagName added in v0.5.10

func (e *HTMLElement) SetTagName(name string)

SetTagName sets the tag name.

func (*HTMLElement) SetTextContent added in v0.5.10

func (e *HTMLElement) SetTextContent(text string)

SetTextContent sets the text content.

func (*HTMLElement) TagName added in v0.5.10

func (e *HTMLElement) TagName() string

TagName returns the tag name.

func (*HTMLElement) TextContent added in v0.5.10

func (e *HTMLElement) TextContent() string

TextContent returns the text content.

func (*HTMLElement) ToBool added in v0.5.10

func (e *HTMLElement) ToBool() *Bool

ToBool returns true if the element has content.

func (*HTMLElement) ToIndented added in v0.5.10

func (e *HTMLElement) ToIndented() string

ToIndented converts the element to indented HTML string.

func (*HTMLElement) ToMap added in v0.5.10

func (e *HTMLElement) ToMap() *Map

ToMap converts the element to a Map.

func (*HTMLElement) ToString added in v0.5.10

func (e *HTMLElement) ToString() string

ToString converts the element to HTML string.

func (*HTMLElement) ToggleClass added in v0.5.10

func (e *HTMLElement) ToggleClass(className string)

ToggleClass toggles a class on the element.

func (*HTMLElement) Type added in v0.5.10

func (e *HTMLElement) Type() ObjectType

Type returns the object type.

func (*HTMLElement) TypeTag added in v0.5.10

func (e *HTMLElement) TypeTag() TypeTag

TypeTag returns the fast type tag.

type HTMLNodeType added in v0.5.10

type HTMLNodeType int

HTMLNodeType represents the type of HTML node.

const (
	HTMLNodeElement HTMLNodeType = iota
	HTMLNodeText
	HTMLNodeComment
	HTMLNodeDoctype
)

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 ImageObj added in v0.5.13

type ImageObj struct {
	Value image.Image
}

ImageObj represents an image object in Xxlang

func (*ImageObj) HashKey added in v0.5.13

func (i *ImageObj) HashKey() HashKey

func (*ImageObj) Inspect added in v0.5.13

func (i *ImageObj) Inspect() string

func (*ImageObj) ToBool added in v0.5.13

func (i *ImageObj) ToBool() *Bool

func (*ImageObj) Type added in v0.5.13

func (i *ImageObj) Type() ObjectType

func (*ImageObj) TypeTag added in v0.5.13

func (i *ImageObj) TypeTag() TypeTag

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 Lexer added in v0.5.13

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

Lexer holds the lexer state

func NewLexer added in v0.5.13

func NewLexer(input string) *Lexer

NewLexer creates a new lexer

func (*Lexer) AllTokens added in v0.5.13

func (l *Lexer) AllTokens() []Token

AllTokens returns all tokens

func (*Lexer) NextToken added in v0.5.13

func (l *Lexer) NextToken() Token

NextToken returns the next token

type LineEditor added in v0.5.8

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

LineEditor represents a line-based text editor object. It stores lines in memory and provides various editing operations.

func NewLineEditor added in v0.5.8

func NewLineEditor() *LineEditor

NewLineEditor creates a new empty LineEditor.

func NewLineEditorFromFile added in v0.5.8

func NewLineEditorFromFile(path string) (*LineEditor, error)

NewLineEditorFromFile opens a file and creates a LineEditor from its contents.

func NewLineEditorFromLines added in v0.5.8

func NewLineEditorFromLines(lines []string) *LineEditor

NewLineEditorFromLines creates a LineEditor from a string array.

func NewLineEditorFromText added in v0.5.8

func NewLineEditorFromText(text string) *LineEditor

NewLineEditorFromText creates a LineEditor from a text string. The text is split by newlines.

func NewLineEditorWithCapacity added in v0.5.8

func NewLineEditorWithCapacity(capacity int) *LineEditor

NewLineEditorWithCapacity creates a new LineEditor with initial capacity.

func (*LineEditor) AddLine added in v0.5.8

func (le *LineEditor) AddLine(text string)

AddLine adds a line at the end.

func (*LineEditor) AlignLeft added in v0.5.8

func (le *LineEditor) AlignLeft(width int)

AlignLeft aligns all lines to the left by trimming and optionally padding.

func (*LineEditor) AlignRight added in v0.5.8

func (le *LineEditor) AlignRight(width int)

AlignRight aligns all lines to the right by padding.

func (*LineEditor) AppendFromFile added in v0.5.8

func (le *LineEditor) AppendFromFile(path string) error

AppendFromFile appends lines from a file to the editor.

func (*LineEditor) AppendLines added in v0.5.8

func (le *LineEditor) AppendLines(newLines []string)

AppendLines appends multiple lines at the end.

func (*LineEditor) AppendToFile added in v0.5.8

func (le *LineEditor) AppendToFile(path string) error

AppendToFile appends the content to an existing file.

func (*LineEditor) Center added in v0.5.8

func (le *LineEditor) Center(width int)

Center centers each line within the specified width.

func (*LineEditor) CharCount added in v0.5.8

func (le *LineEditor) CharCount() int

CharCount returns the total number of bytes in all lines.

func (*LineEditor) Clear added in v0.5.8

func (le *LineEditor) Clear()

Clear removes all lines.

func (*LineEditor) Close added in v0.5.8

func (le *LineEditor) Close()

Close releases resources (no-op for LineEditor).

func (*LineEditor) Comment added in v0.5.8

func (le *LineEditor) Comment(prefix string)

Comment adds a comment prefix to each line.

func (*LineEditor) CountEmpty added in v0.5.8

func (le *LineEditor) CountEmpty() int

CountEmpty returns the number of empty lines.

func (*LineEditor) Dedent added in v0.5.8

func (le *LineEditor) Dedent()

Dedent removes common indentation from all lines.

func (*LineEditor) DeleteLine added in v0.5.8

func (le *LineEditor) DeleteLine(n int) bool

DeleteLine deletes the line at index n (1-based). Returns false if out of range.

func (*LineEditor) DeleteLines added in v0.5.8

func (le *LineEditor) DeleteLines(start, end int) bool

DeleteLines deletes lines in the range [start, end] (1-based, inclusive).

func (*LineEditor) DuplicateLine added in v0.5.8

func (le *LineEditor) DuplicateLine(n int) bool

DuplicateLine duplicates a line at the given index (1-based).

func (*LineEditor) Find added in v0.5.8

func (le *LineEditor) Find(text string) []int

Find returns line numbers (1-based) containing the text.

func (*LineEditor) FindAll added in v0.5.8

func (le *LineEditor) FindAll(text string) []string

FindAll returns all lines containing the text.

func (*LineEditor) FindDupes added in v0.5.8

func (le *LineEditor) FindDupes() map[string]int

FindDupes returns duplicate lines with counts as a map.

func (*LineEditor) FindFirst added in v0.5.8

func (le *LineEditor) FindFirst(text string) int

FindFirst returns the first line number (1-based) containing the text, or 0 if not found.

func (*LineEditor) FindLast added in v0.5.8

func (le *LineEditor) FindLast(text string) int

FindLast returns the last line number (1-based) containing the text, or 0 if not found.

func (*LineEditor) FindRegex added in v0.5.8

func (le *LineEditor) FindRegex(pattern string) ([]int, error)

FindRegex returns line numbers (1-based) matching the pattern.

func (*LineEditor) GetFilePath added in v0.5.8

func (le *LineEditor) GetFilePath() string

GetFilePath returns the associated file path.

func (*LineEditor) GetLine added in v0.5.8

func (le *LineEditor) GetLine(n int) (string, bool)

GetLine returns the line at index n (1-based, supports negative index). Returns empty string and false if index is out of range.

func (*LineEditor) GetLines added in v0.5.8

func (le *LineEditor) GetLines(start, end int) []string

GetLines returns lines in the range [start, end] (1-based, inclusive).

func (*LineEditor) Grep added in v0.5.8

func (le *LineEditor) Grep(text string) *LineEditor

Grep filters lines containing text and returns a new LineEditor.

func (*LineEditor) GrepNot added in v0.5.8

func (le *LineEditor) GrepNot(text string) *LineEditor

GrepNot filters lines NOT containing text and returns a new LineEditor.

func (*LineEditor) GrepNotRegex added in v0.5.8

func (le *LineEditor) GrepNotRegex(pattern string) (*LineEditor, error)

GrepNotRegex filters lines NOT matching pattern and returns a new LineEditor.

func (*LineEditor) GrepRegex added in v0.5.8

func (le *LineEditor) GrepRegex(pattern string) (*LineEditor, error)

GrepRegex filters lines matching pattern and returns a new LineEditor.

func (*LineEditor) HashKey added in v0.5.8

func (le *LineEditor) HashKey() HashKey

HashKey returns a hash key for the LineEditor.

func (*LineEditor) Head added in v0.5.8

func (le *LineEditor) Head(n int) []string

Head returns the first n lines.

func (*LineEditor) Indent added in v0.5.8

func (le *LineEditor) Indent(prefix string)

Indent adds prefix to each line.

func (*LineEditor) Info added in v0.5.8

func (le *LineEditor) Info() map[string]int

Info returns a map with statistics about the editor content.

func (*LineEditor) InsertLine added in v0.5.8

func (le *LineEditor) InsertLine(n int, text string) bool

InsertLine inserts a line before index n (1-based). Returns false if out of range.

func (*LineEditor) Inspect added in v0.5.8

func (le *LineEditor) Inspect() string

Inspect returns a string representation of the LineEditor.

func (*LineEditor) IsEmpty added in v0.5.8

func (le *LineEditor) IsEmpty() bool

IsEmpty checks if the editor is empty.

func (*LineEditor) IsModified added in v0.5.8

func (le *LineEditor) IsModified() bool

IsModified checks if the content has been modified.

func (*LineEditor) Join added in v0.5.8

func (le *LineEditor) Join(sep string) string

Join joins all lines into one with separator.

func (*LineEditor) KeepDupes added in v0.5.8

func (le *LineEditor) KeepDupes()

KeepDupes keeps only duplicate lines (removes unique lines).

func (*LineEditor) LineCount added in v0.5.8

func (le *LineEditor) LineCount() int

LineCount returns the number of lines.

func (*LineEditor) MoveLine added in v0.5.8

func (le *LineEditor) MoveLine(from, to int) bool

MoveLine moves a line from one position to another (1-based).

func (*LineEditor) NumberLines added in v0.5.8

func (le *LineEditor) NumberLines(start int)

NumberLines adds line number prefix to each line.

func (*LineEditor) PadLeft added in v0.5.8

func (le *LineEditor) PadLeft(width int, padChar string)

PadLeft pads each line on the left to the specified width with the given character.

func (*LineEditor) PadRight added in v0.5.8

func (le *LineEditor) PadRight(width int, padChar string)

PadRight pads each line to the specified width with the given character.

func (*LineEditor) Prefix added in v0.5.8

func (le *LineEditor) Prefix(prefix string)

Prefix adds prefix to each line.

func (*LineEditor) RemoveBlank added in v0.5.8

func (le *LineEditor) RemoveBlank()

RemoveBlank removes blank lines (whitespace only).

func (*LineEditor) RemoveDupes added in v0.5.8

func (le *LineEditor) RemoveDupes()

RemoveDupes removes all duplicate lines (keeps only unique lines).

func (*LineEditor) RemoveEmpty added in v0.5.8

func (le *LineEditor) RemoveEmpty()

RemoveEmpty removes empty lines.

func (*LineEditor) Replace added in v0.5.8

func (le *LineEditor) Replace(old, new string) int

Replace replaces all occurrences of old text with new text in all lines. Returns the number of replacements made.

func (*LineEditor) ReplaceFirst added in v0.5.8

func (le *LineEditor) ReplaceFirst(old, new string) bool

ReplaceFirst replaces the first occurrence globally.

func (*LineEditor) ReplaceLast added in v0.5.8

func (le *LineEditor) ReplaceLast(old, new string) bool

ReplaceLast replaces the last occurrence globally.

func (*LineEditor) ReplaceLine added in v0.5.8

func (le *LineEditor) ReplaceLine(n int, old, new string) int

ReplaceLine replaces only in the specified line (1-based).

func (*LineEditor) ReplaceRange added in v0.5.8

func (le *LineEditor) ReplaceRange(start, end int, old, new string) int

ReplaceRange replaces within the specified line range [start, end] (1-based).

func (*LineEditor) ReplaceRegex added in v0.5.8

func (le *LineEditor) ReplaceRegex(pattern, new string) (int, error)

ReplaceRegex replaces all matches of pattern with new text.

func (*LineEditor) Reverse added in v0.5.8

func (le *LineEditor) Reverse()

Reverse reverses the line order.

func (*LineEditor) RuneCount added in v0.5.8

func (le *LineEditor) RuneCount() int

RuneCount returns the total number of runes (Unicode code points) in all lines.

func (*LineEditor) Sample added in v0.5.8

func (le *LineEditor) Sample(n int) *LineEditor

Sample returns a new LineEditor with n randomly selected lines.

func (*LineEditor) Save added in v0.5.8

func (le *LineEditor) Save() error

Save saves to the original file.

func (*LineEditor) SaveAs added in v0.5.8

func (le *LineEditor) SaveAs(path string) error

SaveAs saves to a new file.

func (*LineEditor) SelectLines added in v0.5.8

func (le *LineEditor) SelectLines(indices []int) *LineEditor

SelectLines returns a new LineEditor with only the lines at specified indices.

func (*LineEditor) SetFilePath added in v0.5.8

func (le *LineEditor) SetFilePath(path string)

SetFilePath sets the associated file path.

func (*LineEditor) SetLine added in v0.5.8

func (le *LineEditor) SetLine(n int, text string) bool

SetLine sets the line at index n (1-based). Returns false if out of range.

func (*LineEditor) SetLines added in v0.5.8

func (le *LineEditor) SetLines(start int, newLines []string) bool

SetLines replaces lines in the range starting from start (1-based).

func (*LineEditor) Shuffle added in v0.5.8

func (le *LineEditor) Shuffle()

Shuffle randomizes the line order.

func (*LineEditor) Sort added in v0.5.8

func (le *LineEditor) Sort()

Sort sorts lines alphabetically (ascending).

func (*LineEditor) SortByCol added in v0.5.8

func (le *LineEditor) SortByCol(col int, sep string)

SortByCol sorts by specified column (1-based).

func (*LineEditor) SortByColNum added in v0.5.8

func (le *LineEditor) SortByColNum(col int, sep string)

SortByColNum sorts by specified column numerically (1-based).

func (*LineEditor) SortDesc added in v0.5.8

func (le *LineEditor) SortDesc()

SortDesc sorts lines alphabetically (descending).

func (*LineEditor) SortNum added in v0.5.8

func (le *LineEditor) SortNum()

SortNum sorts lines numerically (ascending). Non-numeric lines are placed at the end.

func (*LineEditor) SortNumDesc added in v0.5.8

func (le *LineEditor) SortNumDesc()

SortNumDesc sorts lines numerically (descending).

func (*LineEditor) SplitLines added in v0.5.8

func (le *LineEditor) SplitLines(sep string)

SplitLines splits each line by separator into multiple lines.

func (*LineEditor) StripPrefix added in v0.5.8

func (le *LineEditor) StripPrefix(prefix string)

StripPrefix removes a prefix from each line if present.

func (*LineEditor) StripSuffix added in v0.5.8

func (le *LineEditor) StripSuffix(suffix string)

StripSuffix removes a suffix from each line if present.

func (*LineEditor) Suffix added in v0.5.8

func (le *LineEditor) Suffix(suffix string)

Suffix adds suffix to each line.

func (*LineEditor) SwapLines added in v0.5.8

func (le *LineEditor) SwapLines(n1, n2 int) bool

SwapLines swaps two lines at the given indices (1-based).

func (*LineEditor) Tail added in v0.5.8

func (le *LineEditor) Tail(n int) []string

Tail returns the last n lines.

func (*LineEditor) TakeLines added in v0.5.8

func (le *LineEditor) TakeLines(start, end int) []string

TakeLines extracts and removes a range of lines, returning them.

func (*LineEditor) ToBool added in v0.5.8

func (le *LineEditor) ToBool() *Bool

ToBool returns true (LineEditor is always truthy).

func (*LineEditor) ToLines added in v0.5.8

func (le *LineEditor) ToLines() []string

ToLines returns the line array.

func (*LineEditor) ToLowerCase added in v0.5.8

func (le *LineEditor) ToLowerCase()

ToLowerCase converts all lines to lowercase.

func (*LineEditor) ToText added in v0.5.8

func (le *LineEditor) ToText() string

ToText returns the full text with newlines.

func (*LineEditor) ToUpperCase added in v0.5.8

func (le *LineEditor) ToUpperCase()

ToUpperCase converts all lines to uppercase.

func (*LineEditor) Trim added in v0.5.8

func (le *LineEditor) Trim()

Trim trims whitespace from each line.

func (*LineEditor) TrimLeft added in v0.5.8

func (le *LineEditor) TrimLeft()

TrimLeft trims leading whitespace from each line.

func (*LineEditor) TrimRight added in v0.5.8

func (le *LineEditor) TrimRight()

TrimRight trims trailing whitespace from each line.

func (*LineEditor) Truncate added in v0.5.8

func (le *LineEditor) Truncate(maxLen int)

Truncate truncates each line to the specified maximum length.

func (*LineEditor) TruncateWithEllipsis added in v0.5.8

func (le *LineEditor) TruncateWithEllipsis(maxLen int)

TruncateWithEllipsis truncates each line and adds "..." if truncated.

func (*LineEditor) Type added in v0.5.8

func (le *LineEditor) Type() ObjectType

Type returns the object type.

func (*LineEditor) TypeTag added in v0.5.8

func (le *LineEditor) TypeTag() TypeTag

TypeTag returns the fast type tag.

func (*LineEditor) Uncomment added in v0.5.8

func (le *LineEditor) Uncomment(prefix string)

Uncomment removes a comment prefix from each line.

func (*LineEditor) Unique added in v0.5.8

func (le *LineEditor) Unique()

Unique removes duplicate lines (keeps first occurrence).

func (*LineEditor) UniqueSorted added in v0.5.8

func (le *LineEditor) UniqueSorted()

UniqueSorted sorts then removes duplicates.

func (*LineEditor) ViewAll added in v0.5.8

func (le *LineEditor) ViewAll(showNumber bool) []string

ViewAll returns all lines formatted (with optional line numbers).

func (*LineEditor) ViewLine added in v0.5.8

func (le *LineEditor) ViewLine(n int, showNumber bool) string

ViewLine returns a formatted string for the specified line (with line number).

func (*LineEditor) ViewLines added in v0.5.8

func (le *LineEditor) ViewLines(start, end int, showNumber bool) []string

ViewLines returns formatted strings for a range of lines.

func (*LineEditor) WordCount added in v0.5.8

func (le *LineEditor) WordCount() int

WordCount returns the total number of words in all lines.

type MailClient added in v0.5.13

type MailClient struct {
	Host     string
	Port     int
	User     string
	Password string
	From     string
	FromName string
	UseTLS   bool
}

MailClient represents an email client configuration

func (*MailClient) HashKey added in v0.5.13

func (m *MailClient) HashKey() HashKey

HashKey returns a hash key

func (*MailClient) Inspect added in v0.5.13

func (m *MailClient) Inspect() string

Inspect returns a string representation

func (*MailClient) ToBool added in v0.5.13

func (m *MailClient) ToBool() *Bool

ToBool returns true

func (*MailClient) Type added in v0.5.13

func (m *MailClient) Type() ObjectType

Type returns the object type

func (*MailClient) TypeTag added in v0.5.13

func (m *MailClient) TypeTag() TypeTag

TypeTag returns the type tag

type Map

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

Map represents a map value

func DeepMergeYAMLMaps added in v0.5.10

func DeepMergeYAMLMaps(maps ...*Map) *Map

DeepMergeYAMLMaps performs a deep merge of YAML maps

func MergeYAMLMaps added in v0.5.10

func MergeYAMLMaps(maps ...*Map) *Map

MergeYAMLMaps merges multiple YAML maps

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 YAMLSet added in v0.5.10

func YAMLSet(elements []Object) *Map

YAMLSet wraps an array to represent a YAML set (unique values)

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

func ParseYAMLPairs added in v0.5.10

func ParseYAMLPairs(yamlStr string) ([]MapPair, error)

ParseYAMLPairs parses key-value pairs from a YAML mapping

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 InterfaceToObject added in v0.5.13

func InterfaceToObject(v interface{}) Object

InterfaceToObject converts Go interface{} to Object (exported for crypto module)

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 ParseYAML added in v0.5.10

func ParseYAML(s string) (Object, error)

ParseYAML parses a YAML string and returns an Xxlang Object. This is the main entry point for YAML parsing.

func ParseYAMLDocuments added in v0.5.10

func ParseYAMLDocuments(s string) ([]Object, error)

ParseYAMLDocuments parses a YAML string with multiple documents.

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.

func YAMLPathQuery added in v0.5.10

func YAMLPathQuery(obj Object, path string) Object

YAMLPathQuery queries a YAML object using a simple path syntax

func YAMLPathSet added in v0.5.10

func YAMLPathSet(obj Object, path string, value Object) Object

YAMLPathSet sets a value in a YAML object using a path

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"
	// Socket types
	SocketAddrType ObjectType = "SOCKET_ADDR"
	TcpServerType  ObjectType = "TCP_SERVER"
	TcpClientType  ObjectType = "TCP_CLIENT"
	UdpSocketType  ObjectType = "UDP_SOCKET"
	// LineEditor type
	LineEditorType ObjectType = "LINE_EDITOR"
	// SSH types
	SSHClientType ObjectType = "SSH_CLIENT"
	// FTP/SFTP types
	FtpClientType  ObjectType = "FTP_CLIENT"
	FtpServerType  ObjectType = "FTP_SERVER"
	SftpClientType ObjectType = "SFTP_CLIENT"
	SftpServerType ObjectType = "SFTP_SERVER"
	// HTML types
	HTMLDocumentType ObjectType = "HTML_DOCUMENT"
	HTMLElementType  ObjectType = "HTML_ELEMENT"
	// YAML types
	YAMLDocumentType ObjectType = "YAML_DOCUMENT"
	// TOML types
	TomlDocumentType ObjectType = "TOML_DOCUMENT"
	// Time type
	TimeType ObjectType = "TIME"
)

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.6

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.6

func AcquireOrderedMap() *OrderedMap

AcquireOrderedMap gets an OrderedMap from the pool

func NewOrderedMap added in v0.5.6

func NewOrderedMap() *OrderedMap

NewOrderedMap creates a new empty OrderedMap

func NewOrderedMapWithCapacity added in v0.5.6

func NewOrderedMapWithCapacity(capacity int) *OrderedMap

NewOrderedMapWithCapacity creates a new OrderedMap with pre-allocated capacity

func YAMLOMap added in v0.5.10

func YAMLOMap(pairs []MapPair) *OrderedMap

YAMLOMap creates an ordered map from key-value pairs

func (*OrderedMap) Clone added in v0.5.6

func (om *OrderedMap) Clone() *OrderedMap

Clone creates a deep copy of the OrderedMap

func (*OrderedMap) Delete added in v0.5.6

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.6

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.6

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.6

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.6

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

GetOrderedKeys returns keys in insertion order

func (*OrderedMap) GetOrderedPairs added in v0.5.6

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

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

func (*OrderedMap) GetOrderedValues added in v0.5.6

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

GetOrderedValues returns values in insertion order

func (*OrderedMap) HasKey added in v0.5.6

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

HasKey checks if a key exists

func (*OrderedMap) HashKey added in v0.5.6

func (om *OrderedMap) HashKey() HashKey

HashKey returns an empty HashKey (OrderedMaps are not hashable)

func (*OrderedMap) InsertAt added in v0.5.6

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.6

func (om *OrderedMap) Inspect() string

Inspect returns a string representation of the OrderedMap

func (*OrderedMap) Len added in v0.5.6

func (om *OrderedMap) Len() int

Len returns the number of key-value pairs

func (*OrderedMap) MoveAfter added in v0.5.6

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.6

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.6

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.6

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.6

func (om *OrderedMap) Reverse()

Reverse reverses the order of all elements

func (*OrderedMap) Set added in v0.5.6

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.6

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.6

func (om *OrderedMap) SortByKey()

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

func (*OrderedMap) Swap added in v0.5.6

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.6

func (om *OrderedMap) ToBool() *Bool

ToBool returns TRUE if the map has elements, FALSE otherwise

func (*OrderedMap) ToMap added in v0.5.6

func (om *OrderedMap) ToMap() *Map

ToMap converts the OrderedMap to a regular Map

func (*OrderedMap) Type added in v0.5.6

func (om *OrderedMap) Type() ObjectType

Type returns the object type

func (*OrderedMap) TypeTag added in v0.5.6

func (om *OrderedMap) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type OrderedMapPair added in v0.5.6

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.6

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

PPTXAudio represents an audio on a slide.

func (*PPTXAudio) GetData added in v0.5.6

func (a *PPTXAudio) GetData() []byte

GetData returns the audio data.

func (*PPTXAudio) GetFormat added in v0.5.6

func (a *PPTXAudio) GetFormat() string

GetFormat returns the audio format.

func (*PPTXAudio) GetPosition added in v0.5.6

func (a *PPTXAudio) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXAudio) HashKey added in v0.5.6

func (a *PPTXAudio) HashKey() HashKey

func (*PPTXAudio) Inspect added in v0.5.6

func (a *PPTXAudio) Inspect() string

func (*PPTXAudio) Save added in v0.5.6

func (a *PPTXAudio) Save(path string) error

Save saves the audio to a file.

func (*PPTXAudio) SetPosition added in v0.5.6

func (a *PPTXAudio) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXAudio) ToBool added in v0.5.6

func (a *PPTXAudio) ToBool() *Bool

func (*PPTXAudio) Type added in v0.5.6

func (a *PPTXAudio) Type() ObjectType

Type implementations for PPTXAudio

func (*PPTXAudio) TypeTag added in v0.5.6

func (a *PPTXAudio) TypeTag() TypeTag

type PPTXBulletStyle added in v0.5.6

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.6

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.6

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

PPTXChart represents a chart on a slide.

func (*PPTXChart) GetKind added in v0.5.6

func (c *PPTXChart) GetKind() PPTXChartKind

GetKind returns the chart kind.

func (*PPTXChart) GetPosition added in v0.5.6

func (c *PPTXChart) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXChart) GetSeries added in v0.5.6

func (c *PPTXChart) GetSeries() []*PPTXChartSeries

GetSeries returns all series.

func (*PPTXChart) GetSeriesCount added in v0.5.6

func (c *PPTXChart) GetSeriesCount() int

GetSeriesCount returns the number of series.

func (*PPTXChart) GetSize added in v0.5.6

func (c *PPTXChart) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXChart) GetTitle added in v0.5.6

func (c *PPTXChart) GetTitle() string

GetTitle returns the chart title.

func (*PPTXChart) HashKey added in v0.5.6

func (c *PPTXChart) HashKey() HashKey

func (*PPTXChart) Inspect added in v0.5.6

func (c *PPTXChart) Inspect() string

func (*PPTXChart) SetPosition added in v0.5.6

func (c *PPTXChart) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXChart) SetSize added in v0.5.6

func (c *PPTXChart) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXChart) SetTitle added in v0.5.6

func (c *PPTXChart) SetTitle(title string)

SetTitle sets the chart title.

func (*PPTXChart) ToBool added in v0.5.6

func (c *PPTXChart) ToBool() *Bool

func (*PPTXChart) Type added in v0.5.6

func (c *PPTXChart) Type() ObjectType

Type implementations for PPTXChart

func (*PPTXChart) TypeTag added in v0.5.6

func (c *PPTXChart) TypeTag() TypeTag

type PPTXChartData added in v0.5.6

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

PPTXChartData represents chart data.

type PPTXChartKind added in v0.5.6

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.6

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

PPTXChartSeries represents a data series in a chart.

func (*PPTXChartSeries) GetName added in v0.5.6

func (s *PPTXChartSeries) GetName() string

GetName returns the series name.

func (*PPTXChartSeries) GetValues added in v0.5.6

func (s *PPTXChartSeries) GetValues() []float64

GetValues returns the values.

func (*PPTXChartSeries) HashKey added in v0.5.6

func (s *PPTXChartSeries) HashKey() HashKey

func (*PPTXChartSeries) Inspect added in v0.5.6

func (s *PPTXChartSeries) Inspect() string

func (*PPTXChartSeries) SetName added in v0.5.6

func (s *PPTXChartSeries) SetName(name string)

SetName sets the series name.

func (*PPTXChartSeries) SetValues added in v0.5.6

func (s *PPTXChartSeries) SetValues(values []float64)

SetValues sets the values.

func (*PPTXChartSeries) ToBool added in v0.5.6

func (s *PPTXChartSeries) ToBool() *Bool

func (*PPTXChartSeries) Type added in v0.5.6

func (s *PPTXChartSeries) Type() ObjectType

Type implementations for PPTXChartSeries

func (*PPTXChartSeries) TypeTag added in v0.5.6

func (s *PPTXChartSeries) TypeTag() TypeTag

type PPTXChartSeriesData added in v0.5.6

type PPTXChartSeriesData struct {
	Name   string
	Values []float64
}

PPTXChartSeriesData represents a data series input.

type PPTXChartStyle added in v0.5.6

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

PPTXChartStyle represents chart styling.

type PPTXColor added in v0.5.6

type PPTXColor struct {
	R, G, B uint8
}

PPTXColor represents RGB color.

type PPTXDocument added in v0.5.6

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.6

func NewPPTX() *PPTXDocument

NewPPTX creates a new empty presentation.

func OpenPPTX added in v0.5.6

func OpenPPTX(path string) (*PPTXDocument, error)

OpenPPTX opens an existing PPTX file from a file path.

func OpenPPTXFromBytes added in v0.5.6

func OpenPPTXFromBytes(data []byte) (*PPTXDocument, error)

OpenPPTXFromBytes opens a PPTX presentation from a byte slice.

func (*PPTXDocument) AddSlide added in v0.5.6

func (d *PPTXDocument) AddSlide() *PPTXSlide

AddSlide adds a new slide to the presentation.

func (*PPTXDocument) Close added in v0.5.6

func (d *PPTXDocument) Close() error

Close closes the document and releases resources.

func (*PPTXDocument) DeleteSlide added in v0.5.6

func (d *PPTXDocument) DeleteSlide(index int) bool

DeleteSlide deletes a slide by index (1-based).

func (*PPTXDocument) DuplicateSlide added in v0.5.6

func (d *PPTXDocument) DuplicateSlide(index int) *PPTXSlide

DuplicateSlide creates a copy of a slide.

func (*PPTXDocument) GetProperties added in v0.5.6

func (d *PPTXDocument) GetProperties() *PPTXProperties

GetProperties returns the document properties.

func (*PPTXDocument) GetSlide added in v0.5.6

func (d *PPTXDocument) GetSlide(index int) *PPTXSlide

GetSlide returns a slide by index (1-based).

func (*PPTXDocument) GetSlideCount added in v0.5.6

func (d *PPTXDocument) GetSlideCount() int

GetSlideCount returns the number of slides.

func (*PPTXDocument) GetSlides added in v0.5.6

func (d *PPTXDocument) GetSlides() []*PPTXSlide

GetSlides returns all slides.

func (*PPTXDocument) HashKey added in v0.5.6

func (d *PPTXDocument) HashKey() HashKey

func (*PPTXDocument) Inspect added in v0.5.6

func (d *PPTXDocument) Inspect() string

func (*PPTXDocument) MoveSlide added in v0.5.6

func (d *PPTXDocument) MoveSlide(from, to int) bool

MoveSlide moves a slide from one position to another.

func (*PPTXDocument) Save added in v0.5.6

func (d *PPTXDocument) Save(path string) error

Save saves the document to a file.

func (*PPTXDocument) SetProperties added in v0.5.6

func (d *PPTXDocument) SetProperties(props *PPTXProperties)

SetProperties sets the document properties.

func (*PPTXDocument) ToBool added in v0.5.6

func (d *PPTXDocument) ToBool() *Bool

func (*PPTXDocument) ToBytes added in v0.5.6

func (d *PPTXDocument) ToBytes() ([]byte, error)

ToBytes converts the document to a byte slice.

func (*PPTXDocument) Type added in v0.5.6

func (d *PPTXDocument) Type() ObjectType

func (*PPTXDocument) TypeTag added in v0.5.6

func (d *PPTXDocument) TypeTag() TypeTag

type PPTXFont added in v0.5.6

type PPTXFont struct {
	Name   string
	Size   int // in points
	Bold   bool
	Italic bool
}

PPTXFont represents font properties.

type PPTXFormatScheme added in v0.5.6

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

PPTXFormatScheme defines format scheme.

type PPTXGradient added in v0.5.6

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

PPTXGradient represents gradient fill.

type PPTXImage added in v0.5.6

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

PPTXImage represents an image on a slide.

func (*PPTXImage) GetData added in v0.5.6

func (i *PPTXImage) GetData() []byte

GetData returns the image data.

func (*PPTXImage) GetDataBase64 added in v0.5.6

func (i *PPTXImage) GetDataBase64() string

GetDataBase64 returns the image data as base64.

func (*PPTXImage) GetFormat added in v0.5.6

func (i *PPTXImage) GetFormat() string

GetFormat returns the image format.

func (*PPTXImage) GetPosition added in v0.5.6

func (i *PPTXImage) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXImage) GetSize added in v0.5.6

func (i *PPTXImage) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXImage) HashKey added in v0.5.6

func (i *PPTXImage) HashKey() HashKey

func (*PPTXImage) Inspect added in v0.5.6

func (i *PPTXImage) Inspect() string

func (*PPTXImage) Save added in v0.5.6

func (i *PPTXImage) Save(path string) error

Save saves the image to a file.

func (*PPTXImage) SetPosition added in v0.5.6

func (i *PPTXImage) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXImage) SetSize added in v0.5.6

func (i *PPTXImage) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXImage) ToBool added in v0.5.6

func (i *PPTXImage) ToBool() *Bool

func (*PPTXImage) Type added in v0.5.6

func (i *PPTXImage) Type() ObjectType

Type implementations for PPTXImage

func (*PPTXImage) TypeTag added in v0.5.6

func (i *PPTXImage) TypeTag() TypeTag

type PPTXParagraph added in v0.5.6

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

PPTXParagraph represents a paragraph within a text frame.

func (*PPTXParagraph) GetAlignment added in v0.5.6

func (p *PPTXParagraph) GetAlignment() string

GetAlignment returns the alignment.

func (*PPTXParagraph) GetRuns added in v0.5.6

func (p *PPTXParagraph) GetRuns() []*PPTXTextRun

GetRuns returns all text runs.

func (*PPTXParagraph) GetText added in v0.5.6

func (p *PPTXParagraph) GetText() string

GetText returns the text content.

func (*PPTXParagraph) HashKey added in v0.5.6

func (p *PPTXParagraph) HashKey() HashKey

func (*PPTXParagraph) Inspect added in v0.5.6

func (p *PPTXParagraph) Inspect() string

func (*PPTXParagraph) SetAlignment added in v0.5.6

func (p *PPTXParagraph) SetAlignment(align string)

SetAlignment sets the alignment.

func (*PPTXParagraph) ToBool added in v0.5.6

func (p *PPTXParagraph) ToBool() *Bool

func (*PPTXParagraph) Type added in v0.5.6

func (p *PPTXParagraph) Type() ObjectType

Type implementations for PPTXParagraph

func (*PPTXParagraph) TypeTag added in v0.5.6

func (p *PPTXParagraph) TypeTag() TypeTag

type PPTXPosition added in v0.5.6

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.6

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.6

type PPTXShadow struct {
	Type     string
	Color    PPTXColor
	Blur     int64
	Distance int64
	Angle    int
}

PPTXShadow represents shadow effect.

type PPTXShape added in v0.5.6

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

PPTXShape represents a shape on a slide.

func (*PPTXShape) AddTextFrame added in v0.5.6

func (s *PPTXShape) AddTextFrame(text string) *PPTXTextFrame

AddTextFrame adds a text frame to the shape.

func (*PPTXShape) GetFill added in v0.5.6

func (s *PPTXShape) GetFill() *PPTXColor

GetFill returns the fill color.

func (*PPTXShape) GetKind added in v0.5.6

func (s *PPTXShape) GetKind() PPTXShapeKind

GetKind returns the shape kind.

func (*PPTXShape) GetPosition added in v0.5.6

func (s *PPTXShape) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXShape) GetSize added in v0.5.6

func (s *PPTXShape) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXShape) GetTextFrame added in v0.5.6

func (s *PPTXShape) GetTextFrame() *PPTXTextFrame

GetTextFrame returns the text frame.

func (*PPTXShape) HashKey added in v0.5.6

func (s *PPTXShape) HashKey() HashKey

func (*PPTXShape) Inspect added in v0.5.6

func (s *PPTXShape) Inspect() string

func (*PPTXShape) SetFill added in v0.5.6

func (s *PPTXShape) SetFill(color string)

SetFill sets the fill color.

func (*PPTXShape) SetPosition added in v0.5.6

func (s *PPTXShape) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXShape) SetSize added in v0.5.6

func (s *PPTXShape) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXShape) ToBool added in v0.5.6

func (s *PPTXShape) ToBool() *Bool

func (*PPTXShape) Type added in v0.5.6

func (s *PPTXShape) Type() ObjectType

Type implementations for PPTXShape

func (*PPTXShape) TypeTag added in v0.5.6

func (s *PPTXShape) TypeTag() TypeTag

type PPTXShapeKind added in v0.5.6

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.6

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.6

type PPTXSize struct {
	Width  int64
	Height int64
}

PPTXSize represents element dimensions in EMUs.

type PPTXSlide added in v0.5.6

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

PPTXSlide represents a single slide in a presentation.

func (*PPTXSlide) AddChart added in v0.5.6

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.6

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.6

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.6

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.6

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.6

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.6

func (s *PPTXSlide) GetAllText() string

GetAllText returns all text content combined.

func (*PPTXSlide) GetCharts added in v0.5.6

func (s *PPTXSlide) GetCharts() []*PPTXChart

GetCharts returns all charts on the slide.

func (*PPTXSlide) GetImages added in v0.5.6

func (s *PPTXSlide) GetImages() []*PPTXImage

GetImages returns all images on the slide.

func (*PPTXSlide) GetIndex added in v0.5.6

func (s *PPTXSlide) GetIndex() int

GetIndex returns the slide index (1-based).

func (*PPTXSlide) GetNotes added in v0.5.6

func (s *PPTXSlide) GetNotes() string

GetNotes returns the speaker notes.

func (*PPTXSlide) GetShapes added in v0.5.6

func (s *PPTXSlide) GetShapes() []*PPTXShape

GetShapes returns all shapes on the slide.

func (*PPTXSlide) GetTables added in v0.5.6

func (s *PPTXSlide) GetTables() []*PPTXTable

GetTables returns all tables on the slide.

func (*PPTXSlide) GetTexts added in v0.5.6

func (s *PPTXSlide) GetTexts() []*PPTXTextFrame

GetTexts returns all text frames on the slide.

func (*PPTXSlide) HashKey added in v0.5.6

func (s *PPTXSlide) HashKey() HashKey

func (*PPTXSlide) Inspect added in v0.5.6

func (s *PPTXSlide) Inspect() string

func (*PPTXSlide) SetNotes added in v0.5.6

func (s *PPTXSlide) SetNotes(text string)

SetNotes sets the speaker notes.

func (*PPTXSlide) ToBool added in v0.5.6

func (s *PPTXSlide) ToBool() *Bool

func (*PPTXSlide) Type added in v0.5.6

func (s *PPTXSlide) Type() ObjectType

Type implementations for PPTXSlide

func (*PPTXSlide) TypeTag added in v0.5.6

func (s *PPTXSlide) TypeTag() TypeTag

type PPTXSlideBackground added in v0.5.6

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

PPTXSlideBackground represents slide background.

type PPTXSlideLayout added in v0.5.6

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

PPTXSlideLayout represents a slide layout template.

func (*PPTXSlideLayout) HashKey added in v0.5.6

func (l *PPTXSlideLayout) HashKey() HashKey

func (*PPTXSlideLayout) Inspect added in v0.5.6

func (l *PPTXSlideLayout) Inspect() string

func (*PPTXSlideLayout) ToBool added in v0.5.6

func (l *PPTXSlideLayout) ToBool() *Bool

func (*PPTXSlideLayout) Type added in v0.5.6

func (l *PPTXSlideLayout) Type() ObjectType

Type implementations for PPTXSlideLayout

func (*PPTXSlideLayout) TypeTag added in v0.5.6

func (l *PPTXSlideLayout) TypeTag() TypeTag

type PPTXSlideMaster added in v0.5.6

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

PPTXSlideMaster represents a slide master.

func (*PPTXSlideMaster) HashKey added in v0.5.6

func (m *PPTXSlideMaster) HashKey() HashKey

func (*PPTXSlideMaster) Inspect added in v0.5.6

func (m *PPTXSlideMaster) Inspect() string

func (*PPTXSlideMaster) ToBool added in v0.5.6

func (m *PPTXSlideMaster) ToBool() *Bool

func (*PPTXSlideMaster) Type added in v0.5.6

func (m *PPTXSlideMaster) Type() ObjectType

Type implementations for PPTXSlideMaster

func (*PPTXSlideMaster) TypeTag added in v0.5.6

func (m *PPTXSlideMaster) TypeTag() TypeTag

type PPTXTable added in v0.5.6

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

PPTXTable represents a table on a slide.

func (*PPTXTable) GetCell added in v0.5.6

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.6

func (t *PPTXTable) GetColCount() int

GetColCount returns the number of columns.

func (*PPTXTable) GetPosition added in v0.5.6

func (t *PPTXTable) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXTable) GetRowCount added in v0.5.6

func (t *PPTXTable) GetRowCount() int

GetRowCount returns the number of rows.

func (*PPTXTable) GetSize added in v0.5.6

func (t *PPTXTable) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXTable) GetValue added in v0.5.6

func (t *PPTXTable) GetValue(row, col int) string

GetValue returns a cell value.

func (*PPTXTable) HashKey added in v0.5.6

func (t *PPTXTable) HashKey() HashKey

func (*PPTXTable) Inspect added in v0.5.6

func (t *PPTXTable) Inspect() string

func (*PPTXTable) SetPosition added in v0.5.6

func (t *PPTXTable) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXTable) SetSize added in v0.5.6

func (t *PPTXTable) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXTable) SetValue added in v0.5.6

func (t *PPTXTable) SetValue(row, col int, value string)

SetValue sets a cell value.

func (*PPTXTable) ToBool added in v0.5.6

func (t *PPTXTable) ToBool() *Bool

func (*PPTXTable) Type added in v0.5.6

func (t *PPTXTable) Type() ObjectType

Type implementations for PPTXTable

func (*PPTXTable) TypeTag added in v0.5.6

func (t *PPTXTable) TypeTag() TypeTag

type PPTXTableCell added in v0.5.6

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

PPTXTableCell represents a table cell.

func (*PPTXTableCell) HashKey added in v0.5.6

func (c *PPTXTableCell) HashKey() HashKey

func (*PPTXTableCell) Inspect added in v0.5.6

func (c *PPTXTableCell) Inspect() string

func (*PPTXTableCell) ToBool added in v0.5.6

func (c *PPTXTableCell) ToBool() *Bool

func (*PPTXTableCell) Type added in v0.5.6

func (c *PPTXTableCell) Type() ObjectType

Type implementations for PPTXTableCell

func (*PPTXTableCell) TypeTag added in v0.5.6

func (c *PPTXTableCell) TypeTag() TypeTag

type PPTXTableStyle added in v0.5.6

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.6

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

PPTXTextFrame represents a text box on a slide.

func (*PPTXTextFrame) GetParagraphs added in v0.5.6

func (tf *PPTXTextFrame) GetParagraphs() []*PPTXParagraph

GetParagraphs returns all paragraphs.

func (*PPTXTextFrame) GetPosition added in v0.5.6

func (tf *PPTXTextFrame) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXTextFrame) GetSize added in v0.5.6

func (tf *PPTXTextFrame) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXTextFrame) GetText added in v0.5.6

func (tf *PPTXTextFrame) GetText() string

GetText returns the text content.

func (*PPTXTextFrame) HashKey added in v0.5.6

func (tf *PPTXTextFrame) HashKey() HashKey

func (*PPTXTextFrame) Inspect added in v0.5.6

func (tf *PPTXTextFrame) Inspect() string

func (*PPTXTextFrame) SetPosition added in v0.5.6

func (tf *PPTXTextFrame) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXTextFrame) SetSize added in v0.5.6

func (tf *PPTXTextFrame) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXTextFrame) SetText added in v0.5.6

func (tf *PPTXTextFrame) SetText(text string)

SetText sets the text content.

func (*PPTXTextFrame) ToBool added in v0.5.6

func (tf *PPTXTextFrame) ToBool() *Bool

func (*PPTXTextFrame) Type added in v0.5.6

func (tf *PPTXTextFrame) Type() ObjectType

Type implementations for PPTXTextFrame

func (*PPTXTextFrame) TypeTag added in v0.5.6

func (tf *PPTXTextFrame) TypeTag() TypeTag

type PPTXTextRun added in v0.5.6

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

PPTXTextRun represents a text run with uniform formatting.

func (*PPTXTextRun) GetColor added in v0.5.6

func (r *PPTXTextRun) GetColor() string

GetColor returns the color as hex string.

func (*PPTXTextRun) GetFontName added in v0.5.6

func (r *PPTXTextRun) GetFontName() string

GetFontName returns the font name.

func (*PPTXTextRun) GetFontSize added in v0.5.6

func (r *PPTXTextRun) GetFontSize() int

GetFontSize returns the font size.

func (*PPTXTextRun) GetText added in v0.5.6

func (r *PPTXTextRun) GetText() string

GetText returns the text content.

func (*PPTXTextRun) HashKey added in v0.5.6

func (r *PPTXTextRun) HashKey() HashKey

func (*PPTXTextRun) Inspect added in v0.5.6

func (r *PPTXTextRun) Inspect() string

func (*PPTXTextRun) IsBold added in v0.5.6

func (r *PPTXTextRun) IsBold() bool

IsBold returns whether the text is bold.

func (*PPTXTextRun) IsItalic added in v0.5.6

func (r *PPTXTextRun) IsItalic() bool

IsItalic returns whether the text is italic.

func (*PPTXTextRun) SetBold added in v0.5.6

func (r *PPTXTextRun) SetBold(bold bool)

SetBold sets the bold flag.

func (*PPTXTextRun) SetColor added in v0.5.6

func (r *PPTXTextRun) SetColor(hex string)

SetColor sets the color from hex string.

func (*PPTXTextRun) SetFontName added in v0.5.6

func (r *PPTXTextRun) SetFontName(name string)

SetFontName sets the font name.

func (*PPTXTextRun) SetFontSize added in v0.5.6

func (r *PPTXTextRun) SetFontSize(size int)

SetFontSize sets the font size.

func (*PPTXTextRun) SetItalic added in v0.5.6

func (r *PPTXTextRun) SetItalic(italic bool)

SetItalic sets the italic flag.

func (*PPTXTextRun) SetText added in v0.5.6

func (r *PPTXTextRun) SetText(text string)

SetText sets the text content.

func (*PPTXTextRun) ToBool added in v0.5.6

func (r *PPTXTextRun) ToBool() *Bool

func (*PPTXTextRun) Type added in v0.5.6

func (r *PPTXTextRun) Type() ObjectType

Type implementations for PPTXTextRun

func (*PPTXTextRun) TypeTag added in v0.5.6

func (r *PPTXTextRun) TypeTag() TypeTag

type PPTXTheme added in v0.5.6

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

PPTXTheme represents a presentation theme.

func (*PPTXTheme) HashKey added in v0.5.6

func (t *PPTXTheme) HashKey() HashKey

func (*PPTXTheme) Inspect added in v0.5.6

func (t *PPTXTheme) Inspect() string

func (*PPTXTheme) ToBool added in v0.5.6

func (t *PPTXTheme) ToBool() *Bool

func (*PPTXTheme) Type added in v0.5.6

func (t *PPTXTheme) Type() ObjectType

Type implementations for PPTXTheme

func (*PPTXTheme) TypeTag added in v0.5.6

func (t *PPTXTheme) TypeTag() TypeTag

type PPTXThemeColors added in v0.5.6

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

PPTXThemeColors defines theme color scheme.

type PPTXThemeFonts added in v0.5.6

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

PPTXThemeFonts defines theme fonts.

type PPTXVideo added in v0.5.6

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

PPTXVideo represents a video on a slide.

func (*PPTXVideo) GetData added in v0.5.6

func (v *PPTXVideo) GetData() []byte

GetData returns the video data.

func (*PPTXVideo) GetFormat added in v0.5.6

func (v *PPTXVideo) GetFormat() string

GetFormat returns the video format.

func (*PPTXVideo) GetPosition added in v0.5.6

func (v *PPTXVideo) GetPosition() PPTXPosition

GetPosition returns the position.

func (*PPTXVideo) GetSize added in v0.5.6

func (v *PPTXVideo) GetSize() PPTXSize

GetSize returns the size.

func (*PPTXVideo) HashKey added in v0.5.6

func (v *PPTXVideo) HashKey() HashKey

func (*PPTXVideo) Inspect added in v0.5.6

func (v *PPTXVideo) Inspect() string

func (*PPTXVideo) Save added in v0.5.6

func (v *PPTXVideo) Save(path string) error

Save saves the video to a file.

func (*PPTXVideo) SetPosition added in v0.5.6

func (v *PPTXVideo) SetPosition(x, y int64)

SetPosition sets the position.

func (*PPTXVideo) SetSize added in v0.5.6

func (v *PPTXVideo) SetSize(width, height int64)

SetSize sets the size.

func (*PPTXVideo) ToBool added in v0.5.6

func (v *PPTXVideo) ToBool() *Bool

func (*PPTXVideo) Type added in v0.5.6

func (v *PPTXVideo) Type() ObjectType

Type implementations for PPTXVideo

func (*PPTXVideo) TypeTag added in v0.5.6

func (v *PPTXVideo) TypeTag() TypeTag

type Parser added in v0.5.13

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

Parser holds the parser state

type QRCode added in v0.5.13

type QRCode struct {
	Version int
	Level   QRCodeLevel
	Mode    QRCodeMode
	Modules [][]bool // true = black, false = white
	Size    int
	Data    []byte
}

QRCode represents a QR code

type QRCodeLevel added in v0.5.13

type QRCodeLevel int

QRCodeLevel represents error correction level

const (
	QRLevelLow      QRCodeLevel = iota // 7% error correction
	QRLevelMedium                      // 15% error correction
	QRLevelQuartile                    // 25% error correction
	QRLevelHigh                        // 30% error correction
)

type QRCodeMode added in v0.5.13

type QRCodeMode int

QRCodeMode represents encoding mode

const (
	QRModeNumeric QRCodeMode = iota
	QRModeAlphanumeric
	QRModeByte
	QRModeKanji
)

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 SSHClient added in v0.5.9

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

SSHClient represents an SSH client connection.

func NewSSHClient added in v0.5.9

func NewSSHClient() *SSHClient

NewSSHClient creates a new SSHClient (unconnected).

func (*SSHClient) Close added in v0.5.9

func (c *SSHClient) Close() error

Close closes the SSH connection.

func (*SSHClient) Connect added in v0.5.9

func (c *SSHClient) Connect(host string, port int, user, password string) error

Connect establishes SSH connection with password.

func (*SSHClient) ConnectWithConfig added in v0.5.9

func (c *SSHClient) ConnectWithConfig(config *SSHConfig) error

ConnectWithConfig establishes SSH connection with full configuration.

func (*SSHClient) ConnectWithKey added in v0.5.9

func (c *SSHClient) ConnectWithKey(host string, port int, user, keyPath string) error

ConnectWithKey establishes SSH connection with private key file.

func (*SSHClient) ConnectWithKeyStr added in v0.5.9

func (c *SSHClient) ConnectWithKeyStr(host string, port int, user, keyStr string) error

ConnectWithKeyStr establishes SSH connection with private key string.

func (*SSHClient) Download added in v0.5.9

func (c *SSHClient) Download(remotePath, localPath string) error

Download downloads a remote file to local.

func (*SSHClient) DownloadDir added in v0.5.9

func (c *SSHClient) DownloadDir(remoteDir, localDir string) error

DownloadDir downloads a remote directory to local.

func (*SSHClient) Exec added in v0.5.9

func (c *SSHClient) Exec(cmd string) (string, error)

Exec executes a command and returns stdout.

func (*SSHClient) ExecFull added in v0.5.9

func (c *SSHClient) ExecFull(cmd string) (map[string]interface{}, error)

ExecFull executes a command and returns stdout, stderr, and exit code.

func (*SSHClient) ExecStream added in v0.5.9

func (c *SSHClient) ExecStream(cmd string, callback func(line string)) error

ExecStream executes a command with streaming output. Returns a channel for output lines and an error channel.

func (*SSHClient) Exists added in v0.5.9

func (c *SSHClient) Exists(remotePath string) bool

Exists checks if a path exists.

func (*SSHClient) GetClient added in v0.5.9

func (c *SSHClient) GetClient() *ssh.Client

GetClient returns the underlying ssh.Client (for advanced use).

func (*SSHClient) GetHost added in v0.5.9

func (c *SSHClient) GetHost() string

GetHost returns the connected host.

func (*SSHClient) GetPort added in v0.5.9

func (c *SSHClient) GetPort() int

GetPort returns the connected port.

func (*SSHClient) GetUser added in v0.5.9

func (c *SSHClient) GetUser() string

GetUser returns the username.

func (*SSHClient) HashKey added in v0.5.9

func (c *SSHClient) HashKey() HashKey

HashKey returns a hash key for the SSHClient.

func (*SSHClient) Inspect added in v0.5.9

func (c *SSHClient) Inspect() string

Inspect returns a string representation of the SSHClient.

func (*SSHClient) IsConnected added in v0.5.9

func (c *SSHClient) IsConnected() bool

IsConnected returns the connection status.

func (*SSHClient) IsDir added in v0.5.9

func (c *SSHClient) IsDir(remotePath string) bool

IsDir checks if path is a directory.

func (*SSHClient) IsFile added in v0.5.9

func (c *SSHClient) IsFile(remotePath string) bool

IsFile checks if path is a regular file.

func (*SSHClient) ListDir added in v0.5.9

func (c *SSHClient) ListDir(remotePath string) ([]map[string]interface{}, error)

ListDir lists directory contents.

func (*SSHClient) LocalForward added in v0.5.9

func (c *SSHClient) LocalForward(localPort int, remoteHost string, remotePort int) (net.Listener, error)

LocalForward creates local port forwarding. Returns a forwarding ID that can be used to stop it.

func (*SSHClient) Mkdir added in v0.5.9

func (c *SSHClient) Mkdir(remotePath string) error

Mkdir creates a remote directory.

func (*SSHClient) MkdirAll added in v0.5.9

func (c *SSHClient) MkdirAll(remotePath string) error

MkdirAll creates a remote directory with parents.

func (*SSHClient) ReadFile added in v0.5.9

func (c *SSHClient) ReadFile(remotePath string) (string, error)

ReadFile reads a remote file content.

func (*SSHClient) Remove added in v0.5.9

func (c *SSHClient) Remove(remotePath string) error

Remove removes a remote file.

func (*SSHClient) RemoveDir added in v0.5.9

func (c *SSHClient) RemoveDir(remotePath string) error

RemoveDir removes a remote directory recursively.

func (*SSHClient) Rename added in v0.5.9

func (c *SSHClient) Rename(oldPath, newPath string) error

Rename renames a remote file or directory.

func (*SSHClient) RunScript added in v0.5.9

func (c *SSHClient) RunScript(scriptPath string) (string, error)

RunScript executes a local script file on the remote server.

func (*SSHClient) RunScriptStr added in v0.5.9

func (c *SSHClient) RunScriptStr(scriptStr string) (string, error)

RunScriptStr executes a script string on the remote server.

func (*SSHClient) Stat added in v0.5.9

func (c *SSHClient) Stat(remotePath string) (map[string]interface{}, error)

Stat returns file information.

func (*SSHClient) ToBool added in v0.5.9

func (c *SSHClient) ToBool() *Bool

ToBool returns true if connected.

func (*SSHClient) Type added in v0.5.9

func (c *SSHClient) Type() ObjectType

Type returns the object type.

func (*SSHClient) TypeTag added in v0.5.9

func (c *SSHClient) TypeTag() TypeTag

TypeTag returns the fast type tag.

func (*SSHClient) Upload added in v0.5.9

func (c *SSHClient) Upload(localPath, remotePath string) error

Upload uploads a local file to remote server.

func (*SSHClient) UploadDir added in v0.5.9

func (c *SSHClient) UploadDir(localDir, remoteDir string) error

UploadDir uploads a local directory to remote.

func (*SSHClient) WalkDir added in v0.5.9

func (c *SSHClient) WalkDir(remotePath string) ([]map[string]interface{}, error)

WalkDir recursively lists directory contents.

func (*SSHClient) WriteFile added in v0.5.9

func (c *SSHClient) WriteFile(remotePath, content string) error

WriteFile writes content to a remote file.

type SSHConfig added in v0.5.9

type SSHConfig struct {
	Host           string
	Port           int
	User           string
	Password       string
	KeyPath        string
	KeyStr         string
	KeyPassphrase  string
	Timeout        int // seconds
	KnownHostsPath string
	IgnoreHostKey  bool
}

SSHConfig holds SSH connection configuration.

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 SftpClient added in v0.5.9

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

SftpClient represents an SFTP client connection.

func NewSftpClient added in v0.5.9

func NewSftpClient() *SftpClient

NewSftpClient creates a new SftpClient (unconnected).

func (*SftpClient) Chmod added in v0.5.9

func (c *SftpClient) Chmod(remotePath string, mode uint32) error

Chmod changes file permissions.

func (*SftpClient) Close added in v0.5.9

func (c *SftpClient) Close() error

Close closes the SFTP connection.

func (*SftpClient) CloseHandle added in v0.5.9

func (c *SftpClient) CloseHandle(handle string) error

CloseHandle closes a file handle.

func (*SftpClient) Connect added in v0.5.9

func (c *SftpClient) Connect(host string, port int, user, password string) error

Connect establishes SFTP connection with password.

func (*SftpClient) ConnectWithConfig added in v0.5.9

func (c *SftpClient) ConnectWithConfig(config *SftpConfig) error

ConnectWithConfig establishes SFTP connection with full configuration.

func (*SftpClient) ConnectWithKey added in v0.5.9

func (c *SftpClient) ConnectWithKey(host string, port int, user, keyPath string) error

ConnectWithKey establishes SFTP connection with private key file.

func (*SftpClient) ConnectWithKeyStr added in v0.5.9

func (c *SftpClient) ConnectWithKeyStr(host string, port int, user, keyStr string) error

ConnectWithKeyStr establishes SFTP connection with private key string.

func (*SftpClient) Create added in v0.5.9

func (c *SftpClient) Create(remotePath string) (string, error)

Create creates a remote file for writing.

func (*SftpClient) Delete added in v0.5.9

func (c *SftpClient) Delete(remotePath string) error

Delete deletes a remote file.

func (*SftpClient) Download added in v0.5.9

func (c *SftpClient) Download(remotePath, localPath string) error

Download downloads a remote file to the local filesystem.

func (*SftpClient) Exists added in v0.5.9

func (c *SftpClient) Exists(remotePath string) bool

Exists checks if a remote path exists.

func (*SftpClient) GetHost added in v0.5.9

func (c *SftpClient) GetHost() string

GetHost returns the connected host.

func (*SftpClient) GetPort added in v0.5.9

func (c *SftpClient) GetPort() int

GetPort returns the connected port.

func (*SftpClient) GetUser added in v0.5.9

func (c *SftpClient) GetUser() string

GetUser returns the username.

func (*SftpClient) HashKey added in v0.5.9

func (c *SftpClient) HashKey() HashKey

HashKey returns a hash key for the SftpClient.

func (*SftpClient) Inspect added in v0.5.9

func (c *SftpClient) Inspect() string

Inspect returns a string representation of the SftpClient.

func (*SftpClient) IsConnected added in v0.5.9

func (c *SftpClient) IsConnected() bool

IsConnected returns the connection status.

func (*SftpClient) IsDir added in v0.5.9

func (c *SftpClient) IsDir(remotePath string) bool

IsDir checks if a remote path is a directory.

func (*SftpClient) IsFile added in v0.5.9

func (c *SftpClient) IsFile(remotePath string) bool

IsFile checks if a remote path is a regular file.

func (*SftpClient) ListDir added in v0.5.9

func (c *SftpClient) ListDir(remotePath string) ([]SftpFileInfo, error)

ListDir lists the contents of a remote directory.

func (*SftpClient) Lstat added in v0.5.9

func (c *SftpClient) Lstat(remotePath string) (*SftpFileInfo, error)

Lstat returns file information without following symlinks.

func (*SftpClient) Mkdir added in v0.5.9

func (c *SftpClient) Mkdir(remotePath string) error

Mkdir creates a remote directory.

func (*SftpClient) MkdirAll added in v0.5.9

func (c *SftpClient) MkdirAll(remotePath string) error

MkdirAll creates a remote directory with parents.

func (*SftpClient) Open added in v0.5.9

func (c *SftpClient) Open(remotePath string) (string, error)

Open opens a remote file for reading.

func (*SftpClient) OpenFile added in v0.5.9

func (c *SftpClient) OpenFile(remotePath string, flags uint32) (string, error)

OpenFile opens a remote file with specified flags.

func (*SftpClient) Read added in v0.5.9

func (c *SftpClient) Read(handle string, offset uint64, length uint32) ([]byte, error)

Read reads data from a file handle.

func (c *SftpClient) ReadLink(remotePath string) (string, error)

ReadLink reads a symbolic link.

func (*SftpClient) RealPath added in v0.5.9

func (c *SftpClient) RealPath(remotePath string) (string, error)

RealPath returns the canonical path.

func (*SftpClient) Rename added in v0.5.9

func (c *SftpClient) Rename(oldPath, newPath string) error

Rename renames a remote file.

func (*SftpClient) Rmdir added in v0.5.9

func (c *SftpClient) Rmdir(remotePath string) error

Rmdir removes an empty remote directory.

func (*SftpClient) RmdirAll added in v0.5.9

func (c *SftpClient) RmdirAll(remotePath string) error

RmdirAll removes a remote directory recursively.

func (*SftpClient) Stat added in v0.5.9

func (c *SftpClient) Stat(remotePath string) (*SftpFileInfo, error)

Stat returns file information.

func (c *SftpClient) Symlink(oldPath, newPath string) error

Symlink creates a symbolic link.

func (*SftpClient) ToBool added in v0.5.9

func (c *SftpClient) ToBool() *Bool

ToBool returns true if connected.

func (*SftpClient) Truncate added in v0.5.9

func (c *SftpClient) Truncate(remotePath string, size int64) error

Truncate truncates a file.

func (*SftpClient) Type added in v0.5.9

func (c *SftpClient) Type() ObjectType

Type returns the object type.

func (*SftpClient) TypeTag added in v0.5.9

func (c *SftpClient) TypeTag() TypeTag

TypeTag returns the fast type tag.

func (*SftpClient) Upload added in v0.5.9

func (c *SftpClient) Upload(localPath, remotePath string) error

Upload uploads a local file to the remote server.

func (*SftpClient) Write added in v0.5.9

func (c *SftpClient) Write(handle string, offset uint64, data []byte) error

Write writes data to a file handle.

type SftpConfig added in v0.5.9

type SftpConfig struct {
	Host          string
	Port          int
	User          string
	Password      string
	KeyPath       string
	KeyStr        string
	KeyPassphrase string
	Timeout       int
	IgnoreHostKey bool
}

SftpConfig holds SFTP connection configuration.

type SftpFileInfo added in v0.5.9

type SftpFileInfo struct {
	Name    string
	Size    int64
	Mode    uint32
	ModTime int64 // Unix timestamp
	IsDir   bool
}

SftpFileInfo represents file information from SFTP.

type SftpServer added in v0.5.9

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

SftpServer represents an SFTP server.

func NewSftpServer added in v0.5.9

func NewSftpServer() *SftpServer

NewSftpServer creates a new SftpServer.

func (*SftpServer) AddUser added in v0.5.9

func (s *SftpServer) AddUser(username, password, homeDir string) error

AddUser adds a user account with password.

func (*SftpServer) AddUserWithKey added in v0.5.9

func (s *SftpServer) AddUserWithKey(username, keyStr, homeDir string) error

AddUserWithKey adds a user account with public key.

func (*SftpServer) Create added in v0.5.9

func (s *SftpServer) Create(addr string, config *SftpServerConfig) error

Create creates and configures the SFTP server.

func (*SftpServer) HashKey added in v0.5.9

func (s *SftpServer) HashKey() HashKey

HashKey returns a hash key for the SftpServer.

func (*SftpServer) Inspect added in v0.5.9

func (s *SftpServer) Inspect() string

Inspect returns a string representation of the SftpServer.

func (*SftpServer) IsRunning added in v0.5.9

func (s *SftpServer) IsRunning() bool

IsRunning returns true if the server is running.

func (*SftpServer) RemoveUser added in v0.5.9

func (s *SftpServer) RemoveUser(username string) error

RemoveUser removes a user account.

func (*SftpServer) Start added in v0.5.9

func (s *SftpServer) Start() error

Start starts the SFTP server.

func (*SftpServer) Stop added in v0.5.9

func (s *SftpServer) Stop() error

Stop stops the SFTP server.

func (*SftpServer) ToBool added in v0.5.9

func (s *SftpServer) ToBool() *Bool

ToBool returns true if running.

func (*SftpServer) Type added in v0.5.9

func (s *SftpServer) Type() ObjectType

Type returns the object type.

func (*SftpServer) TypeTag added in v0.5.9

func (s *SftpServer) TypeTag() TypeTag

TypeTag returns the fast type tag.

type SftpServerConfig added in v0.5.9

type SftpServerConfig struct {
	Host           string
	Port           int
	HostKey        string // PEM format private key
	HostKeyPath    string
	MaxConnections int
	Timeout        int // seconds
}

SftpServerConfig holds SFTP server configuration.

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 SocketAddr added in v0.5.8

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

SocketAddr represents a network address with host and port. It is used for socket operations to specify endpoints.

func NewSocketAddr added in v0.5.8

func NewSocketAddr(host string, port int) *SocketAddr

NewSocketAddr creates a new SocketAddr with the given host and port.

func (*SocketAddr) HashKey added in v0.5.8

func (a *SocketAddr) HashKey() HashKey

HashKey returns a hash key for the SocketAddr.

func (*SocketAddr) Host added in v0.5.8

func (a *SocketAddr) Host() string

Host returns the host part of the address.

func (*SocketAddr) Inspect added in v0.5.8

func (a *SocketAddr) Inspect() string

Inspect returns a string representation of the SocketAddr.

func (*SocketAddr) Port added in v0.5.8

func (a *SocketAddr) Port() int

Port returns the port part of the address.

func (*SocketAddr) ToBool added in v0.5.8

func (a *SocketAddr) ToBool() *Bool

ToBool returns true (SocketAddr is always truthy).

func (*SocketAddr) ToStr added in v0.5.8

func (a *SocketAddr) ToStr() string

ToStr returns the address in "host:port" format. For IPv6 addresses, the host is wrapped in brackets.

func (*SocketAddr) Type added in v0.5.8

func (a *SocketAddr) Type() ObjectType

Type returns the object type.

func (*SocketAddr) TypeTag added in v0.5.8

func (a *SocketAddr) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

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 TcpClient added in v0.5.8

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

TcpClient represents a TCP client connection. It provides methods for connecting to TCP servers, sending and receiving data. TcpClient is thread-safe and supports read timeouts.

func NewTcpClient added in v0.5.8

func NewTcpClient() *TcpClient

NewTcpClient creates a new unconnected TcpClient. The client must call Connect before sending or receiving data.

func NewTcpClientFromConn added in v0.5.8

func NewTcpClientFromConn(conn net.Conn) *TcpClient

NewTcpClientFromConn creates a TcpClient from an existing net.Conn. This is useful for server-side accepted connections.

func (*TcpClient) Close added in v0.5.8

func (c *TcpClient) Close() Object

Close closes the connection. Returns NULL on success, or an Error on failure.

func (*TcpClient) Connect added in v0.5.8

func (c *TcpClient) Connect(addr string) Object

Connect establishes a TCP connection to the specified address. The address should be in the format "host:port". Returns NULL on success, or an Error on failure.

func (*TcpClient) HashKey added in v0.5.8

func (c *TcpClient) HashKey() HashKey

HashKey returns a hash key for the TcpClient.

func (*TcpClient) Inspect added in v0.5.8

func (c *TcpClient) Inspect() string

Inspect returns a string representation of the TcpClient.

func (*TcpClient) IsClosed added in v0.5.8

func (c *TcpClient) IsClosed() bool

IsClosed returns true if the connection is closed.

func (*TcpClient) LocalAddr added in v0.5.8

func (c *TcpClient) LocalAddr() Object

LocalAddr returns the local address as a SocketAddr. Returns an Error if not connected.

func (*TcpClient) Receive added in v0.5.8

func (c *TcpClient) Receive(n int) Object

Receive reads up to n bytes and returns the data as a String. Returns NULL on timeout or EOF, or an Error on failure.

func (*TcpClient) ReceiveBytes added in v0.5.8

func (c *TcpClient) ReceiveBytes(n int) Object

ReceiveBytes reads up to n bytes and returns the data as an Array of Ints. Each element in the array is a byte value (0-255). Returns NULL on timeout or EOF, or an Error on failure.

func (*TcpClient) ReceiveLine added in v0.5.8

func (c *TcpClient) ReceiveLine() Object

ReceiveLine reads until newline and returns the line as a String. The trailing newline and carriage return are removed. Returns NULL on timeout or EOF, or an Error on failure.

func (*TcpClient) RemoteAddr added in v0.5.8

func (c *TcpClient) RemoteAddr() Object

RemoteAddr returns the remote address as a SocketAddr. Returns an Error if not connected.

func (*TcpClient) SendBytes added in v0.5.8

func (c *TcpClient) SendBytes(data []byte) Object

SendBytes sends a byte slice over the connection. Returns the number of bytes sent as an Int, or an Error on failure.

func (*TcpClient) SendString added in v0.5.8

func (c *TcpClient) SendString(data string) Object

SendString sends a string over the connection. Returns the number of bytes sent as an Int, or an Error on failure.

func (*TcpClient) SetTimeout added in v0.5.8

func (c *TcpClient) SetTimeout(ms int) Object

SetTimeout sets the read timeout in milliseconds. A timeout of 0 means no timeout (blocking read). Returns NULL.

func (*TcpClient) ToBool added in v0.5.8

func (c *TcpClient) ToBool() *Bool

ToBool returns true if connected and not closed.

func (*TcpClient) Type added in v0.5.8

func (c *TcpClient) Type() ObjectType

Type returns the object type.

func (*TcpClient) TypeTag added in v0.5.8

func (c *TcpClient) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type TcpServer added in v0.5.8

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

TcpServer represents a TCP server that can accept incoming connections. It provides methods for listening on a port, accepting connections, and handling connections via callbacks. TcpServer is thread-safe.

func NewTcpServer added in v0.5.8

func NewTcpServer() *TcpServer

NewTcpServer creates a new unbound TcpServer. The server must call Listen before accepting connections.

func (*TcpServer) Accept added in v0.5.8

func (s *TcpServer) Accept(timeoutMs int) Object

Accept waits for and accepts the next incoming connection. If timeout > 0, it will return NULL after the timeout expires. Returns a TcpClient on success, NULL on timeout, or an Error on failure. If the server is not listening, returns an Error.

func (*TcpServer) Addr added in v0.5.8

func (s *TcpServer) Addr() *SocketAddr

Addr returns the address the server is listening on. Returns nil if the server is not listening.

func (*TcpServer) Close added in v0.5.8

func (s *TcpServer) Close() Object

Close stops the server and releases resources. Returns NULL on success, or an Error on failure.

func (*TcpServer) HashKey added in v0.5.8

func (s *TcpServer) HashKey() HashKey

HashKey returns a hash key for the TcpServer.

func (*TcpServer) Inspect added in v0.5.8

func (s *TcpServer) Inspect() string

Inspect returns a string representation of the TcpServer.

func (*TcpServer) IsClosed added in v0.5.8

func (s *TcpServer) IsClosed() bool

IsClosed returns true if the server is not listening.

func (*TcpServer) Listen added in v0.5.8

func (s *TcpServer) Listen(addr string) Object

Listen starts the TCP server on the specified address. The address should be in the format "host:port" or ":port". If port is 0, a random port will be assigned. Returns NULL on success, or an Error on failure.

func (*TcpServer) OnAccept added in v0.5.8

func (s *TcpServer) OnAccept(callback func(client *TcpClient)) Object

OnAccept sets a callback function to be called for each accepted connection. When a callback is set, the server will automatically accept connections in the background when Start() is called. Returns NULL.

func (*TcpServer) SetReuseAddr added in v0.5.8

func (s *TcpServer) SetReuseAddr(reuse bool) Object

SetReuseAddr sets whether to enable SO_REUSEADDR option. Must be called before Listen. Default is true. Returns NULL.

func (*TcpServer) SetTimeout added in v0.5.8

func (s *TcpServer) SetTimeout(ms int) Object

SetTimeout sets the accept timeout in milliseconds. This affects the Accept method when blocking. A timeout of 0 means no timeout (blocking accept). Returns NULL.

func (*TcpServer) Start added in v0.5.8

func (s *TcpServer) Start() Object

Start begins the accept loop in a background goroutine. Connections will be passed to the onAccept callback if set. Use Close() to stop the server. Returns NULL on success, or an Error if not listening or already running.

func (*TcpServer) ToBool added in v0.5.8

func (s *TcpServer) ToBool() *Bool

ToBool returns true if the server is listening and not closed.

func (*TcpServer) Type added in v0.5.8

func (s *TcpServer) Type() ObjectType

Type returns the object type.

func (*TcpServer) TypeTag added in v0.5.8

func (s *TcpServer) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

type Time added in v0.5.13

type Time struct {
	Value time.Time
}

Time represents a time object with various time components

func NewTime added in v0.5.13

func NewTime(t time.Time) *Time

NewTime creates a new Time object from time.Time

func NewTimeFromComponents added in v0.5.13

func NewTimeFromComponents(year, month, day, hour, minute, second, nano int) *Time

NewTimeFromComponents creates a new Time object from date/time components

func NewTimeFromTimestamp added in v0.5.13

func NewTimeFromTimestamp(timestamp int64) *Time

NewTimeFromTimestamp creates a new Time object from Unix timestamp (auto-detects seconds/milliseconds)

func (*Time) AddDate added in v0.5.13

func (t *Time) AddDate(years, months, days int) *Time

AddDate adds years, months, days to the time

func (*Time) AddDuration added in v0.5.13

func (t *Time) AddDuration(durStr string) (*Time, error)

AddDuration adds a duration string (e.g., "1h", "30m", "1h30m")

func (*Time) AddSecs added in v0.5.13

func (t *Time) AddSecs(secs float64) *Time

AddSecs adds seconds to the time

func (*Time) After added in v0.5.13

func (t *Time) After(other *Time) bool

After checks if this time is after another time

func (*Time) Before added in v0.5.13

func (t *Time) Before(other *Time) bool

Before checks if this time is before another time

func (*Time) DiffSecs added in v0.5.13

func (t *Time) DiffSecs(other *Time) float64

DiffSecs returns the difference in seconds between this time and another time

func (*Time) Equal added in v0.5.13

func (t *Time) Equal(other *Time) bool

Equal checks if this time equals another time

func (*Time) Format added in v0.5.13

func (t *Time) Format(layout string) string

Format returns formatted time string

func (*Time) GetDay added in v0.5.13

func (t *Time) GetDay() int

GetDay returns the day of month

func (*Time) GetHour added in v0.5.13

func (t *Time) GetHour() int

GetHour returns the hour (0-23)

func (*Time) GetMinute added in v0.5.13

func (t *Time) GetMinute() int

GetMinute returns the minute (0-59)

func (*Time) GetMonth added in v0.5.13

func (t *Time) GetMonth() int

GetMonth returns the month (1-12)

func (*Time) GetNanosecond added in v0.5.13

func (t *Time) GetNanosecond() int

GetNanosecond returns the nanosecond

func (*Time) GetSecond added in v0.5.13

func (t *Time) GetSecond() int

GetSecond returns the second (0-59)

func (*Time) GetTimestamp added in v0.5.13

func (t *Time) GetTimestamp() int64

GetTimestamp returns Unix timestamp in seconds

func (*Time) GetTimestampMs added in v0.5.13

func (t *Time) GetTimestampMs() int64

GetTimestampMs returns Unix timestamp in milliseconds

func (*Time) GetWeekday added in v0.5.13

func (t *Time) GetWeekday() int

GetWeekday returns the weekday (0=Sunday, 1=Monday, ..., 6=Saturday)

func (*Time) GetYear added in v0.5.13

func (t *Time) GetYear() int

GetYear returns the year

func (*Time) HashKey added in v0.5.13

func (t *Time) HashKey() HashKey

func (*Time) Inspect added in v0.5.13

func (t *Time) Inspect() string

func (*Time) IsZero added in v0.5.13

func (t *Time) IsZero() bool

IsZero checks if the time is zero value

func (*Time) Sub added in v0.5.13

func (t *Time) Sub(other *Time) time.Duration

Sub returns the duration between this time and another time

func (*Time) ToBool added in v0.5.13

func (t *Time) ToBool() *Bool

func (*Time) ToMap added in v0.5.13

func (t *Time) ToMap() *Map

ToMap converts Time to a Map for backward compatibility

func (*Time) Type added in v0.5.13

func (t *Time) Type() ObjectType

func (*Time) TypeTag added in v0.5.13

func (t *Time) TypeTag() TypeTag

type Token added in v0.5.13

type Token struct {
	Type  TokenType
	Value string
	Line  int
	Col   int
}

Token represents a scanned token

type TokenType added in v0.5.13

type TokenType int

TokenType represents a token type

const (
	TokenEOF TokenType = iota
	TokenError
	TokenComment
	TokenKey
	TokenEquals
	TokenString
	TokenMultiLineString
	TokenLiteralString
	TokenMultiLineLiteralString
	TokenInteger
	TokenFloat
	TokenBoolean
	TokenDatetime
	TokenDate
	TokenTime
	TokenLBracket       // [
	TokenRBracket       // ]
	TokenDoubleLBracket // [[
	TokenDoubleRBracket // ]]
	TokenLBrace         // {
	TokenRBrace         // }
	TokenLParen         // (
	TokenRParen         // )
	TokenComma
	TokenDot
	TokenNewline
)

func (TokenType) String added in v0.5.13

func (t TokenType) String() string

type TomlDocument added in v0.5.13

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

TomlDocument represents a parsed TOML document

func NewTomlDocument added in v0.5.13

func NewTomlDocument() *TomlDocument

NewTomlDocument creates a new empty TOML document

func ParseToml added in v0.5.13

func ParseToml(input string) (*TomlDocument, error)

ParseToml parses a TOML string and returns a document

func (*TomlDocument) Get added in v0.5.13

func (d *TomlDocument) Get(path string) *TomlValue

Get retrieves a value by path Path format: "section.key", "section.subsection.key", "array[0].key"

func (*TomlDocument) Has added in v0.5.13

func (d *TomlDocument) Has(path string) bool

Has checks if a path exists

func (*TomlDocument) HashKey added in v0.5.13

func (d *TomlDocument) HashKey() HashKey

HashKey returns a hash key

func (*TomlDocument) Inspect added in v0.5.13

func (d *TomlDocument) Inspect() string

Inspect returns a string representation

func (*TomlDocument) Keys added in v0.5.13

func (d *TomlDocument) Keys() []string

Keys returns all top-level keys

func (*TomlDocument) Merge added in v0.5.13

func (d *TomlDocument) Merge(other *TomlDocument) error

Merge merges another TOML document into this one

func (*TomlDocument) Remove added in v0.5.13

func (d *TomlDocument) Remove(path string) bool

Remove removes a value at the specified path

func (*TomlDocument) Root added in v0.5.13

func (d *TomlDocument) Root() *TomlValue

Root returns the root table

func (*TomlDocument) Save added in v0.5.13

func (d *TomlDocument) Save(path string) error

Save saves the document to a file

func (*TomlDocument) Sections added in v0.5.13

func (d *TomlDocument) Sections() []string

Sections returns all section names (top-level tables)

func (*TomlDocument) Set added in v0.5.13

func (d *TomlDocument) Set(path string, value *TomlValue) error

Set sets a value at the specified path

func (*TomlDocument) ToBool added in v0.5.13

func (d *TomlDocument) ToBool() *Bool

ToBool returns true

func (*TomlDocument) ToIndented added in v0.5.13

func (d *TomlDocument) ToIndented() string

ToIndented serializes with indentation

func (*TomlDocument) ToMap added in v0.5.13

func (d *TomlDocument) ToMap() *Map

ToMap converts the document to an Xxlang Map

func (*TomlDocument) ToString added in v0.5.13

func (d *TomlDocument) ToString() string

ToString serializes the document to a TOML string

func (*TomlDocument) Type added in v0.5.13

func (d *TomlDocument) Type() ObjectType

Type returns the object type

func (*TomlDocument) TypeTag added in v0.5.13

func (d *TomlDocument) TypeTag() TypeTag

TypeTag returns the type tag

type TomlValue added in v0.5.13

type TomlValue struct {
	Type  TomlValueType
	Value interface{}
	// contains filtered or unexported fields
}

TomlValue represents a value in TOML document

func CreateTomlValueFromInterface added in v0.5.13

func CreateTomlValueFromInterface(v interface{}) *TomlValue

CreateTomlValueFromInterface creates TomlValue from Go interface{}

func FromXxlangObject added in v0.5.13

func FromXxlangObject(obj Object) *TomlValue

FromXxlangObject converts Xxlang Object to TomlValue

func NewTomlValue added in v0.5.13

func NewTomlValue(valType TomlValueType, value interface{}) *TomlValue

NewTomlValue creates a new TomlValue

func (*TomlValue) AsArray added in v0.5.13

func (v *TomlValue) AsArray() ([]*TomlValue, bool)

AsArray converts to array

func (*TomlValue) AsBool added in v0.5.13

func (v *TomlValue) AsBool() (bool, bool)

AsBool converts to bool

func (*TomlValue) AsFloat added in v0.5.13

func (v *TomlValue) AsFloat() (float64, bool)

AsFloat converts to float

func (*TomlValue) AsInt added in v0.5.13

func (v *TomlValue) AsInt() (int64, bool)

AsInt converts to int

func (*TomlValue) AsString added in v0.5.13

func (v *TomlValue) AsString() (string, bool)

AsString converts to string

func (*TomlValue) AsTable added in v0.5.13

func (v *TomlValue) AsTable() (map[string]*TomlValue, bool)

AsTable converts to table

func (*TomlValue) Contains added in v0.5.13

func (v *TomlValue) Contains(key string) bool

Ensure key exists in string representation

func (*TomlValue) Get added in v0.5.13

func (v *TomlValue) Get(key string) *TomlValue

Get gets a value from a table by key

func (*TomlValue) GetPath added in v0.5.13

func (v *TomlValue) GetPath(keys ...string) *TomlValue

Get nested value with multiple keys

func (*TomlValue) IsArray added in v0.5.13

func (v *TomlValue) IsArray() bool

IsArray checks if the value is an array

func (*TomlValue) IsScalar added in v0.5.13

func (v *TomlValue) IsScalar() bool

IsScalar checks if the value is a scalar (non-container) type

func (*TomlValue) IsTable added in v0.5.13

func (v *TomlValue) IsTable() bool

IsTable checks if the value is a table

func (*TomlValue) Keys added in v0.5.13

func (v *TomlValue) Keys() []string

Keys returns keys of a table

func (*TomlValue) KeysString added in v0.5.13

func (v *TomlValue) KeysString() string

KeysString returns keys as a comma-separated string

func (*TomlValue) Len added in v0.5.13

func (v *TomlValue) Len() int

Len returns the length of an array or number of keys in a table

func (*TomlValue) Set added in v0.5.13

func (v *TomlValue) Set(key string, value *TomlValue)

Set sets a value in a table

func (*TomlValue) String added in v0.5.13

func (v *TomlValue) String() string

String methods for debugging

func (*TomlValue) ToMap added in v0.5.13

func (v *TomlValue) ToMap() *Map

ToMap converts TomlValue to Xxlang Map

func (*TomlValue) ToXxlangObject added in v0.5.13

func (v *TomlValue) ToXxlangObject() Object

ToXxlangObject converts TomlValue to Xxlang Object

func (*TomlValue) TypeName added in v0.5.13

func (v *TomlValue) TypeName() string

TypeName returns the type name

type TomlValueType added in v0.5.13

type TomlValueType int

TomlValueType represents the type of a TOML value

const (
	TomlString TomlValueType = iota
	TomlInteger
	TomlFloat
	TomlBoolean
	TomlDatetime
	TomlDate
	TomlTime
	TomlArray
	TomlTable
	TomlNull
)

func (TomlValueType) String added in v0.5.13

func (t TomlValueType) String() string

type ToneStyle added in v0.5.13

type ToneStyle int

ToneStyle defines how to represent tones in pinyin output

const (
	ToneNone   ToneStyle = iota // No tone (default): zhong
	ToneMark                    // Tone marks: zhōng
	ToneNumber                  // Tone numbers: zhong1
)

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 (
	TypeCodeNull TypeTag = iota
	TypeCodeBool
	TypeCodeInt
	TypeCodeFloat
	TypeCodeString
	TypeCodeArray
	TypeCodeMap
	TypeCodeFunction
	TypeCodeBuiltin
	TypeCodeError
	TypeCodeBytes
	TypeCodeChars
	TypeCodeBigInt
	TypeCodeBigFloat
	TypeCodeCompiledFunction
	TypeCodeOrderedMap
)

Type code constants for typeCode function

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
	// Socket tags
	TagSocketAddr
	TagTcpServer
	TagTcpClient
	TagUdpSocket
	// LineEditor tag
	TagLineEditor
	// SSH tag
	TagSSHClient
	// FTP/SFTP tags
	TagFtpClient
	TagFtpServer
	TagSftpClient
	TagSftpServer
	// HTML tags
	TagHTMLDocument
	TagHTMLElement
	// YAML tags
	TagYAMLDocument
	// Time tag
	TagTime
	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 UdpSocket added in v0.5.8

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

UdpSocket represents a UDP socket for connectionless datagram communication. It supports two modes: 1. Send-only mode: Created with NewUdpSocket(), can send but cannot receive 2. Bidirectional mode: After Bind(), can both send and receive UdpSocket is thread-safe.

func NewUdpSocket added in v0.5.8

func NewUdpSocket() *UdpSocket

NewUdpSocket creates a new unbound UDP socket. The socket can send datagrams immediately using SendTo/SendToBytes, but must call Bind() before it can receive datagrams.

func (*UdpSocket) Bind added in v0.5.8

func (s *UdpSocket) Bind(addr string) Object

Bind binds the socket to a local address. The address should be in the format "host:port" (e.g., ":8080" for all interfaces, port 8080). Use ":0" to bind to a random available port. Returns NULL on success, or an Error on failure.

func (*UdpSocket) Close added in v0.5.8

func (s *UdpSocket) Close() Object

Close closes the UDP socket. Returns NULL on success, or an Error on failure.

func (*UdpSocket) HashKey added in v0.5.8

func (s *UdpSocket) HashKey() HashKey

HashKey returns a hash key for the UdpSocket.

func (*UdpSocket) Inspect added in v0.5.8

func (s *UdpSocket) Inspect() string

Inspect returns a string representation of the UdpSocket.

func (*UdpSocket) IsClosed added in v0.5.8

func (s *UdpSocket) IsClosed() bool

IsClosed returns true if the socket is closed.

func (*UdpSocket) LocalAddr added in v0.5.8

func (s *UdpSocket) LocalAddr() Object

LocalAddr returns the local address as a SocketAddr. Returns an Error if not bound.

func (*UdpSocket) ReceiveFrom added in v0.5.8

func (s *UdpSocket) ReceiveFrom(bufSize int) (Object, Object)

ReceiveFrom receives a datagram and returns the data as a String. Also returns the sender's address as a SocketAddr. Returns NULL for data on timeout, or an Error on failure. Requires Bind() to be called first.

func (*UdpSocket) ReceiveFromBytes added in v0.5.8

func (s *UdpSocket) ReceiveFromBytes(bufSize int) (Object, Object)

ReceiveFromBytes receives a datagram and returns the data as an Array of Ints. Each element in the array is a byte value (0-255). Also returns the sender's address as a SocketAddr. Returns NULL for data on timeout, or an Error on failure. Requires Bind() to be called first.

func (*UdpSocket) SendTo added in v0.5.8

func (s *UdpSocket) SendTo(data string, addr string) Object

SendTo sends a string to the specified address. The address should be in the format "host:port". Returns the number of bytes sent as an Int, or an Error on failure. This method can be used without calling Bind() first.

func (*UdpSocket) SendToBytes added in v0.5.8

func (s *UdpSocket) SendToBytes(data []byte, addr string) Object

SendToBytes sends a byte slice to the specified address. The address should be in the format "host:port". Returns the number of bytes sent as an Int, or an Error on failure. This method can be used without calling Bind() first.

func (*UdpSocket) SetTimeout added in v0.5.8

func (s *UdpSocket) SetTimeout(ms int) Object

SetTimeout sets the read timeout in milliseconds. A timeout of 0 means no timeout (blocking read). Returns NULL.

func (*UdpSocket) ToBool added in v0.5.8

func (s *UdpSocket) ToBool() *Bool

ToBool returns true if not closed.

func (*UdpSocket) Type added in v0.5.8

func (s *UdpSocket) Type() ObjectType

Type returns the object type.

func (*UdpSocket) TypeTag added in v0.5.8

func (s *UdpSocket) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking.

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. Checks both the local closed flag and the underlying handle's closed state.

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.

type YAMLDocument added in v0.5.10

type YAMLDocument struct {
	Root   Object
	Source string
}

YAMLDocument represents a YAML document that can be loaded and queried

func (*YAMLDocument) HashKey added in v0.5.10

func (y *YAMLDocument) HashKey() HashKey

HashKey returns a hash key (always 0 for YAML documents)

func (*YAMLDocument) Inspect added in v0.5.10

func (y *YAMLDocument) Inspect() string

Inspect returns a string representation

func (*YAMLDocument) ToBool added in v0.5.10

func (y *YAMLDocument) ToBool() *Bool

ToBool returns true if the document is not nil

func (*YAMLDocument) Type added in v0.5.10

func (y *YAMLDocument) Type() ObjectType

Type returns the object type

func (*YAMLDocument) TypeTag added in v0.5.10

func (y *YAMLDocument) TypeTag() TypeTag

TypeTag returns the type tag for fast type checking

type YAMLError added in v0.5.10

type YAMLError struct {
	Message  string
	Line     int
	Column   int
	Context  string
	Original error
}

YAMLError represents a YAML parsing error with location information

func (*YAMLError) Error added in v0.5.10

func (e *YAMLError) Error() string

Error returns the error message with location

func (*YAMLError) Unwrap added in v0.5.10

func (e *YAMLError) Unwrap() error

Unwrap returns the underlying error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL