Documentation
¶
Overview ¶
pkg/objects/array.go
pkg/objects/bigfloat.go BigFloat represents an arbitrary-precision floating-point value
pkg/objects/bigint.go BigInt represents an arbitrary-precision integer value
pkg/objects/builtin.go
pkg/objects/builtin_crypto.go Encryption helper functions for Charlang compatibility
pkg/objects/builtin_db.go Database builtin functions for Xxlang. Provides two versions of database functions: 1. String-based functions (Charlang compatible): dbQuery, dbQueryRecs, dbQueryMap, etc. 2. Typed functions (preserve native types): dbQueryTyped, dbQueryRowTyped, etc.
pkg/objects/builtin_file_upload.go Built-in functions for file upload handling in server mode.
pkg/objects/builtin_http.go Built-in functions for HTTP server mode.
pkg/objects/builtin_system.go System command builtin functions for Xxlang. Provides systemCmd, systemCmdDetached, and systemStart functions.
pkg/objects/builtin_system_unix.go Unix-specific system command utilities.
pkg/objects/builtin_testing.go Test assertion built-in functions for Xxlang
pkg/objects/bytes.go Bytes is an immutable byte sequence object. It represents a read-only []byte and is useful for binary data handling.
pkg/objects/bytes_buffer.go BytesBuffer is a mutable buffer of bytes for efficient byte operations. It's similar to Go's bytes.Buffer type. NOTE: This type is NOT thread-safe. Users must handle concurrency themselves using Mutex or RWMutex if shared across goroutines.
pkg/objects/chars.go
pkg/objects/class.go
pkg/objects/context.go Context object for timeout and cancellation (similar to Go's context package)
pkg/objects/db.go Database object types for Xxlang. Provides database connection, transaction, rows, and statement objects.
pkg/objects/file.go File object type for streaming file operations in Xxlang.
pkg/objects/file_lock_unix.go File locking implementation for Unix-like systems (Linux, macOS, BSD, etc.)
pkg/objects/float.go
pkg/objects/function.go
pkg/objects/http.go HTTP object types for server mode.
pkg/objects/int.go
pkg/objects/jsonutil.go JSON utility functions for Xxlang objects. These functions are exported for use by both the builtin functions and the stdlib json module.
pkg/objects/map.go
pkg/objects/methods.go
pkg/objects/methods_pptx.go PPTX methods for Xxlang.
pkg/objects/module.go Module object type for runtime module representation.
pkg/objects/object.go
pkg/objects/orderedmap.go OrderedMap is a map that preserves insertion order and supports reordering.
pkg/objects/pdf.go PDF object types for PDF processing in Xxlang. Implemented using only Go standard library - no third-party dependencies.
pkg/objects/pptx.go PPTX object types for Xxlang - PowerPoint file handling.
pkg/objects/queue.go Queue type for Xxlang - FIFO data structure with O(1) push/pop operations.
pkg/objects/reader_writer.go Reader and Writer objects for streaming I/O operations.
pkg/objects/scanner.go Scanner object for reading input from stdin or any io.Reader.
pkg/objects/set.go Set type for Xxlang - unordered collection of unique elements.
pkg/objects/string.go
pkg/objects/stringbuilder.go StringBuilder is a mutable string builder for efficient string concatenation. Unlike regular string concatenation which creates a new string each time, StringBuilder uses an internal buffer to accumulate strings efficiently. NOTE: This type is NOT thread-safe. Users must handle concurrency themselves using Mutex or RWMutex if shared across goroutines.
pkg/objects/sync.go Synchronization primitives for concurrent programming
pkg/objects/tube.go Tube object for concurrent communication (similar to Go channels)
Package objects defines the object types for Xxlang. This file contains the WebView object type for GUI support.
pkg/objects/xlsx.go XLSX workbook type for Xxlang - Excel file handling.
pkg/objects/xml.go XML types for Xxlang - XML document and node handling.
Index ¶
- Constants
- Variables
- func ClearInternCache()
- func ColToIndex(col string) int
- func EncodeToXML(obj Object, rootName string) (string, error)
- func ErrIndexOutOfRange(index, length int) error
- func ErrKeyNotFound(key Object) error
- func EscapeXMLAttr(s string) string
- func EscapeXMLText(s string) string
- func FormatBigFloat(b *BigFloat) string
- func FormatBigInt(b *BigInt) string
- func IndexToCol(index int) string
- func IsCachedInt(val int64) bool
- func IsTruthy(obj Object) bool
- func NewBytesReader(data []byte) io.Reader
- func NewStringReader(s string) io.Reader
- func ObjectToGoValue(obj Object) (interface{}, error)
- func ObjectToJSON(obj Object, opts ObjectToJSONOptions) ([]byte, error)
- func ParseCellRef(ref string) (col string, row int)
- func ParseMultipartForm(req *http.Request, maxMemory int64) (map[string][]string, map[string][]*FileUpload, error)
- func PutBufferedFloat(obj *Float)
- func PutBufferedInt(obj *Int)
- func PutBufferedString(obj *String)
- func RegisterFileUploadBuiltins()
- func RegisterHttpBuiltins()
- func ReleaseArray(obj *Array)
- func ReleaseArraySlice(objs []*Array)
- func ReleaseFloat(obj *Float)
- func ReleaseFloatSlice(objs []*Float)
- func ReleaseInt(obj *Int)
- func ReleaseIntSlice(objs []*Int)
- func ReleaseMap(obj *Map)
- func ReleaseMapSlice(objs []*Map)
- func ReleaseOrderedMap(om *OrderedMap)
- func ReleaseString(obj *String)
- func ReleaseStringSlice(objs []*String)
- func ResetArrayPoolStats()
- func ResetFloatPoolStats()
- func ResetGlobalReader()
- func ResetIntPoolStats()
- func ResetMapPoolStats()
- func ResetStringPoolStats()
- func SafePath(baseDir, filename string) (string, error)
- func Scan2() (Object, Object)
- func Scan3() (Object, Object, Object)
- func ScanRow(rows *sql.Rows, columns []string) (map[string]interface{}, error)
- func SetCallUserFuncImpl(fn func(fnObj Object, args ...Object) (Object, error)) func(Object, ...Object) (Object, error)
- func SetDelegateImpl(fn func(source string) (Object, error)) func(source string) (Object, error)
- func SetLoadPluginImpl(fn func(path string) (Object, error)) func(path string) (Object, error)
- func SetRunCodeImpl(fn func(code string, args *Map) (Object, error)) func(code string, args *Map) (Object, error)
- func WarmArrayPool(count int)
- func WarmFloatPool(count int)
- func WarmIntPool(count int)
- func WarmMapPool(count int)
- func WarmStringPool(count int)
- type Array
- type ArrayPoolStats
- type AtomicInt
- func (a *AtomicInt) Add(delta int64) int64
- func (a *AtomicInt) CompareAndSwap(old, new int64) bool
- func (a *AtomicInt) HashKey() HashKey
- func (a *AtomicInt) Inspect() string
- func (a *AtomicInt) Load() int64
- func (a *AtomicInt) Store(val int64)
- func (a *AtomicInt) Swap(new int64) int64
- func (a *AtomicInt) ToBool() *Bool
- func (a *AtomicInt) Type() ObjectType
- func (a *AtomicInt) TypeTag() TypeTag
- type BigFloat
- func (b *BigFloat) Abs() *BigFloat
- func (b *BigFloat) Add(other *BigFloat) *BigFloat
- func (b *BigFloat) AddFloat64(f float64) *BigFloat
- func (b *BigFloat) Ceil() *BigFloat
- func (b *BigFloat) Clone() *BigFloat
- func (b *BigFloat) Cmp(other *BigFloat) int
- func (b *BigFloat) Div(other *BigFloat) *BigFloat
- func (b *BigFloat) DivFloat64(f float64) *BigFloat
- func (b *BigFloat) Floor() *BigFloat
- func (b *BigFloat) HashKey() HashKey
- func (b *BigFloat) Inspect() string
- func (b *BigFloat) IsNegative() bool
- func (b *BigFloat) IsPositive() bool
- func (b *BigFloat) IsZero() bool
- func (b *BigFloat) Mul(other *BigFloat) *BigFloat
- func (b *BigFloat) MulFloat64(f float64) *BigFloat
- func (b *BigFloat) Neg() *BigFloat
- func (b *BigFloat) Precision() uint
- func (b *BigFloat) Round() *BigFloat
- func (b *BigFloat) SetPrecision(prec uint) *BigFloat
- func (b *BigFloat) Sign() int
- func (b *BigFloat) String() string
- func (b *BigFloat) Sub(other *BigFloat) *BigFloat
- func (b *BigFloat) SubFloat64(f float64) *BigFloat
- func (b *BigFloat) ToBigInt() *BigInt
- func (b *BigFloat) ToBool() *Bool
- func (b *BigFloat) ToFloat64() (float64, big.Accuracy)
- func (b *BigFloat) ToInt64() (int64, bool)
- func (b *BigFloat) Type() ObjectType
- func (b *BigFloat) TypeTag() TypeTag
- type BigInt
- func (b *BigInt) Abs() *BigInt
- func (b *BigInt) Add(other *BigInt) *BigInt
- func (b *BigInt) AddInt(n int64) *BigInt
- func (b *BigInt) BitLen() int
- func (b *BigInt) Clone() *BigInt
- func (b *BigInt) Cmp(other *BigInt) int
- func (b *BigInt) Div(other *BigInt) *BigInt
- func (b *BigInt) DivInt(n int64) *BigInt
- func (b *BigInt) HashKey() HashKey
- func (b *BigInt) Inspect() string
- func (b *BigInt) IsNegative() bool
- func (b *BigInt) IsPositive() bool
- func (b *BigInt) IsZero() bool
- func (b *BigInt) Mod(other *BigInt) *BigInt
- func (b *BigInt) ModInt(n int64) *BigInt
- func (b *BigInt) Mul(other *BigInt) *BigInt
- func (b *BigInt) MulInt(n int64) *BigInt
- func (b *BigInt) Neg() *BigInt
- func (b *BigInt) Sign() int
- func (b *BigInt) String() string
- func (b *BigInt) Sub(other *BigInt) *BigInt
- func (b *BigInt) SubInt(n int64) *BigInt
- func (b *BigInt) ToBigFloat() *BigFloat
- func (b *BigInt) ToBool() *Bool
- func (b *BigInt) ToFloat64() float64
- func (b *BigInt) ToInt64() (int64, bool)
- func (b *BigInt) Type() ObjectType
- func (b *BigInt) TypeTag() TypeTag
- type Bool
- type Builtin
- type BuiltinFunction
- type Bytes
- func (b *Bytes) At(index int) (int64, bool)
- func (b *Bytes) Concat(others ...*Bytes) *Bytes
- func (b *Bytes) Contains(sub *Bytes) bool
- func (b *Bytes) Count(sub *Bytes) int
- func (b *Bytes) Equal(other *Bytes) bool
- func (b *Bytes) GetIOReader() io.Reader
- func (b *Bytes) GetMember(name string) Object
- func (b *Bytes) HasPrefix(prefix *Bytes) bool
- func (b *Bytes) HasSuffix(suffix *Bytes) bool
- func (b *Bytes) HashKey() HashKey
- func (b *Bytes) Index(sub *Bytes) int
- func (b *Bytes) Inspect() string
- func (b *Bytes) LastIndex(sub *Bytes) int
- func (b *Bytes) Len() int
- func (b *Bytes) Repeat(n int) *Bytes
- func (b *Bytes) Slice(start, end int) *Bytes
- func (b *Bytes) String() string
- func (b *Bytes) ToArray() *Array
- func (b *Bytes) ToBool() *Bool
- func (b *Bytes) Type() ObjectType
- func (b *Bytes) TypeTag() TypeTag
- type BytesBuffer
- func (bb *BytesBuffer) Bytes() []byte
- func (bb *BytesBuffer) BytesRef() []byte
- func (bb *BytesBuffer) Cap() int
- func (bb *BytesBuffer) Clear()
- func (bb *BytesBuffer) Equals(other *BytesBuffer) bool
- func (bb *BytesBuffer) GetIOReader() *bytesBufferReader
- func (bb *BytesBuffer) GetIOWriter() *bytesBufferWriter
- func (bb *BytesBuffer) Grow(n int)
- func (bb *BytesBuffer) HashKey() HashKey
- func (bb *BytesBuffer) Inspect() string
- func (bb *BytesBuffer) Len() int
- func (bb *BytesBuffer) Peek(n int) []byte
- func (bb *BytesBuffer) Read(p []byte) (int, error)
- func (bb *BytesBuffer) ReadByte() (byte, error)
- func (bb *BytesBuffer) ReadBytes(delim byte) ([]byte, error)
- func (bb *BytesBuffer) ReadFloat32() (float32, error)
- func (bb *BytesBuffer) ReadFloat64() (float64, error)
- func (bb *BytesBuffer) ReadInt16() (int16, error)
- func (bb *BytesBuffer) ReadInt32() (int32, error)
- func (bb *BytesBuffer) ReadInt64() (int64, error)
- func (bb *BytesBuffer) ReadString(delim byte) (string, error)
- func (bb *BytesBuffer) Reset()
- func (bb *BytesBuffer) Seek(offset int64, whence int) int64
- func (bb *BytesBuffer) String() string
- func (bb *BytesBuffer) ToBool() *Bool
- func (bb *BytesBuffer) Truncate(n int)
- func (bb *BytesBuffer) Type() ObjectType
- func (bb *BytesBuffer) TypeTag() TypeTag
- func (bb *BytesBuffer) Write(data []byte) int
- func (bb *BytesBuffer) WriteByte(b byte) error
- func (bb *BytesBuffer) WriteFloat32(v float32) error
- func (bb *BytesBuffer) WriteFloat64(v float64) error
- func (bb *BytesBuffer) WriteInt16(v int16) error
- func (bb *BytesBuffer) WriteInt32(v int32) error
- func (bb *BytesBuffer) WriteInt64(v int64) error
- func (bb *BytesBuffer) WriteString(s string) int
- func (bb *BytesBuffer) WriteTo(other *BytesBuffer) (int64, error)
- type Cell
- type Chars
- func (c *Chars) At(index int) (string, bool)
- func (c *Chars) HashKey() HashKey
- func (c *Chars) Inspect() string
- func (c *Chars) Len() int
- func (c *Chars) Slice(start, end int) *Chars
- func (c *Chars) String() string
- func (c *Chars) ToBool() *Bool
- func (c *Chars) Type() ObjectType
- func (c *Chars) TypeTag() TypeTag
- type Class
- type CompiledFunction
- type Cond
- type Context
- func NewBackgroundContext() *Context
- func NewContext(ctx context.Context, cancel context.CancelFunc) *Context
- func NewContextWithCancel(parent *Context) *Context
- func NewContextWithDeadline(parent *Context, deadline time.Time) *Context
- func NewContextWithTimeout(parent *Context, timeout time.Duration) *Context
- func (c *Context) Cancel()
- func (c *Context) Deadline() (time.Time, bool)
- func (c *Context) DeadlineString() string
- func (c *Context) Done() *Tube
- func (c *Context) Err() error
- func (c *Context) ErrString() string
- func (c *Context) GoContext() context.Context
- func (c *Context) HashKey() HashKey
- func (c *Context) Inspect() string
- func (c *Context) IsDone() bool
- func (c *Context) ToBool() *Bool
- func (c *Context) Type() ObjectType
- func (c *Context) TypeTag() TypeTag
- func (c *Context) Value(key interface{}) interface{}
- type DB
- type DBRows
- func (r *DBRows) Close() error
- func (r *DBRows) Columns() ([]string, error)
- func (r *DBRows) GetMember(name string) Object
- func (r *DBRows) HashKey() HashKey
- func (r *DBRows) Inspect() string
- func (r *DBRows) IsClosed() bool
- func (r *DBRows) ToBool() *Bool
- func (r *DBRows) Type() ObjectType
- func (r *DBRows) TypeTag() TypeTag
- type DBStmt
- type DBTx
- type Environment
- type Error
- type File
- func (f *File) Close() error
- func (f *File) Flush() error
- func (f *File) GetMode() FileMode
- func (f *File) GetName() string
- func (f *File) HashKey() HashKey
- func (f *File) Inspect() string
- func (f *File) IsOpen() bool
- func (f *File) Lock(lockType FileLockType, blocking bool) error
- func (f *File) Read(n int) ([]byte, error)
- func (f *File) ReadAll() ([]byte, error)
- func (f *File) ReadLine() (string, error)
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) Stat() (os.FileInfo, error)
- func (f *File) Tell() int64
- func (f *File) ToBool() *Bool
- func (f *File) Truncate(size int64) error
- func (f *File) Type() ObjectType
- func (f *File) TypeTag() TypeTag
- func (f *File) Unlock() error
- func (f *File) Write(data []byte) (int, error)
- func (f *File) WriteString(s string) (int, error)
- type FileInfo
- func (fi *FileInfo) GetModTimeString() string
- func (fi *FileInfo) GetModTimeUnix() int64
- func (fi *FileInfo) GetModeString() string
- func (fi *FileInfo) HashKey() HashKey
- func (fi *FileInfo) Inspect() string
- func (fi *FileInfo) IsRegular() bool
- func (fi *FileInfo) IsSymlink() bool
- func (fi *FileInfo) ToBool() *Bool
- func (fi *FileInfo) Type() ObjectType
- func (fi *FileInfo) TypeTag() TypeTag
- type FileLockType
- type FileMode
- type FileUpload
- func (f *FileUpload) GetMember(name string) Object
- func (f *FileUpload) HashKey() HashKey
- func (f *FileUpload) HashSHA256() (string, error)
- func (f *FileUpload) Inspect() string
- func (f *FileUpload) Open() (multipart.File, error)
- func (f *FileUpload) ReadAll() ([]byte, error)
- func (f *FileUpload) ReadAsString() (string, error)
- func (f *FileUpload) Save(destPath string) (string, error)
- func (f *FileUpload) SaveToDir(dir string, autoRename bool) (string, error)
- func (f *FileUpload) ToBool() *Bool
- func (f *FileUpload) Type() ObjectType
- func (f *FileUpload) TypeTag() TypeTag
- type FileUploadConfig
- type FileUploadResult
- type Float
- type FloatPoolStats
- type Function
- type Goroutine
- func (g *Goroutine) HashKey() HashKey
- func (g *Goroutine) ID() uint64
- func (g *Goroutine) Inspect() string
- func (g *Goroutine) MarkFinished()
- func (g *Goroutine) MarkPanicked(v interface{})
- func (g *Goroutine) PanicValue() interface{}
- func (g *Goroutine) Status() GoroutineStatus
- func (g *Goroutine) ToBool() *Bool
- func (g *Goroutine) Type() ObjectType
- func (g *Goroutine) TypeTag() TypeTag
- func (g *Goroutine) Wait()
- type GoroutineStatus
- type HashKey
- type HttpMux
- type HttpReq
- type HttpResp
- type Identifier
- type ImageInfo
- type Instance
- type Int
- type IntPoolStats
- type Map
- type MapPair
- type MapPoolStats
- type MergeRange
- type Module
- type Mutex
- type Null
- type Object
- func CallUserFunc(fn Object, args ...Object) (Object, error)
- func GoValueToObject(v interface{}) Object
- func IoCopy(dst *Writer, src *Reader) Object
- func JSONToObject(s string) (Object, error)
- func RowsToArrays(rows *sql.Rows) (Object, error)
- func RowsToMaps(rows *sql.Rows) (Object, error)
- func Scan(prompt string) Object
- func ScanBool(prompt string) Object
- func ScanFloat(prompt string) Object
- func ScanInt(prompt string) Object
- func ScanN(n int) Object
- func ScanSplit(sep string) Object
- func Scanf(format string) Object
- type ObjectToJSONOptions
- type ObjectType
- type Once
- type OrderedMap
- func (om *OrderedMap) Clone() *OrderedMap
- func (om *OrderedMap) Delete(key Object) bool
- func (om *OrderedMap) Get(key Object) Object
- func (om *OrderedMap) GetAt(index int) (Object, Object, error)
- func (om *OrderedMap) GetIndex(key Object) int
- func (om *OrderedMap) GetOrderedKeys() []Object
- func (om *OrderedMap) GetOrderedPairs() []Object
- func (om *OrderedMap) GetOrderedValues() []Object
- func (om *OrderedMap) HasKey(key Object) bool
- func (om *OrderedMap) HashKey() HashKey
- func (om *OrderedMap) InsertAt(key Object, value Object, index int) error
- func (om *OrderedMap) Inspect() string
- func (om *OrderedMap) Len() int
- func (om *OrderedMap) MoveAfter(key1, key2 Object) error
- func (om *OrderedMap) MoveBefore(key1, key2 Object) error
- func (om *OrderedMap) MoveToBack(key Object) error
- func (om *OrderedMap) MoveToFront(key Object) error
- func (om *OrderedMap) Reverse()
- func (om *OrderedMap) Set(key Object, value Object)
- func (om *OrderedMap) SetAt(index int, value Object) error
- func (om *OrderedMap) SortByKey()
- func (om *OrderedMap) Swap(key1, key2 Object) error
- func (om *OrderedMap) ToBool() *Bool
- func (om *OrderedMap) ToMap() *Map
- func (om *OrderedMap) Type() ObjectType
- func (om *OrderedMap) TypeTag() TypeTag
- type OrderedMapPair
- type PDF
- func (p *PDF) Close() Object
- func (p *PDF) ExtractAllText() Object
- func (p *PDF) ExtractText(pageIndex int) Object
- func (p *PDF) GetInfo() *PDFInfo
- func (p *PDF) GetMember(name string) Object
- func (p *PDF) GetPage(index int) Object
- func (p *PDF) HashKey() HashKey
- func (p *PDF) Inspect() string
- func (p *PDF) Parse() error
- func (p *PDF) RotatePage(pageIndex int, angle int) Object
- func (p *PDF) SaveAs(filePath string) Object
- func (p *PDF) ToBool() *Bool
- func (p *PDF) ToBytes() Object
- func (p *PDF) Type() ObjectType
- func (p *PDF) TypeTag() TypeTag
- type PDFArray
- type PDFDict
- type PDFDocument
- func (d *PDFDocument) AddPage(width, height float64) Object
- func (d *PDFDocument) GetMember(name string) Object
- func (d *PDFDocument) HashKey() HashKey
- func (d *PDFDocument) Inspect() string
- func (d *PDFDocument) Save(filePath string) Object
- func (d *PDFDocument) SetFont(name string, size float64) Object
- func (d *PDFDocument) ToBool() *Bool
- func (d *PDFDocument) ToBytes() Object
- func (d *PDFDocument) Type() ObjectType
- func (d *PDFDocument) TypeTag() TypeTag
- func (d *PDFDocument) WriteText(pageIndex int, text string, x, y float64, opts map[string]interface{}) Object
- type PDFHexStr
- type PDFInfo
- type PDFName
- type PDFObj
- type PDFPage
- type PDFPageData
- type PDFRef
- type PDFStream
- type PDFString
- type PDFXRefEntry
- type PDFXRefTable
- type PPTXAudio
- func (a *PPTXAudio) GetData() []byte
- func (a *PPTXAudio) GetFormat() string
- func (a *PPTXAudio) GetPosition() PPTXPosition
- func (a *PPTXAudio) HashKey() HashKey
- func (a *PPTXAudio) Inspect() string
- func (a *PPTXAudio) Save(path string) error
- func (a *PPTXAudio) SetPosition(x, y int64)
- func (a *PPTXAudio) ToBool() *Bool
- func (a *PPTXAudio) Type() ObjectType
- func (a *PPTXAudio) TypeTag() TypeTag
- type PPTXBulletStyle
- type PPTXCellStyle
- type PPTXChart
- func (c *PPTXChart) GetKind() PPTXChartKind
- func (c *PPTXChart) GetPosition() PPTXPosition
- func (c *PPTXChart) GetSeries() []*PPTXChartSeries
- func (c *PPTXChart) GetSeriesCount() int
- func (c *PPTXChart) GetSize() PPTXSize
- func (c *PPTXChart) GetTitle() string
- func (c *PPTXChart) HashKey() HashKey
- func (c *PPTXChart) Inspect() string
- func (c *PPTXChart) SetPosition(x, y int64)
- func (c *PPTXChart) SetSize(width, height int64)
- func (c *PPTXChart) SetTitle(title string)
- func (c *PPTXChart) ToBool() *Bool
- func (c *PPTXChart) Type() ObjectType
- func (c *PPTXChart) TypeTag() TypeTag
- type PPTXChartData
- type PPTXChartKind
- type PPTXChartSeries
- func (s *PPTXChartSeries) GetName() string
- func (s *PPTXChartSeries) GetValues() []float64
- func (s *PPTXChartSeries) HashKey() HashKey
- func (s *PPTXChartSeries) Inspect() string
- func (s *PPTXChartSeries) SetName(name string)
- func (s *PPTXChartSeries) SetValues(values []float64)
- func (s *PPTXChartSeries) ToBool() *Bool
- func (s *PPTXChartSeries) Type() ObjectType
- func (s *PPTXChartSeries) TypeTag() TypeTag
- type PPTXChartSeriesData
- type PPTXChartStyle
- type PPTXColor
- type PPTXDocument
- func (d *PPTXDocument) AddSlide() *PPTXSlide
- func (d *PPTXDocument) Close() error
- func (d *PPTXDocument) DeleteSlide(index int) bool
- func (d *PPTXDocument) DuplicateSlide(index int) *PPTXSlide
- func (d *PPTXDocument) GetProperties() *PPTXProperties
- func (d *PPTXDocument) GetSlide(index int) *PPTXSlide
- func (d *PPTXDocument) GetSlideCount() int
- func (d *PPTXDocument) GetSlides() []*PPTXSlide
- func (d *PPTXDocument) HashKey() HashKey
- func (d *PPTXDocument) Inspect() string
- func (d *PPTXDocument) MoveSlide(from, to int) bool
- func (d *PPTXDocument) Save(path string) error
- func (d *PPTXDocument) SetProperties(props *PPTXProperties)
- func (d *PPTXDocument) ToBool() *Bool
- func (d *PPTXDocument) ToBytes() ([]byte, error)
- func (d *PPTXDocument) Type() ObjectType
- func (d *PPTXDocument) TypeTag() TypeTag
- type PPTXFont
- type PPTXFormatScheme
- type PPTXGradient
- type PPTXImage
- func (i *PPTXImage) GetData() []byte
- func (i *PPTXImage) GetDataBase64() string
- func (i *PPTXImage) GetFormat() string
- func (i *PPTXImage) GetPosition() PPTXPosition
- func (i *PPTXImage) GetSize() PPTXSize
- func (i *PPTXImage) HashKey() HashKey
- func (i *PPTXImage) Inspect() string
- func (i *PPTXImage) Save(path string) error
- func (i *PPTXImage) SetPosition(x, y int64)
- func (i *PPTXImage) SetSize(width, height int64)
- func (i *PPTXImage) ToBool() *Bool
- func (i *PPTXImage) Type() ObjectType
- func (i *PPTXImage) TypeTag() TypeTag
- type PPTXParagraph
- func (p *PPTXParagraph) GetAlignment() string
- func (p *PPTXParagraph) GetRuns() []*PPTXTextRun
- func (p *PPTXParagraph) GetText() string
- func (p *PPTXParagraph) HashKey() HashKey
- func (p *PPTXParagraph) Inspect() string
- func (p *PPTXParagraph) SetAlignment(align string)
- func (p *PPTXParagraph) ToBool() *Bool
- func (p *PPTXParagraph) Type() ObjectType
- func (p *PPTXParagraph) TypeTag() TypeTag
- type PPTXPosition
- type PPTXProperties
- type PPTXShadow
- type PPTXShape
- func (s *PPTXShape) AddTextFrame(text string) *PPTXTextFrame
- func (s *PPTXShape) GetFill() *PPTXColor
- func (s *PPTXShape) GetKind() PPTXShapeKind
- func (s *PPTXShape) GetPosition() PPTXPosition
- func (s *PPTXShape) GetSize() PPTXSize
- func (s *PPTXShape) GetTextFrame() *PPTXTextFrame
- func (s *PPTXShape) HashKey() HashKey
- func (s *PPTXShape) Inspect() string
- func (s *PPTXShape) SetFill(color string)
- func (s *PPTXShape) SetPosition(x, y int64)
- func (s *PPTXShape) SetSize(width, height int64)
- func (s *PPTXShape) ToBool() *Bool
- func (s *PPTXShape) Type() ObjectType
- func (s *PPTXShape) TypeTag() TypeTag
- type PPTXShapeKind
- type PPTXShapeStyle
- type PPTXSize
- type PPTXSlide
- func (s *PPTXSlide) AddChart(chartKind PPTXChartKind, data PPTXChartData, options map[string]interface{}) *PPTXChart
- func (s *PPTXSlide) AddImage(path string, options map[string]interface{}) *PPTXImage
- func (s *PPTXSlide) AddImageFromBytes(data []byte, format string, options map[string]interface{}) *PPTXImage
- func (s *PPTXSlide) AddShape(shapeKind PPTXShapeKind, options map[string]interface{}) *PPTXShape
- func (s *PPTXSlide) AddTable(rows, cols int, options map[string]interface{}) *PPTXTable
- func (s *PPTXSlide) AddText(text string, options map[string]interface{}) *PPTXTextFrame
- func (s *PPTXSlide) GetAllText() string
- func (s *PPTXSlide) GetCharts() []*PPTXChart
- func (s *PPTXSlide) GetImages() []*PPTXImage
- func (s *PPTXSlide) GetIndex() int
- func (s *PPTXSlide) GetNotes() string
- func (s *PPTXSlide) GetShapes() []*PPTXShape
- func (s *PPTXSlide) GetTables() []*PPTXTable
- func (s *PPTXSlide) GetTexts() []*PPTXTextFrame
- func (s *PPTXSlide) HashKey() HashKey
- func (s *PPTXSlide) Inspect() string
- func (s *PPTXSlide) SetNotes(text string)
- func (s *PPTXSlide) ToBool() *Bool
- func (s *PPTXSlide) Type() ObjectType
- func (s *PPTXSlide) TypeTag() TypeTag
- type PPTXSlideBackground
- type PPTXSlideLayout
- type PPTXSlideMaster
- type PPTXTable
- func (t *PPTXTable) GetCell(row, col int) *PPTXTableCell
- func (t *PPTXTable) GetColCount() int
- func (t *PPTXTable) GetPosition() PPTXPosition
- func (t *PPTXTable) GetRowCount() int
- func (t *PPTXTable) GetSize() PPTXSize
- func (t *PPTXTable) GetValue(row, col int) string
- func (t *PPTXTable) HashKey() HashKey
- func (t *PPTXTable) Inspect() string
- func (t *PPTXTable) SetPosition(x, y int64)
- func (t *PPTXTable) SetSize(width, height int64)
- func (t *PPTXTable) SetValue(row, col int, value string)
- func (t *PPTXTable) ToBool() *Bool
- func (t *PPTXTable) Type() ObjectType
- func (t *PPTXTable) TypeTag() TypeTag
- type PPTXTableCell
- type PPTXTableStyle
- type PPTXTextFrame
- func (tf *PPTXTextFrame) GetParagraphs() []*PPTXParagraph
- func (tf *PPTXTextFrame) GetPosition() PPTXPosition
- func (tf *PPTXTextFrame) GetSize() PPTXSize
- func (tf *PPTXTextFrame) GetText() string
- func (tf *PPTXTextFrame) HashKey() HashKey
- func (tf *PPTXTextFrame) Inspect() string
- func (tf *PPTXTextFrame) SetPosition(x, y int64)
- func (tf *PPTXTextFrame) SetSize(width, height int64)
- func (tf *PPTXTextFrame) SetText(text string)
- func (tf *PPTXTextFrame) ToBool() *Bool
- func (tf *PPTXTextFrame) Type() ObjectType
- func (tf *PPTXTextFrame) TypeTag() TypeTag
- type PPTXTextRun
- func (r *PPTXTextRun) GetColor() string
- func (r *PPTXTextRun) GetFontName() string
- func (r *PPTXTextRun) GetFontSize() int
- func (r *PPTXTextRun) GetText() string
- func (r *PPTXTextRun) HashKey() HashKey
- func (r *PPTXTextRun) Inspect() string
- func (r *PPTXTextRun) IsBold() bool
- func (r *PPTXTextRun) IsItalic() bool
- func (r *PPTXTextRun) SetBold(bold bool)
- func (r *PPTXTextRun) SetColor(hex string)
- func (r *PPTXTextRun) SetFontName(name string)
- func (r *PPTXTextRun) SetFontSize(size int)
- func (r *PPTXTextRun) SetItalic(italic bool)
- func (r *PPTXTextRun) SetText(text string)
- func (r *PPTXTextRun) ToBool() *Bool
- func (r *PPTXTextRun) Type() ObjectType
- func (r *PPTXTextRun) TypeTag() TypeTag
- type PPTXTheme
- type PPTXThemeColors
- type PPTXThemeFonts
- type PPTXVideo
- func (v *PPTXVideo) GetData() []byte
- func (v *PPTXVideo) GetFormat() string
- func (v *PPTXVideo) GetPosition() PPTXPosition
- func (v *PPTXVideo) GetSize() PPTXSize
- func (v *PPTXVideo) HashKey() HashKey
- func (v *PPTXVideo) Inspect() string
- func (v *PPTXVideo) Save(path string) error
- func (v *PPTXVideo) SetPosition(x, y int64)
- func (v *PPTXVideo) SetSize(width, height int64)
- func (v *PPTXVideo) ToBool() *Bool
- func (v *PPTXVideo) Type() ObjectType
- func (v *PPTXVideo) TypeTag() TypeTag
- type Queue
- func (q *Queue) Clear()
- func (q *Queue) Clone() *Queue
- func (q *Queue) HashKey() HashKey
- func (q *Queue) Inspect() string
- func (q *Queue) IsEmpty() bool
- func (q *Queue) Len() int
- func (q *Queue) Peek() Object
- func (q *Queue) PeekBack() Object
- func (q *Queue) Pop() Object
- func (q *Queue) Push(item Object)
- func (q *Queue) ToArray() *Array
- func (q *Queue) ToBool() *Bool
- func (q *Queue) Type() ObjectType
- func (q *Queue) TypeTag() TypeTag
- type RWMutex
- func (m *RWMutex) HashKey() HashKey
- func (m *RWMutex) Inspect() string
- func (m *RWMutex) Lock()
- func (m *RWMutex) RLock()
- func (m *RWMutex) RUnlock()
- func (m *RWMutex) ToBool() *Bool
- func (m *RWMutex) TryLock() bool
- func (m *RWMutex) TryRLock() bool
- func (m *RWMutex) Type() ObjectType
- func (m *RWMutex) TypeTag() TypeTag
- func (m *RWMutex) Unlock()
- type Reader
- func (r *Reader) Close() Object
- func (r *Reader) GetMember(name string) Object
- func (r *Reader) HashKey() HashKey
- func (r *Reader) Inspect() string
- func (r *Reader) Read(n int) Object
- func (r *Reader) ReadAllBytes() Object
- func (r *Reader) ReadAllStr() Object
- func (r *Reader) ReadLine() Object
- func (r *Reader) ReadStr(n int) Object
- func (r *Reader) ToBool() *Bool
- func (r *Reader) Type() ObjectType
- func (r *Reader) TypeTag() TypeTag
- type Return
- type Scanner
- type Set
- func (s *Set) Add(item Object) bool
- func (s *Set) Clear()
- func (s *Set) Clone() *Set
- func (s *Set) Contains(item Object) bool
- func (s *Set) Difference(other *Set) *Set
- func (s *Set) Equals(other *Set) bool
- func (s *Set) HashKey() HashKey
- func (s *Set) Inspect() string
- func (s *Set) Intersect(other *Set) *Set
- func (s *Set) IsEmpty() bool
- func (s *Set) IsSubset(other *Set) bool
- func (s *Set) IsSuperset(other *Set) bool
- func (s *Set) Len() int
- func (s *Set) Remove(item Object) bool
- func (s *Set) SymmetricDifference(other *Set) *Set
- func (s *Set) ToArray() *Array
- func (s *Set) ToBool() *Bool
- func (s *Set) ToSortedArray() *Array
- func (s *Set) Type() ObjectType
- func (s *Set) TypeTag() TypeTag
- func (s *Set) Union(other *Set) *Set
- type Sheet
- type String
- type StringBuilder
- func (sb *StringBuilder) Cap() int
- func (sb *StringBuilder) Clear()
- func (sb *StringBuilder) GetIOWriter() *stringBuilderWriter
- func (sb *StringBuilder) Grow(n int)
- func (sb *StringBuilder) HashKey() HashKey
- func (sb *StringBuilder) Inspect() string
- func (sb *StringBuilder) Len() int
- func (sb *StringBuilder) Reset()
- func (sb *StringBuilder) String() string
- func (sb *StringBuilder) ToBool() *Bool
- func (sb *StringBuilder) Type() ObjectType
- func (sb *StringBuilder) TypeTag() TypeTag
- func (sb *StringBuilder) Write(s string) int
- func (sb *StringBuilder) WriteLine(s string) int
- type StringPoolStats
- type Tube
- func (t *Tube) Cap() int
- func (t *Tube) CapMethod(args ...Object) Object
- func (t *Tube) Close()
- func (t *Tube) CloseMethod(args ...Object) Object
- func (t *Tube) ElemType() ObjectType
- func (t *Tube) HashKey() HashKey
- func (t *Tube) ID() uint64
- func (t *Tube) Inspect() string
- func (t *Tube) IsClosed() bool
- func (t *Tube) IsClosedMethod(args ...Object) Object
- func (t *Tube) Len() int
- func (t *Tube) LenMethod(args ...Object) Object
- func (t *Tube) Receive() (Object, bool)
- func (t *Tube) ReceiveMethod(args ...Object) Object
- func (t *Tube) ReflectValue() reflect.Value
- func (t *Tube) Send(val Object) bool
- func (t *Tube) SendMethod(args ...Object) Object
- func (t *Tube) SendWithTimeout(val Object, timeoutMs int) (sent bool, ok bool)
- func (t *Tube) ToBool() *Bool
- func (t *Tube) TryReceive() (Object, bool, bool)
- func (t *Tube) TryReceiveMethod(args ...Object) Object
- func (t *Tube) TrySend(val Object) (sent bool, ok bool)
- func (t *Tube) Type() ObjectType
- func (t *Tube) TypeTag() TypeTag
- type TypeTag
- type WaitGroup
- type WebSocket
- func (ws *WebSocket) Close() Object
- func (ws *WebSocket) HashKey() HashKey
- func (ws *WebSocket) Inspect() string
- func (ws *WebSocket) IsClosed() bool
- func (ws *WebSocket) ReadMessage() Object
- func (ws *WebSocket) SendBinaryMessage(data string) Object
- func (ws *WebSocket) SendCloseMessage() Object
- func (ws *WebSocket) SendTextMessage(text string) Object
- func (ws *WebSocket) ToBool() *Bool
- func (ws *WebSocket) Type() ObjectType
- func (ws *WebSocket) TypeTag() TypeTag
- type WebSocketConn
- type WebView
- func (w *WebView) AddCallback(name string, fn *Function)
- func (w *WebView) Close()
- func (w *WebView) Equals(other Object) *Bool
- func (w *WebView) GetCallback(name string) (*Function, bool)
- func (w *WebView) HashKey() HashKey
- func (w *WebView) Inspect() string
- func (w *WebView) IsClosed() bool
- func (w *WebView) SetClosed(closed bool)
- func (w *WebView) ToBool() *Bool
- func (w *WebView) Type() ObjectType
- func (w *WebView) TypeTag() TypeTag
- type Writer
- func (w *Writer) Close() Object
- func (w *Writer) GetMember(name string) Object
- func (w *Writer) HashKey() HashKey
- func (w *Writer) Inspect() string
- func (w *Writer) ToBool() *Bool
- func (w *Writer) Type() ObjectType
- func (w *Writer) TypeTag() TypeTag
- func (w *Writer) Write(data []byte) Object
- func (w *Writer) WriteBytes(arr *Array) Object
- func (w *Writer) WriteStr(s string) Object
- type XLSX
- func (x *XLSX) Close()
- func (x *XLSX) DeleteCol(sheetName string, col int) error
- func (x *XLSX) DeleteRow(sheetName string, row int) error
- func (x *XLSX) DeleteSheet(name string) bool
- func (x *XLSX) ExtractImage(sheetName string, imageIndex int, outputPath string) error
- func (x *XLSX) GetCell(sheetName, ref string) Object
- func (x *XLSX) GetCellByIndex(sheetName string, row, col int) Object
- func (x *XLSX) GetCol(sheetName string, col int) *Array
- func (x *XLSX) GetColCount(sheetName string) int
- func (x *XLSX) GetImageData(sheetName string, imageIndex int) (string, error)
- func (x *XLSX) GetImages(sheetName string) *Array
- func (x *XLSX) GetMerges(sheetName string) *Array
- func (x *XLSX) GetRange(sheetName, rangeStr string) *Array
- func (x *XLSX) GetRow(sheetName string, row int) *Array
- func (x *XLSX) GetRowCount(sheetName string) int
- func (x *XLSX) GetSheet(name string) *Sheet
- func (x *XLSX) GetSheetByIndex(index int) *Sheet
- func (x *XLSX) GetSheetCount() int
- func (x *XLSX) GetSheetList() []string
- func (x *XLSX) GetSheetName(index int) string
- func (x *XLSX) HashKey() HashKey
- func (x *XLSX) InsertCol(sheetName string, col int) error
- func (x *XLSX) InsertRow(sheetName string, row int) error
- func (x *XLSX) Inspect() string
- func (x *XLSX) MergeCell(sheetName string, startRef, endRef string) error
- func (x *XLSX) NewSheet(name string) bool
- func (x *XLSX) Save(path string) error
- func (x *XLSX) SetCell(sheetName, ref string, value Object) error
- func (x *XLSX) SetCellByIndex(sheetName string, row, col int, value Object) error
- func (x *XLSX) SetRow(sheetName string, row int, values *Array) error
- func (x *XLSX) ToBool() *Bool
- func (x *XLSX) Type() ObjectType
- func (x *XLSX) TypeTag() TypeTag
- func (x *XLSX) UnmergeCell(sheetName string, ref string) error
- type XMLDocument
- func (d *XMLDocument) Encoding() string
- func (d *XMLDocument) Find(path string) *Array
- func (d *XMLDocument) FindElement(path string) *XMLNode
- func (d *XMLDocument) FindFirst(path string) *XMLNode
- func (d *XMLDocument) HashKey() HashKey
- func (d *XMLDocument) Inspect() string
- func (d *XMLDocument) Root() *XMLNode
- func (d *XMLDocument) Save(path string) error
- func (d *XMLDocument) SetRoot(node *XMLNode)
- func (d *XMLDocument) ToBool() *Bool
- func (d *XMLDocument) ToIndented() string
- func (d *XMLDocument) ToMap() *Map
- func (d *XMLDocument) ToString() string
- func (d *XMLDocument) Type() ObjectType
- func (d *XMLDocument) TypeTag() TypeTag
- func (d *XMLDocument) Version() string
- type XMLNode
- func (n *XMLNode) AddChild(child *XMLNode)
- func (n *XMLNode) Attr(name string) string
- func (n *XMLNode) Attrs() *Map
- func (n *XMLNode) ChildCount() int
- func (n *XMLNode) Children() *Array
- func (n *XMLNode) Clear()
- func (n *XMLNode) DelAttr(name string)
- func (n *XMLNode) Find(path string) *Array
- func (n *XMLNode) FindFirst(path string) *XMLNode
- func (n *XMLNode) HashKey() HashKey
- func (n *XMLNode) Inspect() string
- func (n *XMLNode) Name() string
- func (n *XMLNode) Parent() *XMLNode
- func (n *XMLNode) RemoveChild(index int) bool
- func (n *XMLNode) SetAttr(name, value string)
- func (n *XMLNode) SetName(name string)
- func (n *XMLNode) SetText(text string)
- func (n *XMLNode) Text() string
- func (n *XMLNode) ToBool() *Bool
- func (n *XMLNode) ToIndented() string
- func (n *XMLNode) ToMap() *Map
- func (n *XMLNode) ToString() string
- func (n *XMLNode) Type() ObjectType
- func (n *XMLNode) TypeTag() TypeTag
Constants ¶
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()
const ( WebSocketTextMessage = 1 WebSocketBinaryMessage = 2 WebSocketCloseMessage = 8 WebSocketPingMessage = 9 WebSocketPongMessage = 10 )
WebSocketMessageType constants
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
const ( EMU_PER_INCH = 914400 EMU_PER_POINT = 12700 EMU_PER_PIXEL = 9525 // at 96 DPI )
EMU conversion constants (English Metric Units)
const DefaultBigFloatPrecision = 256
DefaultBigFloatPrecision is the default precision for BigFloat values (256 bits)
const IntCacheMax = 100000
IntCacheMax is the maximum cached integer value Extended to cover common loop indices and calculation results
const IntCacheMin = -1000
IntCacheMin is the minimum cached integer value
Variables ¶
var ( ContextCanceled = &Error{Message: "context canceled"} ContextDeadlineExceeded = &Error{Message: "context deadline exceeded"} )
Context error types for Xxlang
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
var ( TRUE = &Bool{Value: true} FALSE = &Bool{Value: false} )
TRUE and FALSE are singleton boolean values
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
var (
BYTES_EMPTY = &Bytes{Value: []byte{}}
)
Pre-cached common Bytes values
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.
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.
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]
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).
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.
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.
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.
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...)
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...)
var BuiltinDbQueryOrdered = &Builtin{ Fn: func(args ...Object) Object { if len(args) < 2 { return newError("wrong number of arguments for dbQueryOrdered. got=%d, want>=2", len(args)) } db, ok := args[0].(*DB) if !ok { return newError("first argument to 'dbQueryOrdered' must be DB, got %s", args[0].Type()) } query, ok := args[1].(*String) if !ok { return newError("second argument to 'dbQueryOrdered' must be STRING, got %s", args[1].Type()) } queryArgs := make([]interface{}, len(args)-2) for i, arg := range args[2:] { queryArgs[i] = objectToGoValue(arg) } rows, err := db.Value.Query(query.Value, queryArgs...) if err != nil { return newError("query failed: %v", err) } defer rows.Close() columns, err := rows.Columns() if err != nil { return newError("failed to get columns: %v", err) } var result []Object for rows.Next() { values := make([]interface{}, len(columns)) valuePtrs := make([]interface{}, len(columns)) for i := range values { valuePtrs[i] = &values[i] } if err := rows.Scan(valuePtrs...); err != nil { return newError("scan failed: %v", err) } pairs := make([]Object, len(columns)) for i, col := range columns { pairs[i] = NewArray([]Object{ NewString(col), NewString(dbValueToString(values[i])), }) } result = append(result, NewArray(pairs)) } if err := rows.Err(); err != nil { return newError("rows error: %v", err) } return NewArray(result) }, }
BuiltinDbQueryOrdered executes a SQL query and returns results as an array of ordered maps. All values are converted to strings.
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).
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.
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.
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).
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.
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.
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
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
var BuiltinSystemStart = &Builtin{ Fn: func(args ...Object) Object { if len(args) < 1 { return newError("wrong number of arguments for systemStart. got=%d, want>=1", len(args)) } pathStr, ok := args[0].(*String) if !ok { return newError("first argument to 'systemStart' must be STRING, got %s", args[0].Type()) } path := pathStr.Value // Optional working directory var workingDir string if len(args) >= 2 { if wd, ok := args[1].(*String); ok { workingDir = wd.Value } } var err error switch runtime.GOOS { case "windows": cmd := exec.Command("cmd", "/c", "start", "", path) if workingDir != "" { cmd.Dir = workingDir } cmd.Stdout = nil cmd.Stderr = nil err = cmd.Run() case "darwin": cmd := exec.Command("open", path) if workingDir != "" { cmd.Dir = workingDir } cmd.Stdout = nil cmd.Stderr = nil err = cmd.Run() case "linux": cmd := exec.Command("xdg-open", path) if workingDir != "" { cmd.Dir = workingDir } cmd.Stdout = nil cmd.Stderr = nil err = cmd.Run() default: err = fmt.Errorf("unsupported platform: %s", runtime.GOOS) } result := NewOrderedMap() if err != nil { result.Set(NewString("success"), FALSE) result.Set(NewString("error"), NewString(err.Error())) } else { result.Set(NewString("success"), TRUE) result.Set(NewString("error"), NewString("")) } return result }, }
BuiltinSystemStart starts a program or opens a file/URL with the default application. This is similar to the "start" command on Windows or "open" on macOS. Usage: systemStart(path) or systemStart(path, workingDir) Returns a map with:
- "success": bool - whether the operation succeeded
- "error": string - error message if any
var Builtins = map[string]*Builtin{}/* 203 elements not displayed */
Builtins contains all built-in functions
var (
CHARS_EMPTY = &Chars{Value: []rune{}}
)
Pre-cached common chars values
var EMPTY_ARRAY = &Array{Elements: emptyElements}
Pre-cached empty array
var EMPTY_MAP = &Map{Pairs: emptyPairs}
Pre-cached empty map
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.
var HttpBuiltins = map[string]*Builtin{ "writeResp": { Fn: func(args ...Object) Object { if len(args) != 2 { return newError("wrong number of arguments for writeResp. got=%d, want=2", len(args)) } resp, ok := args[0].(*HttpResp) if !ok { return newError("first argument to 'writeResp' must be HTTP_RESP, got %s", args[0].Type()) } var content string switch c := args[1].(type) { case *String: content = c.Value default: content = c.Inspect() } if resp.Value == nil { return newError("http response is nil") } _, err := resp.Value.Write([]byte(content)) if err != nil { return newError("write response failed: %v", err) } resp.SetWritten() return NULL }, }, "setRespHeader": { Fn: func(args ...Object) Object { if len(args) != 3 { return newError("wrong number of arguments for setRespHeader. got=%d, want=3", len(args)) } resp, ok := args[0].(*HttpResp) if !ok { return newError("first argument to 'setRespHeader' must be HTTP_RESP, got %s", args[0].Type()) } key, ok := args[1].(*String) if !ok { return newError("second argument to 'setRespHeader' must be STRING, got %s", args[1].Type()) } value, ok := args[2].(*String) if !ok { return newError("third argument to 'setRespHeader' must be STRING, got %s", args[2].Type()) } if resp.Value == nil { return newError("http response is nil") } resp.Value.Header().Set(key.Value, value.Value) return NULL }, }, "addRespHeader": { Fn: func(args ...Object) Object { if len(args) != 3 { return newError("wrong number of arguments for addRespHeader. got=%d, want=3", len(args)) } resp, ok := args[0].(*HttpResp) if !ok { return newError("first argument to 'addRespHeader' must be HTTP_RESP, got %s", args[0].Type()) } key, ok := args[1].(*String) if !ok { return newError("second argument to 'addRespHeader' must be STRING, got %s", args[1].Type()) } value, ok := args[2].(*String) if !ok { return newError("third argument to 'addRespHeader' must be STRING, got %s", args[2].Type()) } if resp.Value == nil { return newError("http response is nil") } resp.Value.Header().Add(key.Value, value.Value) return NULL }, }, "getReqHeader": { Fn: func(args ...Object) Object { if len(args) != 2 { return newError("wrong number of arguments for getReqHeader. got=%d, want=2", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("first argument to 'getReqHeader' must be HTTP_REQ, got %s", args[0].Type()) } key, ok := args[1].(*String) if !ok { return newError("second argument to 'getReqHeader' must be STRING, got %s", args[1].Type()) } if req.Value == nil { return newError("http request is nil") } value := req.Value.Header.Get(key.Value) return NewString(value) }, }, "getReqHeaders": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for getReqHeaders. got=%d, want=1", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("argument to 'getReqHeaders' must be HTTP_REQ, got %s", args[0].Type()) } if req.Value == nil { return newError("http request is nil") } return req.getHeaders() }, }, "setCookie": { Fn: func(args ...Object) Object { if len(args) < 3 || len(args) > 4 { return newError("wrong number of arguments for setCookie. got=%d, want=3 or 4", len(args)) } resp, ok := args[0].(*HttpResp) if !ok { return newError("first argument to 'setCookie' must be HTTP_RESP, got %s", args[0].Type()) } name, ok := args[1].(*String) if !ok { return newError("second argument to 'setCookie' must be STRING, got %s", args[1].Type()) } value, ok := args[2].(*String) if !ok { return newError("third argument to 'setCookie' must be STRING, got %s", args[2].Type()) } if resp.Value == nil { return newError("http response is nil") } cookie := &http.Cookie{ Name: name.Value, Value: value.Value, } if len(args) == 4 { opts, ok := args[3].(*Map) if !ok { return newError("fourth argument to 'setCookie' must be MAP, got %s", args[3].Type()) } for _, pair := range opts.Pairs { keyStr, ok := pair.Key.(*String) if !ok { continue } switch keyStr.Value { case "path": if v, ok := pair.Value.(*String); ok { cookie.Path = v.Value } case "domain": if v, ok := pair.Value.(*String); ok { cookie.Domain = v.Value } case "maxAge": if v, ok := pair.Value.(*Int); ok { cookie.MaxAge = int(v.Value) } case "secure": if v, ok := pair.Value.(*Bool); ok { cookie.Secure = v.Value } case "httpOnly": if v, ok := pair.Value.(*Bool); ok { cookie.HttpOnly = v.Value } case "sameSite": if v, ok := pair.Value.(*Int); ok { cookie.SameSite = http.SameSite(v.Value) } case "expires": if v, ok := pair.Value.(*String); ok { t, err := time.Parse(time.RFC3339, v.Value) if err == nil { cookie.Expires = t } } } } } http.SetCookie(resp.Value, cookie) return NULL }, }, "getCookie": { Fn: func(args ...Object) Object { if len(args) != 2 { return newError("wrong number of arguments for getCookie. got=%d, want=2", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("first argument to 'getCookie' must be HTTP_REQ, got %s", args[0].Type()) } name, ok := args[1].(*String) if !ok { return newError("second argument to 'getCookie' must be STRING, got %s", args[1].Type()) } if req.Value == nil { return newError("http request is nil") } cookie, err := req.Value.Cookie(name.Value) if err != nil { return NULL } return NewString(cookie.Value) }, }, "getCookies": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for getCookies. got=%d, want=1", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("argument to 'getCookies' must be HTTP_REQ, got %s", args[0].Type()) } if req.Value == nil { return newError("http request is nil") } pairs := make(map[HashKey]MapPair) for _, cookie := range req.Value.Cookies() { k := NewString(cookie.Name) pairs[k.HashKey()] = MapPair{Key: k, Value: NewString(cookie.Value)} } return NewMap(pairs) }, }, "parseForm": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for parseForm. got=%d, want=1", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("argument to 'parseForm' must be HTTP_REQ, got %s", args[0].Type()) } if req.Value == nil { return newError("http request is nil") } if err := req.Value.ParseForm(); err != nil { return newError("parse form failed: %v", err) } pairs := make(map[HashKey]MapPair) for key, values := range req.Value.URL.Query() { k := NewString(key) var v Object if len(values) == 1 { v = NewString(values[0]) } else { elements := make([]Object, len(values)) for i, val := range values { elements[i] = NewString(val) } v = NewArray(elements) } pairs[k.HashKey()] = MapPair{Key: k, Value: v} } for key, values := range req.Value.PostForm { k := NewString(key) if existing, ok := pairs[k.HashKey()]; ok { if arr, ok := existing.Value.(*Array); ok { elements := arr.Elements for _, val := range values { elements = append(elements, NewString(val)) } pairs[k.HashKey()] = MapPair{Key: k, Value: NewArray(elements)} } else { elements := []Object{existing.Value} for _, val := range values { elements = append(elements, NewString(val)) } pairs[k.HashKey()] = MapPair{Key: k, Value: NewArray(elements)} } } else { var v Object if len(values) == 1 { v = NewString(values[0]) } else { elements := make([]Object, len(values)) for i, val := range values { elements[i] = NewString(val) } v = NewArray(elements) } pairs[k.HashKey()] = MapPair{Key: k, Value: v} } } return NewMap(pairs) }, }, "parseJSON": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for parseJSON. got=%d, want=1", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("argument to 'parseJSON' must be HTTP_REQ, got %s", args[0].Type()) } if req.Value == nil { return newError("http request is nil") } body, err := io.ReadAll(req.Value.Body) if err != nil { return newError("read request body failed: %v", err) } var data interface{} if err := json.Unmarshal(body, &data); err != nil { return newError("parse JSON failed: %v", err) } return GoValueToObject(data) }, }, "getReqBody": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for getReqBody. got=%d, want=1", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("argument to 'getReqBody' must be HTTP_REQ, got %s", args[0].Type()) } if req.Value == nil { return newError("http request is nil") } body, err := io.ReadAll(req.Value.Body) if err != nil { return newError("read request body failed: %v", err) } return NewString(string(body)) }, }, "getReqBodyBytes": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for getReqBodyBytes. got=%d, want=1", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("argument to 'getReqBodyBytes' must be HTTP_REQ, got %s", args[0].Type()) } if req.Value == nil { return newError("http request is nil") } body, err := io.ReadAll(req.Value.Body) if err != nil { return newError("read request body failed: %v", err) } elements := make([]Object, len(body)) for i, b := range body { elements[i] = NewInt(int64(b)) } return NewArray(elements) }, }, "status": { Fn: func(args ...Object) Object { if len(args) != 2 { return newError("wrong number of arguments for status. got=%d, want=2", len(args)) } resp, ok := args[0].(*HttpResp) if !ok { return newError("first argument to 'status' must be HTTP_RESP, got %s", args[0].Type()) } code, ok := args[1].(*Int) if !ok { return newError("second argument to 'status' must be INT, got %s", args[1].Type()) } if resp.Value == nil { return newError("http response is nil") } resp.Value.WriteHeader(int(code.Value)) return NULL }, }, "redirect": { Fn: func(args ...Object) Object { if len(args) < 2 || len(args) > 3 { return newError("wrong number of arguments for redirect. got=%d, want=2 or 3", len(args)) } resp, ok := args[0].(*HttpResp) if !ok { return newError("first argument to 'redirect' must be HTTP_RESP, got %s", args[0].Type()) } url, ok := args[1].(*String) if !ok { return newError("second argument to 'redirect' must be STRING, got %s", args[1].Type()) } code := 302 if len(args) == 3 { c, ok := args[2].(*Int) if !ok { return newError("third argument to 'redirect' must be INT, got %s", args[2].Type()) } code = int(c.Value) } if resp.Value == nil { return newError("http response is nil") } http.Redirect(resp.Value, &http.Request{}, url.Value, code) resp.SetWritten() return NULL }, }, "serveFile": { Fn: func(args ...Object) Object { if len(args) != 3 { return newError("wrong number of arguments for serveFile. got=%d, want=3", len(args)) } resp, ok := args[0].(*HttpResp) if !ok { return newError("first argument to 'serveFile' must be HTTP_RESP, got %s", args[0].Type()) } req, ok := args[1].(*HttpReq) if !ok { return newError("second argument to 'serveFile' must be HTTP_REQ, got %s", args[1].Type()) } path, ok := args[2].(*String) if !ok { return newError("third argument to 'serveFile' must be STRING, got %s", args[2].Type()) } if resp.Value == nil || req.Value == nil { return newError("http response or request is nil") } http.ServeFile(resp.Value, req.Value, path.Value) resp.SetWritten() return NULL }, }, "getMimeType": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for getMimeType. got=%d, want=1", len(args)) } path, ok := args[0].(*String) if !ok { return newError("argument to 'getMimeType' must be STRING, got %s", args[0].Type()) } ext := filepath.Ext(path.Value) mimeType := mime.TypeByExtension(ext) if mimeType == "" { mimeType = "application/octet-stream" } return NewString(mimeType) }, }, "setContentType": { Fn: func(args ...Object) Object { if len(args) != 2 { return newError("wrong number of arguments for setContentType. got=%d, want=2", len(args)) } resp, ok := args[0].(*HttpResp) if !ok { return newError("first argument to 'setContentType' must be HTTP_RESP, got %s", args[0].Type()) } mimeType, ok := args[1].(*String) if !ok { return newError("second argument to 'setContentType' must be STRING, got %s", args[1].Type()) } if resp.Value == nil { return newError("http response is nil") } resp.Value.Header().Set("Content-Type", mimeType.Value) return NULL }, }, "queryParam": { Fn: func(args ...Object) Object { if len(args) != 2 { return newError("wrong number of arguments for queryParam. got=%d, want=2", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("first argument to 'queryParam' must be HTTP_REQ, got %s", args[0].Type()) } name, ok := args[1].(*String) if !ok { return newError("second argument to 'queryParam' must be STRING, got %s", args[1].Type()) } if req.Value == nil { return newError("http request is nil") } value := req.Value.URL.Query().Get(name.Value) return NewString(value) }, }, "queryParams": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for queryParams. got=%d, want=1", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("argument to 'queryParams' must be HTTP_REQ, got %s", args[0].Type()) } if req.Value == nil { return newError("http request is nil") } pairs := make(map[HashKey]MapPair) for key, values := range req.Value.URL.Query() { k := NewString(key) var v Object if len(values) == 1 { v = NewString(values[0]) } else { elements := make([]Object, len(values)) for i, val := range values { elements[i] = NewString(val) } v = NewArray(elements) } pairs[k.HashKey()] = MapPair{Key: k, Value: v} } return NewMap(pairs) }, }, "formValue": { Fn: func(args ...Object) Object { if len(args) != 2 { return newError("wrong number of arguments for formValue. got=%d, want=2", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("first argument to 'formValue' must be HTTP_REQ, got %s", args[0].Type()) } name, ok := args[1].(*String) if !ok { return newError("second argument to 'formValue' must be STRING, got %s", args[1].Type()) } if req.Value == nil { return newError("http request is nil") } value := req.Value.FormValue(name.Value) return NewString(value) }, }, "webSocket": { Fn: func(args ...Object) Object { if len(args) != 2 { return newError("wrong number of arguments for webSocket. got=%d, want=2", len(args)) } req, ok := args[0].(*HttpReq) if !ok { return newError("first argument to 'webSocket' must be HTTP_REQ, got %s", args[0].Type()) } resp, ok := args[1].(*HttpResp) if !ok { return newError("second argument to 'webSocket' must be HTTP_RESP, got %s", args[1].Type()) } if req.Value == nil || resp.Value == nil { return newError("http request or response is nil") } conn, err := websocketUpgrader.Upgrade(resp.Value, req.Value, nil) if err != nil { return newError("websocket upgrade failed: %v", err) } return NewWebSocket(conn) }, }, "wsReadMsg": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for wsReadMsg. got=%d, want=1", len(args)) } ws, ok := args[0].(*WebSocket) if !ok { return newError("argument to 'wsReadMsg' must be WEBSOCKET, got %s", args[0].Type()) } return ws.ReadMessage() }, }, "wsSendText": { Fn: func(args ...Object) Object { if len(args) != 2 { return newError("wrong number of arguments for wsSendText. got=%d, want=2", len(args)) } ws, ok := args[0].(*WebSocket) if !ok { return newError("first argument to 'wsSendText' must be WEBSOCKET, got %s", args[0].Type()) } text, ok := args[1].(*String) if !ok { return newError("second argument to 'wsSendText' must be STRING, got %s", args[1].Type()) } return ws.SendTextMessage(text.Value) }, }, "wsSendBinary": { Fn: func(args ...Object) Object { if len(args) != 2 { return newError("wrong number of arguments for wsSendBinary. got=%d, want=2", len(args)) } ws, ok := args[0].(*WebSocket) if !ok { return newError("first argument to 'wsSendBinary' must be WEBSOCKET, got %s", args[0].Type()) } data, ok := args[1].(*String) if !ok { return newError("second argument to 'wsSendBinary' must be STRING, got %s", args[1].Type()) } return ws.SendBinaryMessage(data.Value) }, }, "wsSendClose": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for wsSendClose. got=%d, want=1", len(args)) } ws, ok := args[0].(*WebSocket) if !ok { return newError("argument to 'wsSendClose' must be WEBSOCKET, got %s", args[0].Type()) } return ws.SendCloseMessage() }, }, "wsClose": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for wsClose. got=%d, want=1", len(args)) } ws, ok := args[0].(*WebSocket) if !ok { return newError("argument to 'wsClose' must be WEBSOCKET, got %s", args[0].Type()) } return ws.Close() }, }, "isWebSocket": { Fn: func(args ...Object) Object { if len(args) != 1 { return newError("wrong number of arguments for isWebSocket. got=%d, want=1", len(args)) } _, ok := args[0].(*WebSocket) return &Bool{Value: ok} }, }, }
HttpBuiltins contains all HTTP-related built-in functions. These are only available in server mode.
var NULL = &Null{}
NULL is the singleton null value
var TypeMethods = map[ObjectType]map[string]*Builtin{
IntType: intMethods,
FloatType: floatMethods,
BigIntType: bigIntMethods,
BigFloatType: bigFloatMethods,
StringType: stringMethods,
CharsType: charsMethods,
ArrayType: arrayMethods,
MapType: mapMethods,
BoolType: boolMethods,
NullType: nullMethods,
StringBuilderType: stringBuilderMethods,
BytesType: bytesMethods,
BytesBufferType: bytesBufferMethods,
WebSocketType: webSocketMethods,
MutexType: mutexMethods,
RWMutexType: rwMutexMethods,
WaitGroupType: waitGroupMethods,
AtomicIntType: atomicIntMethods,
TubeType: tubeMethods,
OnceType: onceMethods,
CondType: condMethods,
ContextType: contextMethods,
FileUploadType: fileUploadMethods,
FileUploadResultType: fileUploadResultMethods,
FileType: fileMethods,
FileInfoType: fileInfoMethods,
ReaderType: readerMethods,
WriterType: writerMethods,
ScannerType: scannerMethods,
OrderedMapType: orderedMapMethods,
QueueType: queueMethods,
SetType: setMethods,
XLSXType: xlsxMethods,
PPTXDocumentType: pptxDocumentMethods,
PPTXSlideType: pptxSlideMethods,
PPTXTextFrameType: pptxTextFrameMethods,
PPTXTextRunType: pptxTextRunMethods,
PPTXShapeType: pptxShapeMethods,
PPTXTableType: pptxTableMethods,
PPTXChartType: pptxChartMethods,
PPTXImageType: pptxImageMethods,
XMLDocumentType: xmlDocumentMethods,
XMLNodeType: xmlNodeMethods,
}
TypeMethods maps ObjectType -> methodName -> *Builtin
Functions ¶
func ClearInternCache ¶ added in v0.4.23
func ClearInternCache()
ClearInternCache clears the string intern cache Use with caution - this will cause all interned strings to be re-allocated
func ColToIndex ¶ added in v0.5.2
ColToIndex converts column letter to index (A=1).
func EncodeToXML ¶ added in v0.5.4
EncodeToXML converts an Object to XML string.
func ErrIndexOutOfRange ¶ added in v0.5.7
ErrIndexOutOfRange creates an error for an out of range index
func ErrKeyNotFound ¶ added in v0.5.7
ErrKeyNotFound creates an error for a missing key
func EscapeXMLAttr ¶ added in v0.5.4
EscapeXMLAttr escapes special characters for XML attributes.
func EscapeXMLText ¶ added in v0.5.4
EscapeXMLText escapes special characters for XML text.
func FormatBigFloat ¶ added in v0.4.25
FormatBigFloat formats a BigFloat value for display with the 'm' suffix
func FormatBigInt ¶ added in v0.4.25
FormatBigInt formats a BigInt value for display with the 'n' suffix
func IndexToCol ¶ added in v0.5.2
IndexToCol converts index to column letter.
func IsCachedInt ¶ added in v0.4.23
IsCachedInt returns true if the given value is within the cached range
func NewBytesReader ¶ added in v0.4.25
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
NewStringReader creates an io.Reader from a string. This is useful for creating a Reader from a string value.
func ObjectToGoValue ¶ added in v0.4.25
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
ParseCellRef parses a cell reference.
func ParseMultipartForm ¶ added in v0.4.25
func ParseMultipartForm(req *http.Request, maxMemory int64) (map[string][]string, map[string][]*FileUpload, error)
ParseMultipartForm parses a multipart form from an HTTP request. It returns a map of form values and a map of file uploads.
func PutBufferedFloat ¶ added in v0.4.23
func PutBufferedFloat(obj *Float)
PutBufferedFloat returns a temporary Float to the global buffer
func PutBufferedInt ¶ added in v0.4.23
func PutBufferedInt(obj *Int)
PutBufferedInt returns a temporary Int to the global buffer
func PutBufferedString ¶ added in v0.4.23
func PutBufferedString(obj *String)
PutBufferedString returns a temporary String to the global buffer
func RegisterFileUploadBuiltins ¶ added in v0.4.25
func RegisterFileUploadBuiltins()
RegisterFileUploadBuiltins registers file upload built-in functions into the main Builtins map.
func RegisterHttpBuiltins ¶ added in v0.4.25
func RegisterHttpBuiltins()
RegisterHttpBuiltins registers HTTP built-in functions into the main Builtins map.
func ReleaseArray ¶ added in v0.4.23
func ReleaseArray(obj *Array)
ReleaseArray returns an Array object to the pool
func ReleaseArraySlice ¶ added in v0.4.23
func ReleaseArraySlice(objs []*Array)
ReleaseArraySlice returns multiple Array objects to the pool
func ReleaseFloat ¶ added in v0.4.23
func ReleaseFloat(obj *Float)
ReleaseFloat returns a Float object to the pool if it's not a cached value This should be called when the object is no longer needed
func ReleaseFloatSlice ¶ added in v0.4.23
func ReleaseFloatSlice(objs []*Float)
ReleaseFloatSlice returns multiple Float objects to the pool This is more efficient than calling ReleaseFloat multiple times
func ReleaseInt ¶ added in v0.4.23
func ReleaseInt(obj *Int)
ReleaseInt returns an Int object to the pool if it's outside the cache range This should be called when the object is no longer needed
func ReleaseIntSlice ¶ added in v0.4.23
func ReleaseIntSlice(objs []*Int)
ReleaseIntSlice returns multiple Int objects to the pool This is more efficient than calling ReleaseInt multiple times
func ReleaseMap ¶ added in v0.4.23
func ReleaseMap(obj *Map)
ReleaseMap returns a Map object to the pool
func ReleaseMapSlice ¶ added in v0.4.23
func ReleaseMapSlice(objs []*Map)
ReleaseMapSlice returns multiple Map objects to the pool
func ReleaseOrderedMap ¶ added in v0.5.7
func ReleaseOrderedMap(om *OrderedMap)
ReleaseOrderedMap returns an OrderedMap to the pool
func ReleaseString ¶ added in v0.4.23
func ReleaseString(obj *String)
ReleaseString returns a String object to the pool if it's not a cached value This should be called when the object is no longer needed
func ReleaseStringSlice ¶ added in v0.4.23
func ReleaseStringSlice(objs []*String)
ReleaseStringSlice returns multiple String objects to the pool This is more efficient than calling ReleaseString multiple times
func ResetArrayPoolStats ¶ added in v0.4.23
func ResetArrayPoolStats()
ResetArrayPoolStats resets the pool statistics counters
func ResetFloatPoolStats ¶ added in v0.4.23
func ResetFloatPoolStats()
ResetFloatPoolStats resets the pool statistics counters
func ResetGlobalReader ¶ added in v0.4.25
func ResetGlobalReader()
ResetGlobalReader resets the global reader for stdin. This is useful for testing or when stdin needs to be reinitialized.
func ResetIntPoolStats ¶ added in v0.4.23
func ResetIntPoolStats()
ResetIntPoolStats resets the pool statistics counters
func ResetMapPoolStats ¶ added in v0.4.23
func ResetMapPoolStats()
ResetMapPoolStats resets the pool statistics counters
func ResetStringPoolStats ¶ added in v0.4.23
func ResetStringPoolStats()
ResetStringPoolStats resets the pool statistics counters
func SafePath ¶ added in v0.4.25
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 ScanRow ¶ added in v0.4.36
ScanRow scans a single row into a map. This is a helper function used by the db module.
func SetCallUserFuncImpl ¶ added in v0.4.25
func SetCallUserFuncImpl(fn func(fnObj Object, args ...Object) (Object, error)) func(Object, ...Object) (Object, error)
SetCallUserFuncImpl registers the callback for calling user functions and returns the previous value
func SetDelegateImpl ¶ added in v0.4.25
SetDelegateImpl registers the delegate implementation and returns the previous value
func SetLoadPluginImpl ¶ added in v0.4.19
SetLoadPluginImpl registers the loadPlugin implementation and returns the previous value
func SetRunCodeImpl ¶ added in v0.4.19
func SetRunCodeImpl(fn func(code string, args *Map) (Object, error)) func(code string, args *Map) (Object, error)
SetRunCodeImpl registers the runCode implementation and returns the previous value
func WarmArrayPool ¶ added in v0.4.23
func WarmArrayPool(count int)
WarmArrayPool pre-allocates Array objects into the pool
func WarmFloatPool ¶ added in v0.4.23
func WarmFloatPool(count int)
WarmFloatPool pre-allocates a number of Float objects into the pool This can improve performance by reducing allocations during hot paths
func WarmIntPool ¶ added in v0.4.23
func WarmIntPool(count int)
WarmIntPool pre-allocates a number of Int objects into the pool This can improve performance by reducing allocations during hot paths
func WarmMapPool ¶ added in v0.4.23
func WarmMapPool(count int)
WarmMapPool pre-allocates Map objects into the pool
func WarmStringPool ¶ added in v0.4.23
func WarmStringPool(count int)
WarmStringPool pre-allocates a number of String objects into the pool This can improve performance by reducing allocations during hot paths
Types ¶
type Array ¶
type Array struct {
Elements []Object
LastPopped Object // Used by pop() to return the popped value
}
Array represents an array value
func NewArrayWithCapacity ¶ added in v0.4.23
NewArrayWithCapacity creates a new Array with pre-allocated capacity
type ArrayPoolStats ¶ added in v0.4.23
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
NewAtomicInt creates a new AtomicInt with the given initial value
func (*AtomicInt) Add ¶ added in v0.4.25
Add atomically adds delta to the value and returns the new value
func (*AtomicInt) CompareAndSwap ¶ added in v0.4.25
CompareAndSwap atomically compares and swaps Returns true if the swap was successful
func (*AtomicInt) Type ¶ added in v0.4.25
func (a *AtomicInt) Type() ObjectType
Object interface implementation
type BigFloat ¶ added in v0.4.25
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
NewBigFloat creates a new BigFloat from a big.Float
func NewBigFloatFromBigInt ¶ added in v0.4.25
NewBigFloatFromBigInt creates a new BigFloat from a BigInt object
func NewBigFloatFromFloat64 ¶ added in v0.4.25
NewBigFloatFromFloat64 creates a new BigFloat from a float64
func NewBigFloatFromInt ¶ added in v0.4.25
NewBigFloatFromInt creates a new BigFloat from an Int object
func NewBigFloatFromInt64 ¶ added in v0.4.25
NewBigFloatFromInt64 creates a new BigFloat from an int64
func NewBigFloatFromString ¶ added in v0.4.25
NewBigFloatFromString creates a new BigFloat from a string representation
func (*BigFloat) AddFloat64 ¶ added in v0.4.25
AddFloat64 returns a new BigFloat that is the sum of b and a float64
func (*BigFloat) Ceil ¶ added in v0.4.25
Ceil returns the least integer value greater than or equal to b
func (*BigFloat) Cmp ¶ added in v0.4.25
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
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
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
Floor returns the greatest integer value less than or equal to b
func (*BigFloat) Inspect ¶ added in v0.4.25
Inspect returns the string representation (without the 'm' suffix)
func (*BigFloat) IsNegative ¶ added in v0.4.25
IsNegative returns true if the BigFloat is negative
func (*BigFloat) IsPositive ¶ added in v0.4.25
IsPositive returns true if the BigFloat is positive
func (*BigFloat) MulFloat64 ¶ added in v0.4.25
MulFloat64 returns a new BigFloat that is b multiplied by a float64
func (*BigFloat) Precision ¶ added in v0.4.25
Precision returns the precision of the BigFloat in bits
func (*BigFloat) SetPrecision ¶ added in v0.4.25
SetPrecision returns a new BigFloat with the specified precision
func (*BigFloat) Sign ¶ added in v0.4.25
Sign returns the sign of the BigFloat Returns -1 for negative, 0 for zero, 1 for positive
func (*BigFloat) SubFloat64 ¶ added in v0.4.25
SubFloat64 returns a new BigFloat that is b minus a float64
func (*BigFloat) ToBigInt ¶ added in v0.4.25
ToBigInt converts the BigFloat to a BigInt (truncates toward zero)
func (*BigFloat) ToFloat64 ¶ added in v0.4.25
ToFloat64 converts the BigFloat to float64 May lose precision for very large or high-precision values
func (*BigFloat) ToInt64 ¶ added in v0.4.25
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
type BigInt ¶ added in v0.4.25
BigInt represents an arbitrary-precision integer value It wraps Go's math/big.Int for unlimited precision integer arithmetic
func NewBigIntFromInt ¶ added in v0.4.25
NewBigIntFromInt creates a new BigInt from an Int object
func NewBigIntFromInt64 ¶ added in v0.4.25
NewBigIntFromInt64 creates a new BigInt from an int64
func NewBigIntFromString ¶ added in v0.4.25
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) AddInt ¶ added in v0.4.25
AddInt returns a new BigInt that is the sum of b and an int64
func (*BigInt) Cmp ¶ added in v0.4.25
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
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
DivInt returns a new BigInt that is b divided by an int64 Returns nil if n is zero
func (*BigInt) Inspect ¶ added in v0.4.25
Inspect returns the string representation (without the 'n' suffix)
func (*BigInt) IsNegative ¶ added in v0.4.25
IsNegative returns true if the BigInt is negative
func (*BigInt) IsPositive ¶ added in v0.4.25
IsPositive returns true if the BigInt is positive
func (*BigInt) Mod ¶ added in v0.4.25
Mod returns a new BigInt that is b mod other Returns nil if other is zero
func (*BigInt) ModInt ¶ added in v0.4.25
ModInt returns a new BigInt that is b mod an int64 Returns nil if n is zero
func (*BigInt) MulInt ¶ added in v0.4.25
MulInt returns a new BigInt that is b multiplied by an int64
func (*BigInt) Sign ¶ added in v0.4.25
Sign returns the sign of the BigInt Returns -1 for negative, 0 for zero, 1 for positive
func (*BigInt) ToBigFloat ¶ added in v0.4.25
ToBigFloat converts the BigInt to a BigFloat
func (*BigInt) ToFloat64 ¶ added in v0.4.25
ToFloat64 converts the BigInt to float64 May lose precision for very large values
func (*BigInt) ToInt64 ¶ added in v0.4.25
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
type Bool ¶
type Bool struct {
Value bool
}
Bool represents a boolean value
func (*Bool) Type ¶
func (b *Bool) Type() ObjectType
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) Type ¶
func (b *Builtin) Type() ObjectType
type BuiltinFunction ¶
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
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
NewBytesFromArray creates a new Bytes object from an integer array. Each integer must be in range 0-255.
func (*Bytes) Contains ¶ added in v0.4.25
Contains checks if the bytes contain the given subsequence.
func (*Bytes) GetIOReader ¶ added in v0.4.25
GetIOReader returns an io.Reader for the bytes. This allows Bytes to be used with Reader objects.
func (*Bytes) HasPrefix ¶ added in v0.4.25
HasPrefix checks if the bytes start with the given prefix.
func (*Bytes) Index ¶ added in v0.4.25
Index returns the index of the first occurrence of sub. Returns -1 if not found.
func (*Bytes) LastIndex ¶ added in v0.4.25
LastIndex returns the index of the last occurrence of sub. Returns -1 if not found.
func (*Bytes) Repeat ¶ added in v0.4.25
Repeat returns a new Bytes with the content repeated n times.
func (*Bytes) String ¶ added in v0.4.25
String returns the bytes as a string (UTF-8 interpretation).
func (*Bytes) Type ¶ added in v0.4.25
func (b *Bytes) Type() ObjectType
Type returns the object type.
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 NewCharsFromString ¶ added in v0.4.25
NewCharsFromString creates a new Chars object from a string
func (*Chars) Type ¶ added in v0.4.25
func (c *Chars) Type() ObjectType
Type returns the object type
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) Type ¶
func (c *Class) Type() ObjectType
type CompiledFunction ¶
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 (*Cond) Broadcast ¶ added in v0.4.25
func (c *Cond) Broadcast()
Broadcast wakes all goroutines waiting on the condition
func (*Cond) Signal ¶ added in v0.4.25
func (c *Cond) Signal()
Signal wakes one goroutine waiting on the condition
func (*Cond) Type ¶ added in v0.4.25
func (c *Cond) Type() ObjectType
Object interface implementation
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
NewContextWithCancel creates a context that can be cancelled manually
func NewContextWithDeadline ¶ added in v0.4.25
NewContextWithDeadline creates a context that cancels at deadline
func NewContextWithTimeout ¶ added in v0.4.25
NewContextWithTimeout creates a context that cancels after duration
func (*Context) Deadline ¶ added in v0.4.25
Deadline returns the deadline time and whether a deadline is set
func (*Context) DeadlineString ¶ added in v0.4.25
DeadlineString returns the deadline as a string
func (*Context) Done ¶ added in v0.4.25
Done returns the done tube (creates it lazily) The tube is a zero-buffer tube that gets closed when context is done
func (*Context) Type ¶ added in v0.4.25
func (c *Context) Type() ObjectType
Type returns the object type
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 (*DB) Inspect ¶ added in v0.4.36
Inspect returns a string representation of the database connection.
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 (*DBRows) ToBool ¶ added in v0.4.36
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.
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 (*DBStmt) ToBool ¶ added in v0.4.36
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.
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 (*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
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.
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
type Error ¶
type Error struct {
Message string
}
Error represents a runtime error
func (*Error) Type ¶
func (e *Error) Type() ObjectType
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 (*File) Close ¶ added in v0.4.25
Close closes the file handle. Returns nil on success, error otherwise.
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
Read reads up to n bytes from the file. Returns the bytes read as an array of integers.
func (*File) ReadLine ¶ added in v0.4.25
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
Seek sets the file position. Whence: 0 = start, 1 = current, 2 = end
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
NewFileInfo creates a new FileInfo from os.FileInfo.
func (*FileInfo) GetModTimeString ¶ added in v0.4.25
GetModTimeString returns the modification time as a formatted string.
func (*FileInfo) GetModTimeUnix ¶ added in v0.4.25
GetModTimeUnix returns the modification time as Unix timestamp (milliseconds).
func (*FileInfo) GetModeString ¶ added in v0.4.25
GetModeString returns the file mode as an octal string.
func (*FileInfo) Inspect ¶ added in v0.4.25
Inspect returns a string representation of the FileInfo.
func (*FileInfo) Type ¶ added in v0.4.25
func (fi *FileInfo) Type() ObjectType
Type returns the object type.
type FileLockType ¶ added in v0.4.25
type FileLockType int
FileLockType represents the type of file lock
const ( LockNone FileLockType = iota // No 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
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
GetBufferedFloat gets a temporary Float using the global buffer
func NewFloat ¶ added in v0.4.23
NewFloat creates a new Float object, using cached values for common floats
func NewFloatSlice ¶ added in v0.4.23
NewFloatSlice creates multiple Float objects efficiently This is optimized for batch operations
type FloatPoolStats ¶ added in v0.4.23
type FloatPoolStats struct {
// CacheHits is the number of times a cached float was returned
CacheHits int64
// PoolHits is the number of times a pooled float was reused
PoolHits int64
// Created is the number of new floats allocated by the pool
Created int64
// Released is the number of floats returned to the pool
Released int64
}
FloatPoolStats tracks statistics about float pool usage
func GetFloatPoolStats ¶ added in v0.4.23
func GetFloatPoolStats() FloatPoolStats
GetFloatPoolStats returns current statistics about float pool usage
type Function ¶
type Function struct {
Parameters []*Identifier
Body interface{} // Will be *ast.BlockStatement, using interface{} to avoid import cycle
Env *Environment
Name string // Optional: for named functions
}
Function represents a user-defined function
func (*Function) Type ¶
func (f *Function) Type() ObjectType
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) 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) Type ¶ added in v0.4.25
func (g *Goroutine) Type() ObjectType
Object interface implementation
type GoroutineStatus ¶ added in v0.4.25
type GoroutineStatus int
GoroutineStatus represents the state of a goroutine
const ( GoroutineRunning GoroutineStatus = iota GoroutineFinished GoroutinePanicked )
type HttpMux ¶ added in v0.4.25
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
HashKey returns a hash key for the HTTP mux. HTTP muxes are not hashable in a meaningful way.
func (*HttpMux) Type ¶ added in v0.4.25
func (m *HttpMux) Type() ObjectType
Type returns the object type.
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
NewHttpReq creates a new HttpReq object from an http.Request.
func (*HttpReq) HashKey ¶ added in v0.4.25
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
Inspect returns a string representation of the HTTP request.
func (*HttpReq) ToBool ¶ added in v0.4.25
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.
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) HashKey ¶ added in v0.4.25
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
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
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.
type Identifier ¶
type Identifier struct {
Value string
}
Identifier represents an identifier (used in function parameters)
func (*Identifier) String ¶
func (i *Identifier) String() string
type ImageInfo ¶ added in v0.5.2
type ImageInfo struct {
Col, Row int // Top-left position
ColEnd, RowEnd int // Bottom-right position
Filename string // Original filename in xlsx
Data []byte // Image data
}
ImageInfo represents an image in a sheet.
type Instance ¶
Instance represents an instance of a class
func (*Instance) Type ¶
func (i *Instance) Type() ObjectType
type Int ¶
type Int struct {
Value int64
}
Int represents an integer value
func GetBufferedInt ¶ added in v0.4.23
GetBufferedInt gets a temporary Int using the global buffer
func NewIntSlice ¶ added in v0.4.23
NewIntSlice creates multiple Int objects efficiently This is optimized for batch operations
type IntPoolStats ¶ added in v0.4.23
type IntPoolStats struct {
// CacheHits is the number of times a cached integer was returned
CacheHits int64
// PoolHits is the number of times a pooled integer was reused
PoolHits int64
// PoolMisses is the number of times a new integer had to be allocated
PoolMisses int64
// Created is the number of new integers allocated by the pool
Created int64
// Released is the number of integers returned to the pool
Released int64
}
IntPoolStats tracks statistics about integer pool usage
func GetIntPoolStats ¶ added in v0.4.23
func GetIntPoolStats() IntPoolStats
GetIntPoolStats returns current statistics about integer pool usage
type Map ¶
Map represents a map value
func NewMapWithCapacity ¶ added in v0.4.23
NewMapWithCapacity creates a new Map with pre-allocated capacity
func (*Map) GetSortedKeys ¶ added in v0.4.23
GetSortedKeys returns the keys in sorted order, caching the result
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
type MapPoolStats ¶ added in v0.4.23
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
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 ¶
HashKey returns a hash key for the module. Modules are not hashable in a meaningful way, so we return a constant.
type Mutex ¶ added in v0.4.25
type Mutex struct {
// contains filtered or unexported fields
}
Mutex wraps sync.Mutex for use in Xxlang
func (*Mutex) Lock ¶ added in v0.4.25
func (m *Mutex) Lock()
Lock acquires the mutex, blocking if necessary
func (*Mutex) TryLock ¶ added in v0.4.25
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
type Null ¶
type Null struct{}
Null represents the null value
func (*Null) Type ¶
func (n *Null) Type() ObjectType
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
CallUserFunc calls a user-defined function from within a builtin method Returns an error if the callback is not set or if the call fails
func GoValueToObject ¶ added in v0.4.25
func GoValueToObject(v interface{}) Object
GoValueToObject converts a Go value (from JSON unmarshaling) to an Xxlang Object. This function is exported for use by other packages that need to convert Go values to Xxlang objects.
func IoCopy ¶ added in v0.4.25
IoCopy copies data from reader to writer. This is exposed as a builtin function.
func JSONToObject ¶ added in v0.4.25
JSONToObject parses a JSON string and returns an Xxlang Object. This is the primary function for JSON deserialization in Xxlang.
func RowsToArrays ¶ added in v0.4.36
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
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
Scan reads a line from stdin and returns it as a string. If a prompt string is provided, it is printed first.
type ObjectToJSONOptions ¶ added in v0.4.25
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" DocxStyleType ObjectType = "DOCX_STYLE" DocxHyperlinkType ObjectType = "DOCX_HYPERLINK" DocxBookmarkType ObjectType = "DOCX_BOOKMARK" DocxTOCType ObjectType = "DOCX_TOC" DocxTextBoxType ObjectType = "DOCX_TEXT_BOX" DocxShapeType ObjectType = "DOCX_SHAPE" DocxChartType ObjectType = "DOCX_CHART" DocxCommentType ObjectType = "DOCX_COMMENT" DocxRevisionType ObjectType = "DOCX_REVISION" DocxFootnoteType ObjectType = "DOCX_FOOTNOTE" DocxEndnoteType ObjectType = "DOCX_ENDNOTE" // PPTX types PPTXDocumentType ObjectType = "PPTX_DOCUMENT" PPTXSlideType ObjectType = "PPTX_SLIDE" PPTXTextFrameType ObjectType = "PPTX_TEXT_FRAME" PPTXParagraphType ObjectType = "PPTX_PARAGRAPH" PPTXTextRunType ObjectType = "PPTX_TEXT_RUN" PPTXShapeType ObjectType = "PPTX_SHAPE" PPTXTableType ObjectType = "PPTX_TABLE" PPTXTableCellType ObjectType = "PPTX_TABLE_CELL" PPTXChartType ObjectType = "PPTX_CHART" PPTXChartSeriesType ObjectType = "PPTX_CHART_SERIES" PPTXImageType ObjectType = "PPTX_IMAGE" PPTXVideoType ObjectType = "PPTX_VIDEO" PPTXAudioType ObjectType = "PPTX_AUDIO" PPTXSlideLayoutType ObjectType = "PPTX_SLIDE_LAYOUT" PPTXSlideMasterType ObjectType = "PPTX_SLIDE_MASTER" PPTXThemeType ObjectType = "PPTX_THEME" // PDF types PDFType ObjectType = "PDF" PDFDocumentType ObjectType = "PDF_DOCUMENT" PDFPageType ObjectType = "PDF_PAGE" PDFInfoType ObjectType = "PDF_INFO" )
Object types
const CompiledFunctionType ObjectType = "COMPILED_FUNCTION"
CompiledFunctionType is the type for compiled functions
const WebViewType ObjectType = "WEBVIEW"
WebViewType is the object type for WebView.
type Once ¶ added in v0.4.25
type Once struct {
// contains filtered or unexported fields
}
Once wraps sync.Once for use in Xxlang
func (*Once) Type ¶ added in v0.4.25
func (o *Once) Type() ObjectType
Object interface implementation
type OrderedMap ¶ added in v0.5.7
type OrderedMap struct {
Pairs map[HashKey]int // HashKey -> index in orderSlice
// contains filtered or unexported fields
}
OrderedMap represents a map that preserves insertion order of key-value pairs. It supports O(1) lookup via a hash map and ordered iteration via a slice.
func AcquireOrderedMap ¶ added in v0.5.7
func AcquireOrderedMap() *OrderedMap
AcquireOrderedMap gets an OrderedMap from the pool
func NewOrderedMap ¶ added in v0.5.7
func NewOrderedMap() *OrderedMap
NewOrderedMap creates a new empty OrderedMap
func NewOrderedMapWithCapacity ¶ added in v0.5.7
func NewOrderedMapWithCapacity(capacity int) *OrderedMap
NewOrderedMapWithCapacity creates a new OrderedMap with pre-allocated capacity
func (*OrderedMap) Clone ¶ added in v0.5.7
func (om *OrderedMap) Clone() *OrderedMap
Clone creates a deep copy of the OrderedMap
func (*OrderedMap) Delete ¶ added in v0.5.7
func (om *OrderedMap) Delete(key Object) bool
Delete removes a key-value pair. Returns true if the key was found and removed.
func (*OrderedMap) Get ¶ added in v0.5.7
func (om *OrderedMap) Get(key Object) Object
Get retrieves a value by key. Returns NULL if key not found.
func (*OrderedMap) GetAt ¶ added in v0.5.7
func (om *OrderedMap) GetAt(index int) (Object, Object, error)
GetAt returns the key-value pair at a specific index. Returns nil, nil, error if index is out of bounds.
func (*OrderedMap) GetIndex ¶ added in v0.5.7
func (om *OrderedMap) GetIndex(key Object) int
GetIndex returns the index of a key (0-based). Returns -1 if key not found.
func (*OrderedMap) GetOrderedKeys ¶ added in v0.5.7
func (om *OrderedMap) GetOrderedKeys() []Object
GetOrderedKeys returns keys in insertion order
func (*OrderedMap) GetOrderedPairs ¶ added in v0.5.7
func (om *OrderedMap) GetOrderedPairs() []Object
GetOrderedPairs returns key-value pairs as array of [key, value] arrays
func (*OrderedMap) GetOrderedValues ¶ added in v0.5.7
func (om *OrderedMap) GetOrderedValues() []Object
GetOrderedValues returns values in insertion order
func (*OrderedMap) HasKey ¶ added in v0.5.7
func (om *OrderedMap) HasKey(key Object) bool
HasKey checks if a key exists
func (*OrderedMap) HashKey ¶ added in v0.5.7
func (om *OrderedMap) HashKey() HashKey
HashKey returns an empty HashKey (OrderedMaps are not hashable)
func (*OrderedMap) InsertAt ¶ added in v0.5.7
func (om *OrderedMap) InsertAt(key Object, value Object, index int) error
InsertAt inserts a key-value pair at a specific index. If the key already exists, it updates the value and moves it to the new position. Returns error if index is out of bounds.
func (*OrderedMap) Inspect ¶ added in v0.5.7
func (om *OrderedMap) Inspect() string
Inspect returns a string representation of the OrderedMap
func (*OrderedMap) Len ¶ added in v0.5.7
func (om *OrderedMap) Len() int
Len returns the number of key-value pairs
func (*OrderedMap) MoveAfter ¶ added in v0.5.7
func (om *OrderedMap) MoveAfter(key1, key2 Object) error
MoveAfter moves key1 to the position immediately after key2. Returns error if either key is not found.
func (*OrderedMap) MoveBefore ¶ added in v0.5.7
func (om *OrderedMap) MoveBefore(key1, key2 Object) error
MoveBefore moves key1 to the position immediately before key2. Returns error if either key is not found.
func (*OrderedMap) MoveToBack ¶ added in v0.5.7
func (om *OrderedMap) MoveToBack(key Object) error
MoveToBack moves a key to the back (last position). Returns error if key not found.
func (*OrderedMap) MoveToFront ¶ added in v0.5.7
func (om *OrderedMap) MoveToFront(key Object) error
MoveToFront moves a key to the front (position 0). Returns error if key not found.
func (*OrderedMap) Reverse ¶ added in v0.5.7
func (om *OrderedMap) Reverse()
Reverse reverses the order of all elements
func (*OrderedMap) Set ¶ added in v0.5.7
func (om *OrderedMap) Set(key Object, value Object)
Set adds or updates a key-value pair. If the key exists, it updates the value but preserves the position. If the key is new, it appends to the end.
func (*OrderedMap) SetAt ¶ added in v0.5.7
func (om *OrderedMap) SetAt(index int, value Object) error
SetAt updates the value at a specific index. Returns error if index is out of bounds.
func (*OrderedMap) SortByKey ¶ added in v0.5.7
func (om *OrderedMap) SortByKey()
SortByKey sorts the map by key (alphabetically by string representation)
func (*OrderedMap) Swap ¶ added in v0.5.7
func (om *OrderedMap) Swap(key1, key2 Object) error
Swap swaps the positions of two keys. Returns error if either key is not found.
func (*OrderedMap) ToBool ¶ added in v0.5.7
func (om *OrderedMap) ToBool() *Bool
ToBool returns TRUE if the map has elements, FALSE otherwise
func (*OrderedMap) ToMap ¶ added in v0.5.7
func (om *OrderedMap) ToMap() *Map
ToMap converts the OrderedMap to a regular Map
func (*OrderedMap) Type ¶ added in v0.5.7
func (om *OrderedMap) Type() ObjectType
Type returns the object type
func (*OrderedMap) TypeTag ¶ added in v0.5.7
func (om *OrderedMap) TypeTag() TypeTag
TypeTag returns the type tag for fast type checking
type OrderedMapPair ¶ added in v0.5.7
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 NewPDFFromBytes ¶ added in v0.5.7
NewPDFFromBytes creates a PDF object from byte data.
func NewPDFFromFile ¶ added in v0.5.7
NewPDFFromFile creates a PDF object from a file path.
func (*PDF) ExtractAllText ¶ added in v0.5.7
ExtractAllText extracts text from all pages.
func (*PDF) ExtractText ¶ added in v0.5.7
ExtractText extracts text from a specific page.
func (*PDF) RotatePage ¶ added in v0.5.7
RotatePage rotates a page by the specified angle.
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.
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) Type ¶ added in v0.5.7
func (i *PDFInfo) Type() ObjectType
Type returns the object type.
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
ExtractText extracts text from the page.
func (*PDFPage) Type ¶ added in v0.5.7
func (pg *PDFPage) Type() ObjectType
Type returns the object type.
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 PDFXRefEntry ¶ added in v0.5.7
type PDFXRefEntry struct {
Type int // 0 = free, 1 = in-use, 2 = compressed
Offset int64 // Byte offset (type 1) or object stream number (type 2)
Generation int64 // Generation number
Index int // Index within object stream (type 2 only)
}
PDFXRefEntry represents an entry in the cross-reference table.
type PDFXRefTable ¶ added in v0.5.7
type PDFXRefTable struct {
Entries map[int64]*PDFXRefEntry
}
PDFXRefTable represents the cross-reference table.
type PPTXAudio ¶ added in v0.5.7
type PPTXAudio struct {
// contains filtered or unexported fields
}
PPTXAudio represents an audio on a slide.
func (*PPTXAudio) GetPosition ¶ added in v0.5.7
func (a *PPTXAudio) GetPosition() PPTXPosition
GetPosition returns the position.
func (*PPTXAudio) SetPosition ¶ added in v0.5.7
SetPosition sets the position.
func (*PPTXAudio) Type ¶ added in v0.5.7
func (a *PPTXAudio) Type() ObjectType
Type implementations for PPTXAudio
type PPTXBulletStyle ¶ added in v0.5.7
type PPTXBulletStyle struct {
Type string // "bullet", "numbered", "none"
Char string // bullet character
StartAt int // starting number for numbered lists
Font PPTXFont
Color PPTXColor
}
PPTXBulletStyle represents bullet/numbering style.
type PPTXCellStyle ¶ added in v0.5.7
type PPTXCellStyle struct {
Fill *PPTXColor
BorderColor *PPTXColor
BorderWidth int64
Font PPTXFont
Alignment string
Vertical string
}
PPTXCellStyle represents table cell styling.
type PPTXChart ¶ added in v0.5.7
type PPTXChart struct {
// contains filtered or unexported fields
}
PPTXChart represents a chart on a slide.
func (*PPTXChart) GetKind ¶ added in v0.5.7
func (c *PPTXChart) GetKind() PPTXChartKind
GetKind returns the chart kind.
func (*PPTXChart) GetPosition ¶ added in v0.5.7
func (c *PPTXChart) GetPosition() PPTXPosition
GetPosition returns the position.
func (*PPTXChart) GetSeries ¶ added in v0.5.7
func (c *PPTXChart) GetSeries() []*PPTXChartSeries
GetSeries returns all series.
func (*PPTXChart) GetSeriesCount ¶ added in v0.5.7
GetSeriesCount returns the number of series.
func (*PPTXChart) SetPosition ¶ added in v0.5.7
SetPosition sets the position.
func (*PPTXChart) Type ¶ added in v0.5.7
func (c *PPTXChart) Type() ObjectType
Type implementations for PPTXChart
type PPTXChartData ¶ added in v0.5.7
type PPTXChartData struct {
// contains filtered or unexported fields
}
PPTXChartData represents chart data.
type PPTXChartKind ¶ added in v0.5.7
type PPTXChartKind string
PPTXChartKind defines chart types.
const ( PPTXChartBar PPTXChartKind = "bar" PPTXChartBarStacked PPTXChartKind = "barStacked" PPTXChartColumn PPTXChartKind = "column" PPTXChartLine PPTXChartKind = "line" PPTXChartPie PPTXChartKind = "pie" PPTXChartArea PPTXChartKind = "area" PPTXChartScatter PPTXChartKind = "scatter" PPTXChartRadar PPTXChartKind = "radar" PPTXChartCombo PPTXChartKind = "combo" )
type PPTXChartSeries ¶ added in v0.5.7
type PPTXChartSeries struct {
// contains filtered or unexported fields
}
PPTXChartSeries represents a data series in a chart.
func (*PPTXChartSeries) GetName ¶ added in v0.5.7
func (s *PPTXChartSeries) GetName() string
GetName returns the series name.
func (*PPTXChartSeries) GetValues ¶ added in v0.5.7
func (s *PPTXChartSeries) GetValues() []float64
GetValues returns the values.
func (*PPTXChartSeries) HashKey ¶ added in v0.5.7
func (s *PPTXChartSeries) HashKey() HashKey
func (*PPTXChartSeries) Inspect ¶ added in v0.5.7
func (s *PPTXChartSeries) Inspect() string
func (*PPTXChartSeries) SetName ¶ added in v0.5.7
func (s *PPTXChartSeries) SetName(name string)
SetName sets the series name.
func (*PPTXChartSeries) SetValues ¶ added in v0.5.7
func (s *PPTXChartSeries) SetValues(values []float64)
SetValues sets the values.
func (*PPTXChartSeries) ToBool ¶ added in v0.5.7
func (s *PPTXChartSeries) ToBool() *Bool
func (*PPTXChartSeries) Type ¶ added in v0.5.7
func (s *PPTXChartSeries) Type() ObjectType
Type implementations for PPTXChartSeries
func (*PPTXChartSeries) TypeTag ¶ added in v0.5.7
func (s *PPTXChartSeries) TypeTag() TypeTag
type PPTXChartSeriesData ¶ added in v0.5.7
PPTXChartSeriesData represents a data series input.
type PPTXChartStyle ¶ added in v0.5.7
type PPTXChartStyle struct {
// contains filtered or unexported fields
}
PPTXChartStyle represents chart styling.
type PPTXColor ¶ added in v0.5.7
type PPTXColor struct {
R, G, B uint8
}
PPTXColor represents RGB color.
type PPTXDocument ¶ added in v0.5.7
type PPTXDocument struct {
// contains filtered or unexported fields
}
PPTXDocument represents a PowerPoint presentation. A .pptx file is a ZIP archive containing XML files.
func NewPPTX ¶ added in v0.5.7
func NewPPTX() *PPTXDocument
NewPPTX creates a new empty presentation.
func OpenPPTX ¶ added in v0.5.7
func OpenPPTX(path string) (*PPTXDocument, error)
OpenPPTX opens an existing PPTX file from a file path.
func OpenPPTXFromBytes ¶ added in v0.5.7
func OpenPPTXFromBytes(data []byte) (*PPTXDocument, error)
OpenPPTXFromBytes opens a PPTX presentation from a byte slice.
func (*PPTXDocument) AddSlide ¶ added in v0.5.7
func (d *PPTXDocument) AddSlide() *PPTXSlide
AddSlide adds a new slide to the presentation.
func (*PPTXDocument) Close ¶ added in v0.5.7
func (d *PPTXDocument) Close() error
Close closes the document and releases resources.
func (*PPTXDocument) DeleteSlide ¶ added in v0.5.7
func (d *PPTXDocument) DeleteSlide(index int) bool
DeleteSlide deletes a slide by index (1-based).
func (*PPTXDocument) DuplicateSlide ¶ added in v0.5.7
func (d *PPTXDocument) DuplicateSlide(index int) *PPTXSlide
DuplicateSlide creates a copy of a slide.
func (*PPTXDocument) GetProperties ¶ added in v0.5.7
func (d *PPTXDocument) GetProperties() *PPTXProperties
GetProperties returns the document properties.
func (*PPTXDocument) GetSlide ¶ added in v0.5.7
func (d *PPTXDocument) GetSlide(index int) *PPTXSlide
GetSlide returns a slide by index (1-based).
func (*PPTXDocument) GetSlideCount ¶ added in v0.5.7
func (d *PPTXDocument) GetSlideCount() int
GetSlideCount returns the number of slides.
func (*PPTXDocument) GetSlides ¶ added in v0.5.7
func (d *PPTXDocument) GetSlides() []*PPTXSlide
GetSlides returns all slides.
func (*PPTXDocument) HashKey ¶ added in v0.5.7
func (d *PPTXDocument) HashKey() HashKey
func (*PPTXDocument) Inspect ¶ added in v0.5.7
func (d *PPTXDocument) Inspect() string
func (*PPTXDocument) MoveSlide ¶ added in v0.5.7
func (d *PPTXDocument) MoveSlide(from, to int) bool
MoveSlide moves a slide from one position to another.
func (*PPTXDocument) Save ¶ added in v0.5.7
func (d *PPTXDocument) Save(path string) error
Save saves the document to a file.
func (*PPTXDocument) SetProperties ¶ added in v0.5.7
func (d *PPTXDocument) SetProperties(props *PPTXProperties)
SetProperties sets the document properties.
func (*PPTXDocument) ToBool ¶ added in v0.5.7
func (d *PPTXDocument) ToBool() *Bool
func (*PPTXDocument) ToBytes ¶ added in v0.5.7
func (d *PPTXDocument) ToBytes() ([]byte, error)
ToBytes converts the document to a byte slice.
func (*PPTXDocument) Type ¶ added in v0.5.7
func (d *PPTXDocument) Type() ObjectType
func (*PPTXDocument) TypeTag ¶ added in v0.5.7
func (d *PPTXDocument) TypeTag() TypeTag
type PPTXFormatScheme ¶ added in v0.5.7
type PPTXFormatScheme struct {
// contains filtered or unexported fields
}
PPTXFormatScheme defines format scheme.
type PPTXGradient ¶ added in v0.5.7
type PPTXGradient struct {
// contains filtered or unexported fields
}
PPTXGradient represents gradient fill.
type PPTXImage ¶ added in v0.5.7
type PPTXImage struct {
// contains filtered or unexported fields
}
PPTXImage represents an image on a slide.
func (*PPTXImage) GetDataBase64 ¶ added in v0.5.7
GetDataBase64 returns the image data as base64.
func (*PPTXImage) GetPosition ¶ added in v0.5.7
func (i *PPTXImage) GetPosition() PPTXPosition
GetPosition returns the position.
func (*PPTXImage) SetPosition ¶ added in v0.5.7
SetPosition sets the position.
func (*PPTXImage) Type ¶ added in v0.5.7
func (i *PPTXImage) Type() ObjectType
Type implementations for PPTXImage
type PPTXParagraph ¶ added in v0.5.7
type PPTXParagraph struct {
// contains filtered or unexported fields
}
PPTXParagraph represents a paragraph within a text frame.
func (*PPTXParagraph) GetAlignment ¶ added in v0.5.7
func (p *PPTXParagraph) GetAlignment() string
GetAlignment returns the alignment.
func (*PPTXParagraph) GetRuns ¶ added in v0.5.7
func (p *PPTXParagraph) GetRuns() []*PPTXTextRun
GetRuns returns all text runs.
func (*PPTXParagraph) GetText ¶ added in v0.5.7
func (p *PPTXParagraph) GetText() string
GetText returns the text content.
func (*PPTXParagraph) HashKey ¶ added in v0.5.7
func (p *PPTXParagraph) HashKey() HashKey
func (*PPTXParagraph) Inspect ¶ added in v0.5.7
func (p *PPTXParagraph) Inspect() string
func (*PPTXParagraph) SetAlignment ¶ added in v0.5.7
func (p *PPTXParagraph) SetAlignment(align string)
SetAlignment sets the alignment.
func (*PPTXParagraph) ToBool ¶ added in v0.5.7
func (p *PPTXParagraph) ToBool() *Bool
func (*PPTXParagraph) Type ¶ added in v0.5.7
func (p *PPTXParagraph) Type() ObjectType
Type implementations for PPTXParagraph
func (*PPTXParagraph) TypeTag ¶ added in v0.5.7
func (p *PPTXParagraph) TypeTag() TypeTag
type PPTXPosition ¶ added in v0.5.7
PPTXPosition represents element position in EMUs (English Metric Units).
type PPTXProperties ¶ added in v0.5.7
type PPTXProperties struct {
Title string
Subject string
Author string
Keywords string
Description string
Created string
Modified string
LastModBy string
Revision int
Category string
Company string
}
PPTXProperties holds document metadata.
type PPTXShadow ¶ added in v0.5.7
PPTXShadow represents shadow effect.
type PPTXShape ¶ added in v0.5.7
type PPTXShape struct {
// contains filtered or unexported fields
}
PPTXShape represents a shape on a slide.
func (*PPTXShape) AddTextFrame ¶ added in v0.5.7
func (s *PPTXShape) AddTextFrame(text string) *PPTXTextFrame
AddTextFrame adds a text frame to the shape.
func (*PPTXShape) GetKind ¶ added in v0.5.7
func (s *PPTXShape) GetKind() PPTXShapeKind
GetKind returns the shape kind.
func (*PPTXShape) GetPosition ¶ added in v0.5.7
func (s *PPTXShape) GetPosition() PPTXPosition
GetPosition returns the position.
func (*PPTXShape) GetTextFrame ¶ added in v0.5.7
func (s *PPTXShape) GetTextFrame() *PPTXTextFrame
GetTextFrame returns the text frame.
func (*PPTXShape) SetPosition ¶ added in v0.5.7
SetPosition sets the position.
func (*PPTXShape) Type ¶ added in v0.5.7
func (s *PPTXShape) Type() ObjectType
Type implementations for PPTXShape
type PPTXShapeKind ¶ added in v0.5.7
type PPTXShapeKind string
PPTXShapeKind defines shape types.
const ( PPTXShapeRectangle PPTXShapeKind = "rect" PPTXShapeOval PPTXShapeKind = "ellipse" PPTXShapeRoundRect PPTXShapeKind = "roundRect" PPTXShapeTriangle PPTXShapeKind = "triangle" PPTXShapeLine PPTXShapeKind = "line" PPTXShapeArrow PPTXShapeKind = "arrow" PPTXShapeTextBox PPTXShapeKind = "textBox" PPTXShapePicture PPTXShapeKind = "picture" )
type PPTXShapeStyle ¶ added in v0.5.7
type PPTXShapeStyle struct {
Fill *PPTXColor
FillTransparency float64
BorderColor *PPTXColor
BorderWidth int64
BorderStyle string // "solid", "dashed", "none"
Shadow *PPTXShadow
}
PPTXShapeStyle represents shape styling.
type PPTXSlide ¶ added in v0.5.7
type PPTXSlide struct {
// contains filtered or unexported fields
}
PPTXSlide represents a single slide in a presentation.
func (*PPTXSlide) AddChart ¶ added in v0.5.7
func (s *PPTXSlide) AddChart(chartKind PPTXChartKind, data PPTXChartData, options map[string]interface{}) *PPTXChart
AddChart adds a chart to the slide.
func (*PPTXSlide) AddImageFromBytes ¶ added in v0.5.7
func (s *PPTXSlide) AddImageFromBytes(data []byte, format string, options map[string]interface{}) *PPTXImage
AddImageFromBytes adds an image to the slide from byte data.
func (*PPTXSlide) AddShape ¶ added in v0.5.7
func (s *PPTXSlide) AddShape(shapeKind PPTXShapeKind, options map[string]interface{}) *PPTXShape
AddShape adds a shape to the slide.
func (*PPTXSlide) AddText ¶ added in v0.5.7
func (s *PPTXSlide) AddText(text string, options map[string]interface{}) *PPTXTextFrame
AddText adds a text frame to the slide.
func (*PPTXSlide) GetAllText ¶ added in v0.5.7
GetAllText returns all text content combined.
func (*PPTXSlide) GetTexts ¶ added in v0.5.7
func (s *PPTXSlide) GetTexts() []*PPTXTextFrame
GetTexts returns all text frames on the slide.
func (*PPTXSlide) Type ¶ added in v0.5.7
func (s *PPTXSlide) Type() ObjectType
Type implementations for PPTXSlide
type PPTXSlideBackground ¶ added in v0.5.7
type PPTXSlideBackground struct {
// contains filtered or unexported fields
}
PPTXSlideBackground represents slide background.
type PPTXSlideLayout ¶ added in v0.5.7
type PPTXSlideLayout struct {
// contains filtered or unexported fields
}
PPTXSlideLayout represents a slide layout template.
func (*PPTXSlideLayout) HashKey ¶ added in v0.5.7
func (l *PPTXSlideLayout) HashKey() HashKey
func (*PPTXSlideLayout) Inspect ¶ added in v0.5.7
func (l *PPTXSlideLayout) Inspect() string
func (*PPTXSlideLayout) ToBool ¶ added in v0.5.7
func (l *PPTXSlideLayout) ToBool() *Bool
func (*PPTXSlideLayout) Type ¶ added in v0.5.7
func (l *PPTXSlideLayout) Type() ObjectType
Type implementations for PPTXSlideLayout
func (*PPTXSlideLayout) TypeTag ¶ added in v0.5.7
func (l *PPTXSlideLayout) TypeTag() TypeTag
type PPTXSlideMaster ¶ added in v0.5.7
type PPTXSlideMaster struct {
// contains filtered or unexported fields
}
PPTXSlideMaster represents a slide master.
func (*PPTXSlideMaster) HashKey ¶ added in v0.5.7
func (m *PPTXSlideMaster) HashKey() HashKey
func (*PPTXSlideMaster) Inspect ¶ added in v0.5.7
func (m *PPTXSlideMaster) Inspect() string
func (*PPTXSlideMaster) ToBool ¶ added in v0.5.7
func (m *PPTXSlideMaster) ToBool() *Bool
func (*PPTXSlideMaster) Type ¶ added in v0.5.7
func (m *PPTXSlideMaster) Type() ObjectType
Type implementations for PPTXSlideMaster
func (*PPTXSlideMaster) TypeTag ¶ added in v0.5.7
func (m *PPTXSlideMaster) TypeTag() TypeTag
type PPTXTable ¶ added in v0.5.7
type PPTXTable struct {
// contains filtered or unexported fields
}
PPTXTable represents a table on a slide.
func (*PPTXTable) GetCell ¶ added in v0.5.7
func (t *PPTXTable) GetCell(row, col int) *PPTXTableCell
GetCell returns a cell by row and column (1-based).
func (*PPTXTable) GetColCount ¶ added in v0.5.7
GetColCount returns the number of columns.
func (*PPTXTable) GetPosition ¶ added in v0.5.7
func (t *PPTXTable) GetPosition() PPTXPosition
GetPosition returns the position.
func (*PPTXTable) GetRowCount ¶ added in v0.5.7
GetRowCount returns the number of rows.
func (*PPTXTable) SetPosition ¶ added in v0.5.7
SetPosition sets the position.
func (*PPTXTable) Type ¶ added in v0.5.7
func (t *PPTXTable) Type() ObjectType
Type implementations for PPTXTable
type PPTXTableCell ¶ added in v0.5.7
type PPTXTableCell struct {
// contains filtered or unexported fields
}
PPTXTableCell represents a table cell.
func (*PPTXTableCell) HashKey ¶ added in v0.5.7
func (c *PPTXTableCell) HashKey() HashKey
func (*PPTXTableCell) Inspect ¶ added in v0.5.7
func (c *PPTXTableCell) Inspect() string
func (*PPTXTableCell) ToBool ¶ added in v0.5.7
func (c *PPTXTableCell) ToBool() *Bool
func (*PPTXTableCell) Type ¶ added in v0.5.7
func (c *PPTXTableCell) Type() ObjectType
Type implementations for PPTXTableCell
func (*PPTXTableCell) TypeTag ¶ added in v0.5.7
func (c *PPTXTableCell) TypeTag() TypeTag
type PPTXTableStyle ¶ added in v0.5.7
type PPTXTableStyle struct {
HeaderRow PPTXCellStyle
TotalRow PPTXCellStyle
FirstCol PPTXCellStyle
LastCol PPTXCellStyle
BandRow bool
BandCol bool
}
PPTXTableStyle represents table styling.
type PPTXTextFrame ¶ added in v0.5.7
type PPTXTextFrame struct {
// contains filtered or unexported fields
}
PPTXTextFrame represents a text box on a slide.
func (*PPTXTextFrame) GetParagraphs ¶ added in v0.5.7
func (tf *PPTXTextFrame) GetParagraphs() []*PPTXParagraph
GetParagraphs returns all paragraphs.
func (*PPTXTextFrame) GetPosition ¶ added in v0.5.7
func (tf *PPTXTextFrame) GetPosition() PPTXPosition
GetPosition returns the position.
func (*PPTXTextFrame) GetSize ¶ added in v0.5.7
func (tf *PPTXTextFrame) GetSize() PPTXSize
GetSize returns the size.
func (*PPTXTextFrame) GetText ¶ added in v0.5.7
func (tf *PPTXTextFrame) GetText() string
GetText returns the text content.
func (*PPTXTextFrame) HashKey ¶ added in v0.5.7
func (tf *PPTXTextFrame) HashKey() HashKey
func (*PPTXTextFrame) Inspect ¶ added in v0.5.7
func (tf *PPTXTextFrame) Inspect() string
func (*PPTXTextFrame) SetPosition ¶ added in v0.5.7
func (tf *PPTXTextFrame) SetPosition(x, y int64)
SetPosition sets the position.
func (*PPTXTextFrame) SetSize ¶ added in v0.5.7
func (tf *PPTXTextFrame) SetSize(width, height int64)
SetSize sets the size.
func (*PPTXTextFrame) SetText ¶ added in v0.5.7
func (tf *PPTXTextFrame) SetText(text string)
SetText sets the text content.
func (*PPTXTextFrame) ToBool ¶ added in v0.5.7
func (tf *PPTXTextFrame) ToBool() *Bool
func (*PPTXTextFrame) Type ¶ added in v0.5.7
func (tf *PPTXTextFrame) Type() ObjectType
Type implementations for PPTXTextFrame
func (*PPTXTextFrame) TypeTag ¶ added in v0.5.7
func (tf *PPTXTextFrame) TypeTag() TypeTag
type PPTXTextRun ¶ added in v0.5.7
type PPTXTextRun struct {
// contains filtered or unexported fields
}
PPTXTextRun represents a text run with uniform formatting.
func (*PPTXTextRun) GetColor ¶ added in v0.5.7
func (r *PPTXTextRun) GetColor() string
GetColor returns the color as hex string.
func (*PPTXTextRun) GetFontName ¶ added in v0.5.7
func (r *PPTXTextRun) GetFontName() string
GetFontName returns the font name.
func (*PPTXTextRun) GetFontSize ¶ added in v0.5.7
func (r *PPTXTextRun) GetFontSize() int
GetFontSize returns the font size.
func (*PPTXTextRun) GetText ¶ added in v0.5.7
func (r *PPTXTextRun) GetText() string
GetText returns the text content.
func (*PPTXTextRun) HashKey ¶ added in v0.5.7
func (r *PPTXTextRun) HashKey() HashKey
func (*PPTXTextRun) Inspect ¶ added in v0.5.7
func (r *PPTXTextRun) Inspect() string
func (*PPTXTextRun) IsBold ¶ added in v0.5.7
func (r *PPTXTextRun) IsBold() bool
IsBold returns whether the text is bold.
func (*PPTXTextRun) IsItalic ¶ added in v0.5.7
func (r *PPTXTextRun) IsItalic() bool
IsItalic returns whether the text is italic.
func (*PPTXTextRun) SetBold ¶ added in v0.5.7
func (r *PPTXTextRun) SetBold(bold bool)
SetBold sets the bold flag.
func (*PPTXTextRun) SetColor ¶ added in v0.5.7
func (r *PPTXTextRun) SetColor(hex string)
SetColor sets the color from hex string.
func (*PPTXTextRun) SetFontName ¶ added in v0.5.7
func (r *PPTXTextRun) SetFontName(name string)
SetFontName sets the font name.
func (*PPTXTextRun) SetFontSize ¶ added in v0.5.7
func (r *PPTXTextRun) SetFontSize(size int)
SetFontSize sets the font size.
func (*PPTXTextRun) SetItalic ¶ added in v0.5.7
func (r *PPTXTextRun) SetItalic(italic bool)
SetItalic sets the italic flag.
func (*PPTXTextRun) SetText ¶ added in v0.5.7
func (r *PPTXTextRun) SetText(text string)
SetText sets the text content.
func (*PPTXTextRun) ToBool ¶ added in v0.5.7
func (r *PPTXTextRun) ToBool() *Bool
func (*PPTXTextRun) Type ¶ added in v0.5.7
func (r *PPTXTextRun) Type() ObjectType
Type implementations for PPTXTextRun
func (*PPTXTextRun) TypeTag ¶ added in v0.5.7
func (r *PPTXTextRun) TypeTag() TypeTag
type PPTXTheme ¶ added in v0.5.7
type PPTXTheme struct {
// contains filtered or unexported fields
}
PPTXTheme represents a presentation theme.
func (*PPTXTheme) Type ¶ added in v0.5.7
func (t *PPTXTheme) Type() ObjectType
Type implementations for PPTXTheme
type PPTXThemeColors ¶ added in v0.5.7
type PPTXThemeColors struct {
// contains filtered or unexported fields
}
PPTXThemeColors defines theme color scheme.
type PPTXThemeFonts ¶ added in v0.5.7
type PPTXThemeFonts struct {
// contains filtered or unexported fields
}
PPTXThemeFonts defines theme fonts.
type PPTXVideo ¶ added in v0.5.7
type PPTXVideo struct {
// contains filtered or unexported fields
}
PPTXVideo represents a video on a slide.
func (*PPTXVideo) GetPosition ¶ added in v0.5.7
func (v *PPTXVideo) GetPosition() PPTXPosition
GetPosition returns the position.
func (*PPTXVideo) SetPosition ¶ added in v0.5.7
SetPosition sets the position.
func (*PPTXVideo) Type ¶ added in v0.5.7
func (v *PPTXVideo) Type() ObjectType
Type implementations for PPTXVideo
type Queue ¶ added in v0.5.2
type Queue struct {
// contains filtered or unexported fields
}
Queue represents a FIFO queue (not thread-safe).
func NewQueueFrom ¶ added in v0.5.2
NewQueueFrom creates a new queue from an array.
func NewQueueWithCapacity ¶ added in v0.5.2
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) Peek ¶ added in v0.5.2
Peek returns the front element without removing it. Returns NULL if the queue is empty.
func (*Queue) PeekBack ¶ added in v0.5.2
PeekBack returns the back element without removing it. Returns NULL if the queue is empty.
func (*Queue) Pop ¶ added in v0.5.2
Pop removes and returns the front element of the queue. Returns NULL if the queue is empty.
func (*Queue) Type ¶ added in v0.5.2
func (q *Queue) Type() ObjectType
Type returns the object type.
type RWMutex ¶ added in v0.4.25
type RWMutex struct {
// contains filtered or unexported fields
}
RWMutex wraps sync.RWMutex for use in Xxlang
func (*RWMutex) RUnlock ¶ added in v0.4.25
func (m *RWMutex) RUnlock()
RUnlock releases the read lock
func (*RWMutex) TryLock ¶ added in v0.4.25
TryLock attempts to acquire the write lock without blocking
func (*RWMutex) TryRLock ¶ added in v0.4.25
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
type Reader ¶ added in v0.4.25
Reader wraps an io.Reader for streaming read operations. It implements io.ReadCloser interface.
func (*Reader) Read ¶ added in v0.4.25
Read reads up to n bytes from the reader and returns as byte array.
func (*Reader) ReadAllBytes ¶ added in v0.4.25
ReadAllBytes reads all remaining content and returns as byte array.
func (*Reader) ReadAllStr ¶ added in v0.4.25
ReadAll reads all remaining content and returns as string.
func (*Reader) ReadLine ¶ added in v0.4.25
ReadLine reads a single line from the reader. Returns null on EOF, or error on failure.
func (*Reader) Type ¶ added in v0.4.25
func (r *Reader) Type() ObjectType
Type returns the object type.
type Return ¶
type Return struct {
Value Object
}
Return represents a return value (used internally)
func (*Return) Type ¶
func (r *Return) Type() ObjectType
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
NewScanner creates a new Scanner from an io.Reader. If reader is nil, it defaults to os.Stdin.
func (*Scanner) Type ¶ added in v0.4.25
func (s *Scanner) Type() ObjectType
Type returns the object type.
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 NewSetFrom ¶ added in v0.5.2
NewSetFrom creates a new set from an array.
func NewSetWithCapacity ¶ added in v0.5.2
NewSetWithCapacity creates a new set with the specified initial capacity.
func (*Set) Add ¶ added in v0.5.2
Add adds an element to the set. Returns true if added, false if already present.
func (*Set) Difference ¶ added in v0.5.2
Difference returns a new set containing elements in s but not in other.
func (*Set) Intersect ¶ added in v0.5.2
Intersect returns a new set containing elements present in both sets.
func (*Set) IsSuperset ¶ added in v0.5.2
IsSuperset returns true if s is a superset of other.
func (*Set) Remove ¶ added in v0.5.2
Remove removes an element from the set. Returns true if removed, false if not found.
func (*Set) SymmetricDifference ¶ added in v0.5.2
SymmetricDifference returns a new set containing elements in either set but not both.
func (*Set) ToSortedArray ¶ added in v0.5.2
ToSortedArray returns all elements as an array, sorted by Inspect() representation.
type Sheet ¶ added in v0.5.2
type Sheet struct {
Name string
Cells map[string]*Cell // key: "A1", "B2", etc.
Merges []MergeRange
RowCount int
ColCount int
Images []ImageInfo
}
Sheet represents a worksheet.
type String ¶
type String struct {
Value string
}
String represents a string value
func GetBufferedString ¶ added in v0.4.23
GetBufferedString gets a temporary String using the global buffer
func InternBatch ¶
InternBatch pre-interns a batch of strings
func InternString ¶
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
NewString creates a new String object, using cached values for common strings
func NewStringSlice ¶ added in v0.4.23
NewStringSlice creates multiple String objects efficiently This is optimized for batch operations
type StringBuilder ¶ added in v0.4.19
type StringBuilder struct {
// contains filtered or unexported fields
}
StringBuilder is a mutable string builder for efficient string concatenation. Not thread-safe - use external synchronization if needed.
func NewStringBuilder ¶ added in v0.4.19
func NewStringBuilder() *StringBuilder
NewStringBuilder creates a new StringBuilder instance.
func (*StringBuilder) Cap ¶ added in v0.4.19
func (sb *StringBuilder) Cap() int
Cap returns the current capacity of the builder's internal buffer.
func (*StringBuilder) Clear ¶ added in v0.4.19
func (sb *StringBuilder) Clear()
Clear resets the builder, removing all content.
func (*StringBuilder) GetIOWriter ¶ added in v0.4.25
func (sb *StringBuilder) GetIOWriter() *stringBuilderWriter
GetIOWriter returns the builder as an io.Writer interface. This allows the StringBuilder to be used with Writer objects.
func (*StringBuilder) Grow ¶ added in v0.4.19
func (sb *StringBuilder) Grow(n int)
Grow grows the builder's capacity to hold at least n more bytes.
func (*StringBuilder) HashKey ¶ added in v0.4.19
func (sb *StringBuilder) HashKey() HashKey
HashKey returns a hash key for the StringBuilder.
func (*StringBuilder) Inspect ¶ added in v0.4.19
func (sb *StringBuilder) Inspect() string
Inspect returns a string representation.
func (*StringBuilder) Len ¶ added in v0.4.19
func (sb *StringBuilder) Len() int
Len returns the current length of the accumulated string.
func (*StringBuilder) Reset ¶ added in v0.4.19
func (sb *StringBuilder) Reset()
Reset is an alias for Clear.
func (*StringBuilder) String ¶ added in v0.4.19
func (sb *StringBuilder) String() string
String returns the accumulated string.
func (*StringBuilder) ToBool ¶ added in v0.4.19
func (sb *StringBuilder) ToBool() *Bool
ToBool returns true (StringBuilder is always truthy).
func (*StringBuilder) Type ¶ added in v0.4.19
func (sb *StringBuilder) Type() ObjectType
Type returns the object type.
func (*StringBuilder) TypeTag ¶ added in v0.4.19
func (sb *StringBuilder) TypeTag() TypeTag
TypeTag returns the fast type tag.
func (*StringBuilder) Write ¶ added in v0.4.19
func (sb *StringBuilder) Write(s string) int
Write appends a string to the builder.
func (*StringBuilder) WriteLine ¶ added in v0.4.19
func (sb *StringBuilder) WriteLine(s string) int
WriteLine appends a string followed by a newline to the builder.
type StringPoolStats ¶ added in v0.4.23
type StringPoolStats struct {
// CacheHits is the number of times a cached string was returned
CacheHits int64
// InternHits is the number of times an interned string was returned
InternHits int64
// PoolHits is the number of times a pooled string was reused
PoolHits int64
// Created is the number of new strings allocated by the pool
Created int64
// Released is the number of strings returned to the pool
Released int64
// Interned is the number of strings currently in the intern cache
Interned int64
}
StringPoolStats tracks statistics about string pool usage
func GetStringPoolStats ¶ added in v0.4.23
func GetStringPoolStats() StringPoolStats
GetStringPoolStats returns current statistics about string pool usage
type Tube ¶ added in v0.4.25
type Tube struct {
// contains filtered or unexported fields
}
Tube represents a communication tube for concurrent message passing It wraps a Go channel for efficient implementation
func NewTube ¶ added in v0.4.25
func NewTube(elemType ObjectType, buffer int) *Tube
NewTube creates a new tube with optional type constraint and buffer size
func (*Tube) 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
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) IsClosedMethod ¶ added in v0.4.25
IsClosedMethod is the method called as tube.isClosed()
func (*Tube) Receive ¶ added in v0.4.25
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
ReceiveMethod is the method called as tube.receive() Returns [value, ok] array
func (*Tube) ReflectValue ¶ added in v0.4.25
ReflectValue returns the underlying reflect.Value for use with reflect.Select
func (*Tube) Send ¶ added in v0.4.25
Send sends a value to the tube (blocking) Returns false if the tube is closed
func (*Tube) SendMethod ¶ added in v0.4.25
SendMethod is the method called as tube.send(value)
func (*Tube) SendWithTimeout ¶ added in v0.4.25
SendWithTimeout sends a value with timeout (in milliseconds) Returns (sent, ok) where ok is false if timeout or closed
func (*Tube) TryReceive ¶ added in v0.4.25
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
TryReceiveMethod is the method called as tube.tryReceive() Returns [value, received, open] array
type TypeTag ¶
type TypeTag uint8
TypeTag is a fast integer type identifier for hot path checks
const ( TagNull TypeTag = iota TagInt TagFloat TagString TagChars TagBool TagArray TagMap TagFunction TagBuiltin TagBytes TagClass TagInstance TagError TagReturn TagClosure TagModule TagStringBuilder TagBytesBuffer TagBigInt TagBigFloat TagHttpReq TagHttpResp TagHttpMux TagWebSocket TagTube TagMutex TagRWMutex TagWaitGroup TagOnce TagCond TagAtomicInt TagGoroutine TagContext TagFileUpload TagFileUploadResult TagFile TagFileInfo TagReader TagWriter TagScanner TagDB TagDBTx TagDBRows TagDBStmt TagOrderedMap TagQueue TagSet TagXLSX TagXMLDocument TagXMLNode TagDocxDocument TagDocxParagraph TagDocxRun TagDocxTable TagDocxTableRow TagDocxTableCell TagDocxImage TagDocxSection TagDocxHeader TagDocxStyle TagDocxHyperlink TagDocxBookmark TagDocxTOC TagDocxTextBox TagDocxShape TagDocxChart TagDocxComment TagDocxRevision TagDocxFootnote TagDocxEndnote // PPTX tags TagPPTXDocument TagPPTXSlide TagPPTXTextFrame TagPPTXParagraph TagPPTXTextRun TagPPTXShape TagPPTXTable TagPPTXTableCell TagPPTXChart TagPPTXChartSeries TagPPTXImage TagPPTXVideo TagPPTXAudio TagPPTXSlideLayout TagPPTXSlideMaster TagPPTXTheme // PDF tags TagPDF TagPDFDocument TagPDFPage TagPDFInfo TagUnknown )
Type tags for fast type checking (must match ObjectType order)
const TagCompiledFunction TypeTag = TagClosure // Use same tag as Closure
TagCompiledFunction is the type tag for compiled functions
const TagWebView TypeTag = 101 // Continue from existing tags
TagWebView is the type tag for WebView objects.
type WaitGroup ¶ added in v0.4.25
type WaitGroup struct {
// contains filtered or unexported fields
}
WaitGroup wraps sync.WaitGroup for use in Xxlang
func NewWaitGroup ¶ added in v0.4.25
func NewWaitGroup() *WaitGroup
NewWaitGroup creates a new WaitGroup
func (*WaitGroup) Done ¶ added in v0.4.25
func (w *WaitGroup) Done()
Done decrements the WaitGroup counter
func (*WaitGroup) Type ¶ added in v0.4.25
func (w *WaitGroup) Type() ObjectType
Object interface implementation
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) HashKey ¶ added in v0.4.25
HashKey returns a hash key for the WebSocket. WebSockets are not hashable in a meaningful way.
func (*WebSocket) Inspect ¶ added in v0.4.25
Inspect returns a string representation of the WebSocket.
func (*WebSocket) ReadMessage ¶ added in v0.4.25
ReadMessage reads a message from the WebSocket connection. Returns an array: [messageType, data]
func (*WebSocket) SendBinaryMessage ¶ added in v0.4.25
SendBinaryMessage sends a binary message over the WebSocket.
func (*WebSocket) SendCloseMessage ¶ added in v0.4.25
SendCloseMessage sends a close message over the WebSocket.
func (*WebSocket) SendTextMessage ¶ added in v0.4.25
SendTextMessage sends a text message over the WebSocket.
func (*WebSocket) ToBool ¶ added in v0.4.25
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.
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
AddCallback adds a callback function.
func (*WebView) GetCallback ¶ added in v0.4.34
GetCallback gets a callback function.
func (*WebView) Type ¶ added in v0.4.34
func (w *WebView) Type() ObjectType
Type returns the object type.
type Writer ¶ added in v0.4.25
Writer wraps an io.Writer for streaming write operations.
func (*Writer) Type ¶ added in v0.4.25
func (w *Writer) Type() ObjectType
Type returns the object type.
func (*Writer) WriteBytes ¶ added in v0.4.25
WriteBytes writes a byte array (array of integers) to the writer.
type XLSX ¶ added in v0.5.2
type XLSX struct {
// contains filtered or unexported fields
}
XLSX represents an Excel workbook.
func (*XLSX) DeleteSheet ¶ added in v0.5.2
DeleteSheet deletes a sheet.
func (*XLSX) ExtractImage ¶ added in v0.5.2
ExtractImage extracts an image to a file.
func (*XLSX) GetCellByIndex ¶ added in v0.5.2
GetCellByIndex returns a cell value by row/col indices (1-based).
func (*XLSX) GetColCount ¶ added in v0.5.2
GetColCount returns the number of columns in a sheet.
func (*XLSX) GetImageData ¶ added in v0.5.2
GetImageData returns image data as base64.
func (*XLSX) GetRowCount ¶ added in v0.5.2
GetRowCount returns the number of rows in a sheet.
func (*XLSX) GetSheetByIndex ¶ added in v0.5.3
GetSheetByIndex returns a sheet by index (1-based).
func (*XLSX) GetSheetCount ¶ added in v0.5.3
GetSheetCount returns the number of sheets.
func (*XLSX) GetSheetList ¶ added in v0.5.2
GetSheetList returns the list of sheet names.
func (*XLSX) GetSheetName ¶ added in v0.5.3
GetSheetName returns the sheet name by index (1-based).
func (*XLSX) SetCellByIndex ¶ added in v0.5.2
SetCellByIndex sets a cell value by row/col indices (1-based).
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
NewXMLNode creates a new XML node.
func (*XMLNode) ChildCount ¶ added in v0.5.4
ChildCount returns the number of children.
func (*XMLNode) RemoveChild ¶ added in v0.5.4
RemoveChild removes a child node by index.
func (*XMLNode) ToIndented ¶ added in v0.5.4
ToIndented converts the node to indented XML string.
func (*XMLNode) Type ¶ added in v0.5.4
func (n *XMLNode) Type() ObjectType
Type returns the object type.
Source Files
¶
- array.go
- bigfloat.go
- bigint.go
- builtin.go
- builtin_crypto.go
- builtin_db.go
- builtin_file_upload.go
- builtin_http.go
- builtin_system.go
- builtin_system_unix.go
- builtin_testing.go
- bytes.go
- bytes_buffer.go
- chars.go
- class.go
- context.go
- db.go
- file.go
- file_lock_unix.go
- file_upload.go
- float.go
- function.go
- http.go
- int.go
- jsonutil.go
- map.go
- methods.go
- methods_pptx.go
- module.go
- object.go
- orderedmap.go
- pdf.go
- pptx.go
- queue.go
- reader_writer.go
- scanner.go
- set.go
- string.go
- stringbuilder.go
- sync.go
- tube.go
- webview.go
- xlsx.go
- xml_obj.go