Advanced features
Last updated
Last updated
When using Gentee in other projects, it may be necessary to expand the standard library. The Customize function allows you to add any number of go-functions to the standard library and use them in scripts. It should be noted that in this case the scripts will not be compiled by the original compiler, since there will be no added functions there. The Customize function must be called before calling other functions from the gentee package.
To expand the standard library, you should specify an array of functions in the parameter of the Custom type. Each function is described by the structure EmbedItem, in which a prototype in the Gentee language and the function itself are specified. The function may return a value of the error type and have a variable number of parameters.
Parameters and return value of go-functions must have types in accordance with this table. When using core types, you must import github.com/gentee/gentee/core.
Gentee type
Golang type
int
int64
bool
int64
char
int64
thread
int64
float
float64
str
string
arr
*core.Array
buf
*core.Buffer
map
*core.Map
set
*core.Set
struct type
*core.Struct
obj
*core.Obj