Embedthis Ejscript 0.9.8
Home > Programmers Reference > Native APIs > Ejscript

See Also

Quick Nav

Escript Native API

Components

Ejs Ejsript Interperter Management.
EjsArray Array class.
EjsBlock Block class.
EjsBoolean Boolean class.
EjsByteArray ByteArray class.
EjsDate Date class.
EjsError Error classes.
EjsFile File class.
EjsFileSystem FileSystem class.
EjsFunction Function class.
EjsGlobal EjsGlobal cass.
EjsHttp Http Class.
EjsIterator Iterator Class.
EjsName Qualified name structure.
EjsNamespace Namespace Class.
EjsNull Null Class.
EjsNumber Number class.
EjsObject Object Type.
EjsPath Path class.
EjsRegExp RegExp Class.
EjsString String Class.
EjsTimer Timer Class.
EjsType Type class.
EjsVar Foundation Variable Interface.
EjsVm Virtual Machine Execution Frame.
EjsVoid Void class.

Functions

intejsCopyToByteArray(Ejs *ejs, EjsByteArray *ap, int offset, char *data, int length)
 Copy data into a byte array.
Ejs*ejsCreate(MprCtx ctx, struct Ejs *master, cchar *searchPath, int flags)
 Create an ejs interpreter.
EjsArray*ejsCreateArray(Ejs *ejs, int size)
 Create an array.
EjsString*ejsCreateBareString(Ejs *ejs, int len)
 Create an empty string object.
EjsBoolean*ejsCreateBoolean(Ejs *ejs, int value)
 Create a boolean.
EjsByteArray*ejsCreateByteArray(Ejs *ejs, int size)
 Create a byte array.
EjsDate*ejsCreateDate(Ejs *ejs, MprTime value)
 Create a new date instance.
EjsFile*ejsCreateFile(Ejs *ejs, cchar *filename)
 Create a File object.
EjsFileSystem*ejsCreateFileSystem(Ejs *ejs, cchar *path)
 Create a FileSystem object.
EjsFunction*ejsCreateFunction(Ejs *ejs, const uchar *code, int codeLen, int numArgs, int numExceptions, EjsType *returnType, int attributes, struct EjsConst *constants, EjsBlock *scope, int lang)
 Create a function object.
EjsHttp*ejsCreateHttp(Ejs *ejs)
 Create a new Http object.
EjsVar*ejsCreateInstance(Ejs *ejs, struct EjsType *type, int argc, EjsVar **argv)
 Create a new variable instance.
EjsIterator*ejsCreateIterator(Ejs *ejs, EjsVar *target, EjsNativeFunction next, bool deep, EjsArray *namespaces)
 Create an iterator object.
EjsNamespace*ejsCreateNamespace(Ejs *ejs, cchar *name, cchar *uri)
 Create a namespace object.
EjsNumber*ejsCreateNumber(Ejs *ejs, MprNumber value)
 Create a number object.
EjsObject*ejsCreateObject(Ejs *ejs, struct EjsType *type, int size)
 Create an object instance of the specified type.
EjsObject*ejsCreateObjectEx(Ejs *ejs, struct EjsType *type, int size, bool dynamic)
 Create an object instance of the specified type.
EjsPath*ejsCreatePath(Ejs *ejs, cchar *path)
 Create a Path object.
EjsRegExp*ejsCreateRegExp(Ejs *ejs, cchar *pattern)
 Create a new regular expression object.
EjsService*ejsCreateService(MprCtx ctx)
 Open the Ejscript service.
EjsObject*ejsCreateSimpleObject(Ejs *ejs)
 Create a simple object.
EjsString*ejsCreateString(Ejs *ejs, cchar *value)
 Create a string object.
EjsString*ejsCreateStringAndFree(Ejs *ejs, char *value)
 Create a string object and free the argument.
EjsString*ejsCreateStringWithLength(Ejs *ejs, cchar *value, int len)
 Create a string and reserve extra room.
EjsType*ejsCreateType(Ejs *ejs, EjsName *name, struct EjsModule *up, EjsType *baseType, int size, int slotNum, int numTypeProp, int numInstanceProp, int attributes, void *data)
 Create a new type object.
EjsVar*ejsCreateVar(Ejs *ejs, struct EjsType *type, int numSlots)
 Create a variable.
intejsDefineGlobalFunction(Ejs *ejs, cchar *name, EjsNativeFunction fn)
 Define a global function.
intejsDefineInstanceProperty(Ejs *ejs, EjsType *type, int slotNum, EjsName *name, EjsType *propType, int attributes, EjsVar *value)
 Define an instance property.
intejsDefineProperty(Ejs *ejs, EjsVar *vp, int slotNum, EjsName *qname, struct EjsType *type, int attributes, EjsVar *value)
 Define a property.
intejsDeleteProperty(Ejs *ejs, EjsVar *vp, int slotNum)
 Delete a property.
intejsDeletePropertyByName(Ejs *ejs, EjsVar *vp, EjsName *qname)
 Delete a property by name.
voidejsDestroyVar(Ejs *ejs, EjsVar *vp)
 Destroy a variable.
EjsString*ejsDupString(Ejs *ejs, EjsString *sp)
 Duplicate a string object.
intejsEvalFile(cchar *path)
 Evaluate a file.
intejsEvalModule(cchar *path)
 Evaluate a module.
intejsEvalScript(cchar *script)
 Evaluate a script.
voidejsExit(Ejs *ejs, int status)
 Instruct the interpreter to exit.
voidejsFinalizeVar(Ejs *ejs, EjsVar *vp)
 Finalize a variable before destroying.
char*ejsFormatStack(Ejs *ejs)
 Format the stack backtrace.
voidejsFreeVar(Ejs *ejs, EjsVar *vp)
 Free a new variable.
boolejsGetBoolean(EjsVar *vp)
 Get the C boolean value from a boolean object.
intejsGetDouble(EjsVar *vp)
 Get the numeric value stored in a EjsNumber object.
char*ejsGetErrorMsg(Ejs *ejs, int withStack)
 Get the interpreter error message.
void*ejsGetHandle(Ejs *ejs)
 Get the hosting handle.
intejsGetInt(EjsVar *vp)
 Get the numeric value stored in a EjsNumber object.
MprNumberejsGetNumber(EjsVar *vp)
 Get the numeric value stored in a EjsNumber object.
EjsVar*ejsGetProperty(Ejs *ejs, EjsVar *vp, int slotNum)
 Get a property.
EjsVar*ejsGetPropertyByName(Ejs *ejs, EjsVar *vp, EjsName *qname)
 Get a property by name.
intejsGetPropertyCount(Ejs *ejs, EjsVar *vp)
 Get a count of properties in a variable.
EjsNameejsGetPropertyName(Ejs *ejs, EjsVar *vp, int slotNum)
 Get a variable property's name.
struct EjsTrait*ejsGetPropertyTrait(Ejs *ejs, EjsVar *vp, int slotNum)
 Get a property's traits.
EjsType*ejsGetType(Ejs *ejs, int slotNum)
 Get a type.
EjsType*ejsGetVarType(EjsVar *vp)
 Get a variables type.
intejsGrowObject(Ejs *ejs, EjsObject *obj, int size)
 Grow an object.
boolejsHasException(Ejs *ejs)
 Determine if an exception has been thrown.
EjsVar*ejsInvokeOperator(Ejs *ejs, EjsVar *vp, int opCode, EjsVar *rhs)
 Invoke an opcode on a native type.
boolejsIsA(Ejs *ejs, EjsVar *target, EjsType *type)
 Test if an variable is an instance of a given type.
boolejsIsArray(EjsVar *vp)
 Determine if a variable is an array.
boolejsIsBlock(EjsVar *vp)
 Determine if a variable is a block.
boolejsIsBoolean(EjsVar *vp)
 Determine if a variable is a boolean.
boolejsIsByteArray(EjsVar *vp)
 Determine if a variable is a byte array.
boolejsIsDate(EjsVar *vp)
 Determine if a variable is a Date.
boolejsIsFile(EjsVar *vp)
 Determine if a variable is a File.
boolejsIsFileSystem(EjsVar *vp)
 Determine if a variable is a Path.
boolejsIsFunction(EjsVar *vp)
 Determine if a variable is a function.
boolejsIsInitializer(EjsVar *vp)
 Determine if the function is an initializer.
boolejsIsInstanceBlock(EjsVar *vp)
 Determine if a variable is an instance block.
boolejsIsNamespace(EjsVar *vp),extern,EjsNamespace,*ejsDefineReservedNamespace(Ejs,*ejs
 Determine if a variable is a namespace.
boolejsIsNativeFunction(EjsVar *vp)
 Determine if the function is a native function.
boolejsIsNumber(EjsVar *vp)
 Determine if a variable is a number.
boolejsIsObject(EjsVar *vp)
 Determine if a variable is an EjsObject.
boolejsIsPath(EjsVar *vp)
 Determine if a variable is a Path.
boolejsIsRegExp(EjsVar *vp)
 Determine if the variable is a regular expression.
boolejsIsType(EjsVar *vp)
 Determine if a variable is an type.
boolejsIsTypeSubType(Ejs *ejs, EjsType *target, EjsType *baseType)
 Test if a type is a derived type of a given base type.
intejsLookupProperty(Ejs *ejs, EjsVar *vp, EjsName *qname)
 Lookup a property by name.
voidejsMarkObject(Ejs *ejs, EjsVar *parent, EjsObject *obj)
 Mark an object as currently in use.
voidejsMarkVar(Ejs *ejs, EjsVar *parent, EjsVar *vp)
 Mark a variable as currently in use.
EjsName*ejsName(struct EjsName *qname, cchar *space, cchar *name)
 Initialize a Qualified Name structure.
voidejsReportError(Ejs *ejs, char *fmt, ...)
 Report an error message using the MprLog error channel.
intejsRun(Ejs *ejs)
 Run a script.
EjsVar*ejsRunFunction(Ejs *ejs, EjsFunction *fn, EjsVar *obj, int argc, EjsVar **argv)
 Run a function.
EjsVar*ejsRunFunctionBySlot(Ejs *ejs, EjsVar *obj, int slotNum, int argc, EjsVar **argv)
 Run a function by slot number.
EjsVar*ejsRunInitializer(Ejs *ejs, struct EjsModule *module)
 Run the initializer for a module.
EjsVar*ejsSerialize(Ejs *ejs, EjsVar *value, int maxDepth, bool showAll, bool showBase)
 Serialize a variable.
voidejsSetByteArrayPositions(Ejs *ejs, EjsByteArray *ap, int readPosition, int writePosition)
 Set the I/O byte array positions.
intejsSetProperty(Ejs *ejs, EjsVar *vp, int slotNum, EjsVar *value)
 Set a property's value.
intejsSetPropertyByName(Ejs *ejs, EjsVar *vp, EjsName *qname, EjsVar *value)
 Set a property's value.
intejsSetPropertyName(Ejs *ejs, EjsVar *vp, int slotNum, EjsName *qname)
 Set a property's name.
intejsSetPropertyTrait(Ejs *ejs, EjsVar *vp, int slotNum, struct EjsType *type, int attributes)
 Set a property's traits.
voidejsSetSearchPath(Ejs *ejs, cchar *ejsPath)
 Set the module search path.
EjsVar*ejsThrowArgError(Ejs *ejs, cchar *fmt, ...)
 Throw an argument exception.
EjsVar*ejsThrowArithmeticError(Ejs *ejs, cchar *fmt, ...)
 Throw an math exception.
EjsVar*ejsThrowAssertError(Ejs *ejs, cchar *fmt, ...)
 Throw an assertion exception.
EjsVar*ejsThrowError(Ejs *ejs, cchar *fmt, ...)
 Throw an general error exception.
struct EjsVar*ejsThrowException(Ejs *ejs, struct EjsVar *error)
 Throw an exception.
EjsVar*ejsThrowInstructionError(Ejs *ejs, cchar *fmt, ...)
 Throw an instruction code exception.
EjsVar*ejsThrowInternalError(Ejs *ejs, cchar *fmt, ...)
 Throw an internal error exception.
EjsVar*ejsThrowIOError(Ejs *ejs, cchar *fmt, ...)
 Throw an IO exception.
EjsVar*ejsThrowMemoryError(Ejs *ejs)
 Throw an Memory depletion exception.
EjsVar*ejsThrowOutOfBoundsError(Ejs *ejs, cchar *fmt, ...)
 Throw an out of bounds exception.
EjsVar*ejsThrowReferenceError(Ejs *ejs, cchar *fmt, ...)
 Throw an reference exception.
EjsVar*ejsThrowResourceError(Ejs *ejs, cchar *fmt, ...)
 Throw an resource exception.
EjsVar*ejsThrowStateError(Ejs *ejs, cchar *fmt, ...)
 Throw an state exception.
EjsVar*ejsThrowStopIteration(Ejs *ejs)
 Throw an stop iteration exception.
EjsVar*ejsThrowSyntaxError(Ejs *ejs, cchar *fmt, ...)
 Throw an syntax error exception.
EjsVar*ejsThrowTypeError(Ejs *ejs, cchar *fmt, ...)
 Throw an type error exception.
EjsBoolean*ejsToBoolean(Ejs *ejs, EjsVar *vp)
 Cast a variable to a boolean.
struct EjsNumber*ejsToNumber(Ejs *ejs, EjsVar *vp)
 Cast a variable to a number.
EjsString*ejsToString(Ejs *ejs, EjsVar *vp)
 Cast a variable to a string.
Ejs*ejsCreate(MprCtx ctx, struct Ejs *master, cchar *searchPath, int flags)
 Create an ejs interpreter.
EjsService*ejsCreateService(MprCtx ctx)
 Open the Ejscript service.
intejsEvalFile(cchar *path)
 Evaluate a file.
intejsEvalModule(cchar *path)
 Evaluate a module.
intejsEvalScript(cchar *script)
 Evaluate a script.
voidejsExit(Ejs *ejs, int status)
 Instruct the interpreter to exit.
void*ejsGetHandle(Ejs *ejs)
 Get the hosting handle.
voidejsReportError(Ejs *ejs, char *fmt, ...)
 Report an error message using the MprLog error channel.
voidejsSetSearchPath(Ejs *ejs, cchar *ejsPath)
 Set the module search path.
struct EjsVar*ejsThrowException(Ejs *ejs, struct EjsVar *error)
 Throw an exception.
EjsArray*ejsCreateArray(Ejs *ejs, int size)
 Create an array.
boolejsIsArray(EjsVar *vp)
 Determine if a variable is an array.
boolejsIsBlock(EjsVar *vp)
 Determine if a variable is a block.
EjsBoolean*ejsCreateBoolean(Ejs *ejs, int value)
 Create a boolean.
boolejsGetBoolean(EjsVar *vp)
 Get the C boolean value from a boolean object.
boolejsIsBoolean(EjsVar *vp)
 Determine if a variable is a boolean.
EjsBoolean*ejsToBoolean(Ejs *ejs, EjsVar *vp)
 Cast a variable to a boolean.
EjsByteArray*ejsCreateByteArray(Ejs *ejs, int size)
 Create a byte array.
boolejsIsByteArray(EjsVar *vp)
 Determine if a variable is a byte array.
voidejsSetByteArrayPositions(Ejs *ejs, EjsByteArray *ap, int readPosition, int writePosition)
 Set the I/O byte array positions.
EjsDate*ejsCreateDate(Ejs *ejs, MprTime value)
 Create a new date instance.
boolejsIsDate(EjsVar *vp)
 Determine if a variable is a Date.
char*ejsFormatStack(Ejs *ejs)
 Format the stack backtrace.
char*ejsGetErrorMsg(Ejs *ejs, int withStack)
 Get the interpreter error message.
boolejsHasException(Ejs *ejs)
 Determine if an exception has been thrown.
EjsVar*ejsThrowArgError(Ejs *ejs, cchar *fmt, ...)
 Throw an argument exception.
EjsVar*ejsThrowArithmeticError(Ejs *ejs, cchar *fmt, ...)
 Throw an math exception.
EjsVar*ejsThrowAssertError(Ejs *ejs, cchar *fmt, ...)
 Throw an assertion exception.
EjsVar*ejsThrowError(Ejs *ejs, cchar *fmt, ...)
 Throw an general error exception.
EjsVar*ejsThrowInstructionError(Ejs *ejs, cchar *fmt, ...)
 Throw an instruction code exception.
EjsVar*ejsThrowInternalError(Ejs *ejs, cchar *fmt, ...)
 Throw an internal error exception.
EjsVar*ejsThrowIOError(Ejs *ejs, cchar *fmt, ...)
 Throw an IO exception.
EjsVar*ejsThrowMemoryError(Ejs *ejs)
 Throw an Memory depletion exception.
EjsVar*ejsThrowOutOfBoundsError(Ejs *ejs, cchar *fmt, ...)
 Throw an out of bounds exception.
EjsVar*ejsThrowReferenceError(Ejs *ejs, cchar *fmt, ...)
 Throw an reference exception.
EjsVar*ejsThrowResourceError(Ejs *ejs, cchar *fmt, ...)
 Throw an resource exception.
EjsVar*ejsThrowStateError(Ejs *ejs, cchar *fmt, ...)
 Throw an state exception.
EjsVar*ejsThrowStopIteration(Ejs *ejs)
 Throw an stop iteration exception.
EjsVar*ejsThrowSyntaxError(Ejs *ejs, cchar *fmt, ...)
 Throw an syntax error exception.
EjsVar*ejsThrowTypeError(Ejs *ejs, cchar *fmt, ...)
 Throw an type error exception.
EjsFile*ejsCreateFile(Ejs *ejs, cchar *filename)
 Create a File object.
boolejsIsFileSystem(EjsVar *vp)
 Determine if a variable is a Path.
EjsFunction*ejsCreateFunction(Ejs *ejs, const uchar *code, int codeLen, int numArgs, int numExceptions, EjsType *returnType, int attributes, struct EjsConst *constants, EjsBlock *scope, int lang)
 Create a function object.
boolejsIsFunction(EjsVar *vp)
 Determine if a variable is a function.
boolejsIsInitializer(EjsVar *vp)
 Determine if the function is an initializer.
boolejsIsNativeFunction(EjsVar *vp)
 Determine if the function is a native function.
EjsVar*ejsRunFunction(Ejs *ejs, EjsFunction *fn, EjsVar *obj, int argc, EjsVar **argv)
 Run a function.
EjsVar*ejsRunFunctionBySlot(Ejs *ejs, EjsVar *obj, int slotNum, int argc, EjsVar **argv)
 Run a function by slot number.
EjsVar*ejsRunInitializer(Ejs *ejs, struct EjsModule *module)
 Run the initializer for a module.
EjsHttp*ejsCreateHttp(Ejs *ejs)
 Create a new Http object.
EjsIterator*ejsCreateIterator(Ejs *ejs, EjsVar *target, EjsNativeFunction next, bool deep, EjsArray *namespaces)
 Create an iterator object.
EjsName*ejsAllocName(MprCtx ctx, cchar *space, cchar *name)
 Allocate and Initialize a Qualified Name structure.
EjsName*ejsName(struct EjsName *qname, cchar *space, cchar *name)
 Initialize a Qualified Name structure.
EjsNamespace*ejsCreateNamespace(Ejs *ejs, cchar *name, cchar *uri)
 Create a namespace object.
boolejsIsNamespace(EjsVar *vp),extern,EjsNamespace,*ejsDefineReservedNamespace(Ejs,*ejs
 Determine if a variable is a namespace.
EjsNumber*ejsCreateNumber(Ejs *ejs, MprNumber value)
 Create a number object.
intejsGetDouble(EjsVar *vp)
 Get the numeric value stored in a EjsNumber object.
intejsGetInt(EjsVar *vp)
 Get the numeric value stored in a EjsNumber object.
MprNumberejsGetNumber(EjsVar *vp)
 Get the numeric value stored in a EjsNumber object.
boolejsIsNumber(EjsVar *vp)
 Determine if a variable is a number.
struct EjsNumber*ejsToNumber(Ejs *ejs, EjsVar *vp)
 Cast a variable to a number.
EjsObject*ejsCreateObject(Ejs *ejs, struct EjsType *type, int size)
 Create an object instance of the specified type.
EjsObject*ejsCreateObjectEx(Ejs *ejs, struct EjsType *type, int size, bool dynamic)
 Create an object instance of the specified type.
EjsObject*ejsCreateSimpleObject(Ejs *ejs)
 Create a simple object.
intejsGrowObject(Ejs *ejs, EjsObject *obj, int size)
 Grow an object.
boolejsIsObject(EjsVar *vp)
 Determine if a variable is an EjsObject.
voidejsMarkObject(Ejs *ejs, EjsVar *parent, EjsObject *obj)
 Mark an object as currently in use.
EjsFileSystem*ejsCreateFileSystem(Ejs *ejs, cchar *path)
 Create a FileSystem object.
EjsPath*ejsCreatePath(Ejs *ejs, cchar *path)
 Create a Path object.
boolejsIsPath(EjsVar *vp)
 Determine if a variable is a Path.
EjsRegExp*ejsCreateRegExp(Ejs *ejs, cchar *pattern)
 Create a new regular expression object.
boolejsIsRegExp(EjsVar *vp)
 Determine if the variable is a regular expression.
EjsString*ejsCreateBareString(Ejs *ejs, int len)
 Create an empty string object.
EjsString*ejsCreateString(Ejs *ejs, cchar *value)
 Create a string object.
EjsString*ejsCreateStringAndFree(Ejs *ejs, char *value)
 Create a string object and free the argument.
EjsString*ejsCreateStringWithLength(Ejs *ejs, cchar *value, int len)
 Create a string and reserve extra room.
EjsString*ejsDupString(Ejs *ejs, EjsString *sp)
 Duplicate a string object.
EjsString*ejsToString(Ejs *ejs, EjsVar *vp)
 Cast a variable to a string.
intejsBindFunction(Ejs *ejs, EjsBlock *block, int slotNum, EjsNativeFunction fn)
 Bind a native C function to a function property.
intejsBindMethod(Ejs *ejs, EjsType *type, int slotNum, EjsNativeFunction fn)
 Bind a native C function to a method property.
EjsType*ejsCreateType(Ejs *ejs, EjsName *name, struct EjsModule *up, EjsType *baseType, int size, int slotNum, int numTypeProp, int numInstanceProp, int attributes, void *data)
 Create a new type object.
intejsDefineGlobalFunction(Ejs *ejs, cchar *name, EjsNativeFunction fn)
 Define a global function.
intejsDefineInstanceProperty(Ejs *ejs, EjsType *type, int slotNum, EjsName *name, EjsType *propType, int attributes, EjsVar *value)
 Define an instance property.
EjsType*ejsGetType(Ejs *ejs, int slotNum)
 Get a type.
boolejsIsA(Ejs *ejs, EjsVar *target, EjsType *type)
 Test if an variable is an instance of a given type.
boolejsIsInstanceBlock(EjsVar *vp)
 Determine if a variable is an instance block.
boolejsIsType(EjsVar *vp)
 Determine if a variable is an type.
boolejsIsTypeSubType(Ejs *ejs, EjsType *target, EjsType *baseType)
 Test if a type is a derived type of a given base type.
EjsVar*ejsAllocVar(Ejs *ejs, struct EjsType *type, int size)
 Allocate a new variable.
EjsVar*ejsCastVar(Ejs *ejs, EjsVar *vp, struct EjsType *type)
 Cast a variable to a new type.
EjsVar*ejsCloneVar(Ejs *ejs, EjsVar *vp, bool deep)
 Clone a variable.
EjsObject*ejsCopyObject(Ejs *ejs, EjsObject *src, bool deep)
 Copy an object.
EjsVar*ejsCreateInstance(Ejs *ejs, struct EjsType *type, int argc, EjsVar **argv)
 Create a new variable instance.
EjsVar*ejsCreateVar(Ejs *ejs, struct EjsType *type, int numSlots)
 Create a variable.
intejsDefineProperty(Ejs *ejs, EjsVar *vp, int slotNum, EjsName *qname, struct EjsType *type, int attributes, EjsVar *value)
 Define a property.
intejsDeleteProperty(Ejs *ejs, EjsVar *vp, int slotNum)
 Delete a property.
intejsDeletePropertyByName(Ejs *ejs, EjsVar *vp, EjsName *qname)
 Delete a property by name.
voidejsDestroyVar(Ejs *ejs, EjsVar *vp)
 Destroy a variable.
voidejsFinalizeVar(Ejs *ejs, EjsVar *vp)
 Finalize a variable before destroying.
voidejsFreeVar(Ejs *ejs, EjsVar *vp)
 Free a new variable.
EjsVar*ejsGetProperty(Ejs *ejs, EjsVar *vp, int slotNum)
 Get a property.
EjsVar*ejsGetPropertyByName(Ejs *ejs, EjsVar *vp, EjsName *qname)
 Get a property by name.
intejsGetPropertyCount(Ejs *ejs, EjsVar *vp)
 Get a count of properties in a variable.
EjsNameejsGetPropertyName(Ejs *ejs, EjsVar *vp, int slotNum)
 Get a variable property's name.
struct EjsTrait*ejsGetPropertyTrait(Ejs *ejs, EjsVar *vp, int slotNum)
 Get a property's traits.
EjsType*ejsGetVarType(EjsVar *vp)
 Get a variables type.
EjsVar*ejsInvokeOperator(Ejs *ejs, EjsVar *vp, int opCode, EjsVar *rhs)
 Invoke an opcode on a native type.
intejsLookupProperty(Ejs *ejs, EjsVar *vp, EjsName *qname)
 Lookup a property by name.
voidejsMarkVar(Ejs *ejs, EjsVar *parent, EjsVar *vp)
 Mark a variable as currently in use.
EjsVar*ejsSerialize(Ejs *ejs, EjsVar *value, int maxDepth, bool showAll, bool showBase)
 Serialize a variable.
intejsSetProperty(Ejs *ejs, EjsVar *vp, int slotNum, EjsVar *value)
 Set a property's value.
intejsSetPropertyByName(Ejs *ejs, EjsVar *vp, EjsName *qname, EjsVar *value)
 Set a property's value.
intejsSetPropertyName(Ejs *ejs, EjsVar *vp, int slotNum, EjsName *qname)
 Set a property's name.
intejsSetPropertyTrait(Ejs *ejs, EjsVar *vp, int slotNum, struct EjsType *type, int attributes)
 Set a property's traits.

Typedefs

MprNumber Configured numeric type.
EjsCode Byte code.
EjsEx Exception Handler Record.
EjsHashEntry Hash entry for a property.
EjsList List type.
EjsLookup Lookup State.
EjsNames Property Names.
EjsService Ejscript Service structure.
EjsStack Evaluation stack.
EjsTrait Property traits.
EjsTypeHelpers Type Helpers.

Defines

#define_h_EJS_BYTECODETABLE_H   1
 ejsByteCodeTable.h - Master Byte Code Table.
#define_h_EJS_WEB_h   1
 ejsWeb.h -- Header for the Ejscript Web Framework.
#defineEJS_ATTR_BLOCK_HELPERS   (1 << 7)
 Use block helper methods.
#defineEJS_ATTR_BUILTIN   (1 << 12)
 Type is builtin.
#defineEJS_ATTR_CALLS_SUPER   (1 << 11)
 Constructor calls super().
#defineEJS_ATTR_CONST   (1 << 16)
 Property is constant after first assignment.
#defineEJS_ATTR_CONSTRUCTOR   (1 << 26)
 Method is a constructor.
#defineEJS_ATTR_DYNAMIC_INSTANCE   (1 << 17)
 Instances are not sealed.
#defineEJS_ATTR_ENUMERABLE   (1 << 19)
 Property is visible.
#defineEJS_ATTR_FINAL   (1 << 14)
 Type can't be subclassed.
#defineEJS_ATTR_FULL_SCOPE   (1 << 28)
 Function needs closure when defined.
#defineEJS_ATTR_GETTER   (1 << 20)
 Property is a getter.
#defineEJS_ATTR_HAS_CONSTRUCTOR   (1 << 4)
 Type has a constructor.
#defineEJS_ATTR_HAS_INITIALIZER   (1 << 9)
 Type has an initializer.
#defineEJS_ATTR_HAS_RETURN   (1 << 29)
 Function has a return statement.
#defineEJS_ATTR_HAS_STATIC_INITIALIZER   (1 << 10)
 Type has an initializer.
#defineEJS_ATTR_HAS_VALUE   (1 << 31)
 Property has a value record.
#defineEJS_ATTR_INITIALIZER   (1 << 3)
 Initializer code.
#defineEJS_ATTR_INTERFACE   (1 << 30)
 Class is an interface.
#defineEJS_ATTR_LITERAL_GETTER   (1 << 21)
 Property is a getter in object literal.
#defineEJS_ATTR_NATIVE   (1 << 1)
 Property is builtin.
#defineEJS_ATTR_NO_BIND   (1 << 13)
 Type properties are never bound.
#defineEJS_ATTR_OBJECT   (1 << 18)
 Instances are based on EjsObject.
#defineEJS_ATTR_OBJECT_HELPERS   (1 << 6)
 Use object helper methods.
#defineEJS_ATTR_OPER_OVERLOAD   (1 << 5)
 Type overloaded operators.
#defineEJS_ATTR_OPERATOR   (1 << 22)
 Operator.
#defineEJS_ATTR_OVERRIDE   (1 << 15)
 Override base type.
#defineEJS_ATTR_PROTOTYPE   (1 << 2)
 TODO - not supported yet (KEEP).
#defineEJS_ATTR_READONLY   (1 << 23)
 Readonly outside class.
#defineEJS_ATTR_REST   (1 << 27)
 Parameter is a "..." rest.
#defineEJS_ATTR_SETTER   (1 << 24)
 Property is a settter.
#defineEJS_ATTR_SLOTS_NEED_FIXUP   (1 << 8)
 Missing inherited slots.
#defineEJS_ATTR_STATIC   (1 << 25)
 Class static property.
#defineEJS_FLAG_COMPILER   0x4
 Running inside the compiler.
#defineEJS_FLAG_DOC   0x40
 Load documentation from modules.
#defineEJS_FLAG_EMPTY   0x2
 Create an empty interpreter without native elements.
#defineEJS_FLAG_EVENT   0x1
 Event pending.
#defineEJS_FLAG_EXIT   0x80
 Interpreter should exit.
#defineEJS_FLAG_LOADING   0x100
 Loading a module.
#defineEJS_FLAG_MASTER   0x20
 Create a master interpreter.
#defineEJS_FLAG_NO_EXE   0x8
 VM will not execute code.
#defineEJS_FLAG_NOEXIT   0x200
 App should service events and not exit.
#defineEJS_FLAGS_ENUM_ALL   0x2
 Enumerate non-enumerable and fixture properties.
#defineEJS_FLAGS_ENUM_INHERITED   0x1
 Enumerate inherited base classes.
#defineEJS_GC_IN_USE   0xe801e2ec
 Magic number when allocated.
#defineEJS_GC_WORK_QUOTA   512
 Allocations required before garbage colllection.
#defineEJS_HASH_MIN_PROP   8
 Min props to hash.
#defineEJS_LOTSA_PROP   256
 Object with lots of properties.
#defineEJS_MAX_TYPE   256
 Maximum number of types.
#defineEJS_NUM_GLOBAL   256
 Number of globals slots to pre-create.
#defineEJS_NUM_PROP   8
 Default object number of properties.
#defineEJS_SPEC_ECMA   0
 Run in strict ECMA-262 compliance mode.
#defineEJS_SPEC_FIXED   2
 Run with ECMA-262 plus enhancements and add breaking fixes.
#defineEJS_SPEC_PLUS   1
 Run in enhanced ECMA-262 with non-breaking changes.
#defineejsIsNull   ejsIs(vp, ES_Null)
 Determine if a variable is a null.
#defineejsIsNull   ejsIs(vp, ES_Null)
 Determine if a variable is a null.

Ejs

Ejs

Ejsript Interperter Management.

Description:
The Ejs structure contains the state for a single interpreter. The ejsCreate routine may be used to create multiple interpreters and returns a reference to be used in subsequent Ejscript API calls.
API Stability:
Prototype.
See Also:
ejsCreate, ejsCreateService, ejsEvalFile, ejsEvalScript, ejsExit, ejsSetSearchPath
Fields:
Ejs * ejsCreate (MprCtx ctx, struct Ejs *master, cchar *searchPath, int flags)

Create an ejs interpreter.

Description:
Create an interpreter object to evalute Ejscript programs. Ejscript supports multiple interpreters. One interpreter can be designated as a master interpreter and then it can be cloned by supplying the master interpreter to this call. A master interpreter provides the standard system types and clone interpreters can quickly be created an utilize the master interpreter's types. This saves memory and speeds initialization.
Parameters:
ctxAny memory context returned by mprAlloc.
masterOptional master interpreter to clone.
searchPathModule search path to use. Set to NULL for the default search path.
flagsOptional flags to modify the interpreter behavior. Valid flags are:
  • EJS_FLAG_COMPILER - Interpreter will compile code from source
  • EJS_FLAG_NO_EXE - Don't execute any code. Just compile.
  • EJS_FLAG_MASTER - Create a master interpreter
  • EJS_FLAG_DOC - Load documentation from modules
  • EJS_FLAG_NOEXIT - App should service events and not exit unless explicitly instructed
.
Returns:
A new interpreter.
See Also:
ejsCreateService, ejsEvalFile, ejsEvalScript, ejsExit, ejsSetSearchPath
EjsService * ejsCreateService (MprCtx ctx)

Open the Ejscript service.

Description:
One Ejscript service object is required per application. From this service, interpreters can be created.
Parameters:
ctxAny memory context returned by mprAlloc.
Returns:
An ejs service object.
See Also:
ejsCreate, ejsEvalFile, ejsEvalScript, ejsExit, ejsSetSearchPath
int ejsEvalFile (cchar *path)

Evaluate a file.

Description:
Evaluate a file containing an Ejscript. This requires linking with the Ejscript compiler library (libec).
Parameters:
pathFilename of the script to evaluate.
Returns:
Return zero on success. Otherwise return a negative Mpr error code.
See Also:
ejsCreate, ejsCreateService, ejsEvalScript, ejsExit, ejsSetSearchPath
int ejsEvalModule (cchar *path)

Evaluate a module.

Description:
Evaluate a module containing compiled Ejscript.
Parameters:
pathFilename of the module to evaluate.
Returns:
Return zero on success. Otherwise return a negative Mpr error code.
See Also:
ejsCreate, ejsCreateService, ejsEvalFile, ejsEvalScript, ejsExit, ejsSetSearchPath
int ejsEvalScript (cchar *script)

Evaluate a script.

Description:
Evaluate a script. This requires linking with the Ejscript compiler library (libec).
Parameters:
scriptScript to evaluate.
Returns:
Return zero on success. Otherwise return a negative Mpr error code.
See Also:
ejsCreate, ejsCreateService, ejsEvalFile, ejsExit, ejsSetSearchPath
void ejsExit (Ejs *ejs, int status)

Instruct the interpreter to exit.

Description:
This will instruct the interpreter to cease interpreting any further script code.
Parameters:
ejsInterpeter object returned from ejsCreate.
statusReserved and ignored.
See Also:
ejsCreate, ejsCreateService, ejsEvalFile, ejsEvalScript, ejsSetSearchPath
void * ejsGetHandle (Ejs *ejs)

Get the hosting handle.

Description:
The interpreter can store a hosting handle. This is typically a web server object if hosted inside a web server.
Parameters:
ejsInterpeter object returned from ejsCreate.
Returns:
Hosting handle.
See Also:
ejsCreate, ejsCreateService, ejsEvalFile, ejsEvalScript, ejsExit, ejsSetSearchPath
void ejsReportError (Ejs *ejs, char *fmt, ...)

Report an error message using the MprLog error channel.

Description:
This will emit an error message of the format:
  • program:line:errorCode:SEVERITY: message
.
Parameters:
ejsInterpeter object returned from ejsCreate.
fmtIs an alternate printf style format to emit if the interpreter has no valid error message.
...Arguments for fmt.
See Also:
ejsCreate, ejsCreateService, ejsEvalFile, ejsEvalScript, ejsExit, ejsSetSearchPath
void ejsSetSearchPath (Ejs *ejs, cchar *ejsPath)

Set the module search path.

Description:
Set the ejs module search path. The search path is by default set to the value of the EJSPATH environment directory. Ejsript will search for modules by name. The search strategy is: Given a name "a.b.c", scan for:
  • File named a.b.c
  • File named a/b/c
  • File named a.b.c in EJSPATH
  • File named a/b/c in EJSPATH
  • File named c in EJSPATH
Ejs will search for files with no extension and also search for modules with a ".mod" extension. If there is a shared library of the same name with a shared library extension (.so, .dll, .dylib) and the module requires native code, then the shared library will also be loaded.
Parameters:
ejsEjs interpreter.
ejsPathSearch path. This is a colon (or semicolon on Windows) separated string of directories.
See Also:
ejsCreate, ejsCreateService, ejsEvalFile, ejsEvalScript, ejsExit
struct EjsVar * EjsVar* ejsThrowException (Ejs *ejs, struct EjsVar *error)

Throw an exception.

Description:
Throw an exception object.
Parameters:
ejsInterpeter object returned from ejsCreate.
errorException argument object.
Returns:
The exception argument for chaining.
See Also:
ejsCreate, ejsCreateService, ejsEvalFile, ejsEvalScript, ejsExit, ejsSetSearchPath

EjsArray

EjsArray

Array class.

Description:
Arrays provide a growable, integer indexed, in-memory store for objects. An array can be treated as a stack (FIFO or LIFO) or a list (ordered). Insertions can be done at the beginning or end of the stack or at an indexed location within a list. The Array class can store objects with numerical indicies and can also store any named properties. The named properties are stored in the obj field, whereas the numeric indexed values are stored in the data field. Array extends EjsObject and has all the capabilities of EjsObject.
API Stability:
Evolving.
See Also:
ejsCreateArray, ejsIsArray
Fields:
EjsVar **data Array elements.
intlength Array length property.
EjsObjectobj Extends Object.
EjsArray * ejsCreateArray (Ejs *ejs, int size)

Create an array.

Parameters:
ejsEjs reference returned from ejsCreate.
sizeInitial size of the array.
Returns:
A new array object.
See Also:
EjsArray, ejsIsArray
bool ejsIsArray (EjsVar *vp)

Determine if a variable is an array.

Parameters:
vpVariable to test.
Returns:
True if the variable is an array.
See Also:
EjsArray, ejsCreateArray

EjsBlock

EjsBlock

Block class.

Description:
The block class is the base class for all program block scope objects. This is an internal class and not exposed to the script programmer. Blocks (including types) may describe their properties via traits. The traits store the property type and access attributes and are stored in EjsBlock which is a sub class of EjsObject. See ejsBlock.c for details.
API Stability:
Evolving.
See Also:
ejsBindFunction, ejsIsBlock
Fields:
uinthasScriptFunctions Block has non-native functions requiring namespaces.
cchar *name Block name.
EjsListnamespaces Current list of namespaces open in this block of properties.
intnumInherited Number of inherited traits.
intnumTraits Number of allocated traits.
EjsObjectobj Extends Object - Property storage.
struct EjsBlock *scopeChain Lexical scope chain for this block.
intsizeTraits Size of traits.
EjsTrait *traits Actual property traits.
bool ejsIsBlock (EjsVar *vp)

Determine if a variable is a block.

Description:
This call tests if the variable is a block.
Parameters:
vpVariable to test.
Returns:
True if the variable is based on EjsBlock.
See Also:
EjsBlock, ejsBindFunction

EjsBoolean

EjsBoolean

Boolean class.

Description:
The Boolean class provides the base class for the boolean values "true" and "false". EjsBoolean is a primitive native type and extends EjsVar. It is still logically an Object, but implements Object properties and methods itself. Only two instances of the boolean class are ever created created these are referenced as ejs->trueValue and ejs->falseValue.
API Stability:
Evolving.
See Also:
ejsCreateBoolean, ejsGetBoolean, ejsIsBoolean
Fields:
boolvalue Boolean value.
EjsVarvar Logically extends Object.
EjsBoolean * ejsCreateBoolean (Ejs *ejs, int value)

Create a boolean.

Description:
Create a boolean value. This will not actually create a new boolean instance as there can only ever be two boolean instances (true and false). Boolean properties are immutable in Ejscript and so this routine will simply return the appropriate pre-created true or false boolean value.
Parameters:
ejsEjs reference returned from ejsCreate.
valueDesired boolean value. Set to 1 for true and zero for false.
See Also:
EjsBoolean, ejsGetBoolean, ejsIsBoolean
bool ejsGetBoolean (EjsVar *vp)

Get the C boolean value from a boolean object.

Parameters:
vpBoolean variable to access.
Returns:
True or false.
See Also:
EjsBoolean, ejsCreateBoolean, ejsIsBoolean
bool ejsIsBoolean (EjsVar *vp)

Determine if a variable is a boolean.

Parameters:
vpVariable to test.
Returns:
True if the variable is a boolean.
See Also:
EjsBoolean, ejsCreateBoolean, ejsGetBoolean
EjsBoolean * ejsToBoolean (Ejs *ejs, EjsVar *vp)

Cast a variable to a boolean.

Description:
Parameters:
ejsEjs reference returned from ejsCreate.
vpVariable to cast.
Returns:
A new boolean object.
See Also:
EjsBoolean, ejsCreateBoolean, ejsGetBoolean, ejsIsBoolean

EjsByteArray

EjsByteArray

ByteArray class.

Description:
ByteArrays provide a growable, integer indexed, in-memory store for bytes. ByteArrays are a powerful data type that can be used as a simple array to store and encode data as bytes or it can be used as a Stream implementing the Stream interface.

When used as a simple byte array, the ByteArray class offers a low level set of methods to insert and extract bytes. The index operator [] can be used to access individual bytes and the copyIn and copyOut methods can be used to get and put blocks of data. In this mode, the read and write position properties are ignored. Accesses to the byte array are from index zero up to the size defined by the length property. When constructed, the ByteArray can be designated as growable, in which case the initial size will grow as required to accomodate data and the length property will be updated accordingly.

When used as a Stream, the byte array offers various read and write methods which store data at the location specified by the write position property and they read data from the read position. The available method indicates how much data is available between the read and write position pointers. The flush method will reset the pointers to the start of the array. The length property is unchanged in behavior from when used as a simple byte array and it specifies the overall storage capacity of the byte array. As numeric values are read or written, they will be encoded according to the value of the endian property which can be set to either LittleEndian or BigEndian. When used with for/in, ByteArrays will iterate or enumerate over the available data between the read and write pointers.

In Stream mode ByteArrays can be configured with input and output callbacks to provide or consume data to other streams or components. These callbacks will automatically be invoked as required when the various read/write methods are called.

Unlike the Array class, ByteArray can only store data in numeric indicies. It is much efficient than EjsByteArray is a primitive native type and extends EjsVar. It is still logically an Object, but implements Object properties and methods itself. Only two instances of the boolean class are ever created created these are referenced as ejs->trueValue and ejs->falseValue.
API Stability:
Evolving.
See Also:
ejsCreateByteArray, ejsIsByteArray, ejsSetByteArrayPositions
Fields:
intendian Endian encoding.
boolgrowable Aray is growable.
intgrowInc Current read position.
EjsFunction *input Input callback function to get more data.
intlength Length property.
EjsFunction *output Output callback function send data.
intreadPosition Current read position.
intswap I/O must swap bytes due to endian byte ordering.
uchar *value Data bytes in the array.
EjsVarvar Logically extends Object.
intwritePosition Current write position.
EjsByteArray * ejsCreateByteArray (Ejs *ejs, int size)

Create a byte array.

Description:
Create a new byte array instance.
Parameters:
ejsEjs reference returned from ejsCreate.
sizeInitial size of the byte array.
Returns:
A new byte array instance.
See Also:
EjsByteArray, ejsIsByteArray, ejsSetByteArrayPositions
bool ejsIsByteArray (EjsVar *vp)

Determine if a variable is a byte array.

Parameters:
vpVariable to test.
Returns:
True if the variable is a byte array.
See Also:
EjsByteArray, ejsCreateByteArray, ejsSetByteArrayPositions
void ejsSetByteArrayPositions (Ejs *ejs, EjsByteArray *ap, int readPosition, int writePosition)

Set the I/O byte array positions.

Description:
Set the read and/or write positions into the byte array. ByteArrays implement the Stream interface and support sequential and random access reading and writing of data in the array. The byte array maintains read and write positions that are automatically updated as data is read or written from or to the array.
Parameters:
ejsEjs reference returned from ejsCreate.
apByte array object.
readPositionNew read position to set.
writePositionNew write position to set.
See Also:
EjsByteArray, ejsCreateByteArray, ejsIsByteArray

EjsDate

EjsDate

Date class.

Description:
The Date class is a general purpose class for working with dates and times. is a a primitive native type and extends EjsVar. It is still logically an Object, but implements Object properties and methods itself.
API Stability:
Evolving.
See Also:
ejsCreateDate
Fields:
MprTimevalue Time in milliseconds since "1970/01/01 GMT".
EjsVarvar Logically extends Object.
EjsDate * ejsCreateDate (Ejs *ejs, MprTime value)

Create a new date instance.

Parameters:
ejsEjs reference returned from ejsCreate.
valueDate/time value to set the new date instance to.
Returns:
An initialized date instance.
See Also:
EjsDate
bool ejsIsDate (EjsVar *vp)

Determine if a variable is a Date.

Parameters:
vpVariable to test.
Returns:
True if the variable is a date.
See Also:
EjsDate, ejsCreateDate

EjsError

EjsError

Error classes.

Description:
Base class for error exception objects. Exception objects are created by programs and by the system as part of changing the normal flow of execution when some error condition occurs. When an exception is created and acted upon ("thrown"), the system transfers the flow of control to a pre-defined instruction stream (the handler or "catch" code). The handler may return processing to the point at which the exception was thrown or not. It may re-throw the exception or pass control up the call stack.
API Stability:
Evolving.
Fields:
intcode Unique error lookup code.
char *message Exception message.
EjsObjectobj Extends Object.
char *stack Execution stack back trace.
char * ejsFormatStack (Ejs *ejs)

Format the stack backtrace.

Description:
Return a string containing the current interpreter stack backtrace.
Parameters:
ejsEjs reference returned from ejsCreate.
Returns:
A string containing the stack backtrace. The caller must free.
See Also:
char * ejsGetErrorMsg (Ejs *ejs, int withStack)

Get the interpreter error message.

Description:
Return a string containing the current interpreter error message.
Parameters:
ejsEjs reference returned from ejsCreate.
withStackSet to 1 to include a stack backtrace in the error message.
Returns:
A string containing the error message. The caller must free.
See Also:
bool ejsHasException (Ejs *ejs)

Determine if an exception has been thrown.

Parameters:
ejsEjs reference returned from ejsCreate.
Returns:
True if an exception has been thrown.
See Also:
EjsVar * ejsThrowArgError (Ejs *ejs, cchar *fmt, ...)

Throw an argument exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowArithmeticError (Ejs *ejs, cchar *fmt, ...)

Throw an math exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowAssertError (Ejs *ejs, cchar *fmt, ...)

Throw an assertion exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowError (Ejs *ejs, cchar *fmt, ...)

Throw an general error exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowInstructionError (Ejs *ejs, cchar *fmt, ...)

Throw an instruction code exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowInternalError (Ejs *ejs, cchar *fmt, ...)

Throw an internal error exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowIOError (Ejs *ejs, cchar *fmt, ...)

Throw an IO exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowMemoryError (Ejs *ejs)

Throw an Memory depletion exception.

Parameters:
ejsEjs reference returned from ejsCreate.
See Also:
EjsVar * ejsThrowOutOfBoundsError (Ejs *ejs, cchar *fmt, ...)

Throw an out of bounds exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowReferenceError (Ejs *ejs, cchar *fmt, ...)

Throw an reference exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowResourceError (Ejs *ejs, cchar *fmt, ...)

Throw an resource exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowStateError (Ejs *ejs, cchar *fmt, ...)

Throw an state exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowStopIteration (Ejs *ejs)

Throw an stop iteration exception.

Parameters:
ejsEjs reference returned from ejsCreate.
See Also:
EjsVar * ejsThrowSyntaxError (Ejs *ejs, cchar *fmt, ...)

Throw an syntax error exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
EjsVar * ejsThrowTypeError (Ejs *ejs, cchar *fmt, ...)

Throw an type error exception.

Parameters:
ejsEjs reference returned from ejsCreate.
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:

EjsFile

EjsFile

File class.

Description:
The File class provides a foundation of I/O services to interact with physical files and directories. Each File object represents a single file or directory and provides methods for creating, opening, reading, writing and deleting files, and for accessing and modifying information about the file.
API Stability:
Prototype.
See Also:
ejsCreateFile
Fields:
MprFile *file Open file handle.
MprPathinfo Cached file info.
intmode Current open mode.
char *modeString User supplied mode string.
EjsObjectobj Extends Object.
char *path Filename path.
intperms Posix permissions mask.
EjsFile * ejsCreateFile (Ejs *ejs, cchar *filename)

Create a File object.

Description:
Create a file object associated with the given filename. The filename is not opened, just stored.
Parameters:
ejsEjs reference returned from ejsCreate.
filenameFilename to associate with the file object.
Returns:
A new file object.
See Also:
EjsFile

EjsFileSystem

EjsFileSystem

FileSystem class.

Description:
The FileSystem class provides file system services.
API Stability:
Prototype.
See Also:
EjsFile, ejsCreateFile
Fields:
MprFileSystem *fs MPR file system object.
EjsObjectobj Extends Object.
char *path Filename path.
bool ejsIsFileSystem (EjsVar *vp)

Determine if a variable is a Path.

Parameters:
vpVariable to test.
Returns:
True if the variable is a FileSystem.
See Also:
EjsFile, ejsCreateFile

EjsFunction

EjsFunction

Function class.

Description:
The Function type is used to represent closures, function expressions and class methods. It contains a reference to the code to execute, the execution scope and possibly a bound "this" reference.
API Stability:
Evolving.
See Also:
ejsCreateFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunInitializer
Fields:
EjsBlockblock Base block. Only used for closures.
EjsCodecode Byte code.
uintconstructor Function is a constructor.
uintfullScope Closures must capture full scope.
uintgetter Function is a getter.
uinthasReturn Function has a return stmt.
uintisInitializer Function is an initializer function.
uintlang Language compliance level: ecma|plus|fixed.
uintliteralGetter Function is in an object literal.
intnextSlot Next multimethod or getter/setter.
uintnumArgs Count of parameters.
uintnumDefault Count of parameters with default initializers.
EjsObject *obj Function.properties. Demand created.
uintoverride Function overrides a base class method.
EjsVar *owner Back reference to original owning block.
EjsNativeFunctionproc Native function pointer.
EjsType *prototype Function.prototype. Demand created.
uintrest Function has a "..." rest of args parameter.
struct EjsType *resultType Return type of method.
uintsetter Function is a setter.
intslotNum Slot number in owner for this function.
uintstaticMethod Function is a static method.
EjsVar *thisObj Bound "this" for closures.
EjsFunction * ejsCreateFunction (Ejs *ejs, const uchar *code, int codeLen, int numArgs, int numExceptions, EjsType *returnType, int attributes, struct EjsConst *constants, EjsBlock *scope, int lang)

Create a function object.

Description:
This creates a function object and optionally associates byte code with the function.
Parameters:
ejsEjs reference returned from ejsCreate.
codePointer to the byte code. The byte code is not copied so this must be a persistent pointer.
codeLenLength of the code.
numArgsNumber of formal arguments to the function.
numExceptionsNumber of exception handlers.
returnTypeReturn type of the function. Set to NULL for no defined type.
attributesInteger mask of access attributes.
constantsReference to the module constant pool. Some byte code opcodes contain references into the constant pool.
scopeReference to the chain of blocks that that comprises the lexical scope chain for this function.
langLanguage level (ecma|plus|fixed). Use constants EJS_SPEC_ECMA, EJS_SPEC_PLUS, EJS_SPEC_FIXED.
Returns:
An initialized function object.
See Also:
EjsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunInitializer
bool ejsIsFunction (EjsVar *vp)

Determine if a variable is a function.

This will return true if the variable is a function of any kind, including methods, native and script functions or initializers
Parameters:
vpVariable to test.
Returns:
True if the variable is a function.
See Also:
EjsFunction, ejsCreateFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunInitializer
bool ejsIsInitializer (EjsVar *vp)

Determine if the function is an initializer.

Initializers are special functions created by the compiler to do static and instance initialization of classes during construction
Parameters:
vpVariable to test.
Returns:
True if the variable is an initializer.
See Also:
EjsFunction, ejsCreateFunction, ejsIsFunction, ejsIsNativeFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunInitializer
bool ejsIsNativeFunction (EjsVar *vp)

Determine if the function is a native function.

Functions can be either native - meaning the implementation is via a C function, or can be scripted
Parameters:
vpVariable to test.
Returns:
True if the variable is a native function.
See Also:
EjsFunction, ejsCreateFunction, ejsIsFunction, ejsIsInitializer, ejsRunFunction, ejsRunFunctionBySlot, ejsRunInitializer
EjsVar * ejsRunFunction (Ejs *ejs, EjsFunction *fn, EjsVar *obj, int argc, EjsVar **argv)

Run a function.

Description:
Run a function with the given actual parameters.
Parameters:
ejsEjs reference returned from ejsCreate.
fnFunction object to run.
objObject to use as the "this" object when running the function.
argcCount of actual parameters.
argvVector of actual parameters.
Returns:
The return value from the function. If an exception is thrown, NULL will be returned and ejs->exception will be set to the exception object.
See Also:
EjsFunction, ejsCreateFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRunFunctionBySlot, ejsRunInitializer
EjsVar * ejsRunFunctionBySlot (Ejs *ejs, EjsVar *obj, int slotNum, int argc, EjsVar **argv)

Run a function by slot number.

Description:
Run a function identified by slot number with the given actual parameters. This will run the function stored at slotNum in the obj variable.
Parameters:
ejsEjs reference returned from ejsCreate.
objObject that holds the function at its "slotNum" slot. Also use this object as the "this" object when running the function.
slotNumSlot number in obj that contains the function to run.
argcCount of actual parameters.
argvVector of actual parameters.
Returns:
The return value from the function. If an exception is thrown, NULL will be returned and ejs->exception will be set to the exception object.
See Also:
EjsFunction, ejsCreateFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRunFunction, ejsRunInitializer
EjsVar * ejsRunInitializer (Ejs *ejs, struct EjsModule *module)

Run the initializer for a module.

Description:
A module's initializer runs global code defined in the module.
Parameters:
ejsEjs reference returned from ejsCreate.
moduleModule object reference.
Returns:
The last expression result of global code executed.
See Also:
EjsFunction, ejsCreateFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRunFunction, ejsRunFunctionBySlot

EjsGlobal

EjsHttp

EjsHttp

Http Class.

Description:
API Stability:
Prototype.
See Also:
ejsCreateHttp
Fields:
EjsFunction *callback Async callback function.
char *certFile SSL certificate file.
MprBuf *content Response data.
intcontentLength Expected content length for post/put data.
Ejs *ejs Convenience access to ejs interpreter instance.
uintfollowRedirects Transparently follow 30X redirects.
uintgotResponse Request has been sent and response headers have been received.
MprHttp *http Underlying MPR http object.
char *keyFile SSL key file.
char *method HTTP method.
EjsObjectobj Extends Object.
char *postData Post data supplied via post() method.
intreadOffset Read response I/O ptr.
uintrequestStarted Request started and connection to server is open.
char *uri Target uri.
EjsHttp * ejsCreateHttp (Ejs *ejs)

Create a new Http object.

Parameters:
ejsEjs reference returned from ejsCreate.
Returns:
A new Http object.
See Also:
EjsHttp

EjsIterator

EjsIterator

Iterator Class.

Description:
Iterator is a helper class to implement iterators in other native classes.
API Stability:
Prototype.
See Also:
ejsCreateIterator
Fields:
booldeep Iterator deep (recursively over all properties).
intindex Current index.
EjsVar *indexVar Reference to current item.
EjsArray *namespaces Namespaces to consider in iteration.
EjsNativeFunctionnativeNext Native next function.
EjsVar *target Object to be enumerated.
EjsVarvar Logically extends Object.
EjsIterator * ejsCreateIterator (Ejs *ejs, EjsVar *target, EjsNativeFunction next, bool deep, EjsArray *namespaces)

Create an iterator object.

Description:
The EjsIterator object is a helper class for native types to implement iteration and enumeration.
Parameters:
ejsEjs reference returned from ejsCreate.
targetTarget variable to iterate or enumerate.
nextFunction to invoke to step to the next element.
deepSet to true to do a deep iteration/enumeration.
namespacesReserved and not used. Supply NULL.
Returns:
A new EjsIterator object.
See Also:
EjsIterator

EjsName

EjsName

Qualified name structure.

Description:
All names in Ejscript consist of a property name and a name space. Namespaces provide discrete spaces to manage and minimize name conflicts. These names will soon be converted to unicode.
API Stability:
Prototype.
See Also:
ejsAllocName, ejsName
Fields:
cchar *name Property name.
cchar *space Property namespace.
EjsName * ejsAllocName (MprCtx ctx, cchar *space, cchar *name)

Allocate and Initialize a Qualified Name structure.

Description:
Create and initialize a qualified name structure using a name and namespace.
Parameters:
ctxAny memory context returned by mprAlloc.
spaceNamespace string.
nameName string.
Returns:
A reference to an allocated EjsName structure. Caller must free.
See Also:
EjsName, ejsName
EjsName * ejsName (struct EjsName *qname, cchar *space, cchar *name)

Initialize a Qualified Name structure.

Description:
Initialize the statically allocated qualified name structure using a name and namespace.
Parameters:
qnameReference to an existing, uninitialized EjsName structure.
spaceNamespace string.
nameName string.
Returns:
A reference to the qname structure.
See Also:
EjsName, ejsAllocName

EjsNamespace

EjsNamespace

Namespace Class.

Description:
Namespaces are used to qualify names into discrete spaces.
API Stability:
Evolving.
See Also:
ejsCreateNamespace, ejsIsNamespace
Description:
The Reflect class permits introspection into the type and attributes of objects and properties.
API Stability:
Evolving.
See Also:
Fields:
intflags Fast comparison flags.
char *name Textual name of the namespace.
char *uri Optional uri definition.
EjsVarvar Logically extends Object.
EjsNamespace * ejsCreateNamespace (Ejs *ejs, cchar *name, cchar *uri)

Create a namespace object.

Parameters:
ejsEjs reference returned from ejsCreate.
nameSpace name to use for the namespace.
uriURI to associate with the namespace.
Returns:
A new namespace object.
See Also:
bool ejsIsNamespace (EjsVar *vp)

Determine if a variable is a namespace.

Returns:
True if the variable is a namespace.
See Also:

EjsNull

EjsNumber

EjsNumber

Number class.

Description:
The Number class provide the base class for all numeric values. The primitive number storage data type may be set via the configure program to be either double, float, int or int64.
API Stability:
Evolving.
See Also:
ejsCreateNumber, ejsGetDouble, ejsGetInt, ejsGetNumber, ejsIsNumber, ejsToNumber
Fields:
MprNumbervalue Numeric value.
EjsVarvar Logically extends Object.
EjsNumber * ejsCreateNumber (Ejs *ejs, MprNumber value)

Create a number object.

Parameters:
ejsEjs reference returned from ejsCreate.
valueNumeric value to initialize the number object.
Returns:
A number object.
See Also:
EjsNumber, ejsGetDouble, ejsGetInt, ejsGetNumber, ejsIsNumber, ejsToNumber
int ejsGetDouble (EjsVar *vp)

Get the numeric value stored in a EjsNumber object.

Parameters:
vpVariable to examine.
Returns:
A double value.
See Also:
EjsNumber, ejsCreateNumber, ejsGetInt, ejsGetNumber, ejsIsNumber, ejsToNumber
int ejsGetInt (EjsVar *vp)

Get the numeric value stored in a EjsNumber object.

Parameters:
vpVariable to examine.
Returns:
An integer value.
See Also:
EjsNumber, ejsCreateNumber, ejsGetDouble, ejsGetNumber, ejsIsNumber, ejsToNumber
MprNumber ejsGetNumber (EjsVar *vp)

Get the numeric value stored in a EjsNumber object.

Parameters:
vpVariable to examine.
Returns:
A numeric value.
See Also:
EjsNumber, ejsCreateNumber, ejsGetDouble, ejsGetInt, ejsIsNumber, ejsToNumber
bool ejsIsNumber (EjsVar *vp)

Determine if a variable is a number.

Parameters:
vpVariable to examine.
Returns:
True if the variable is a number.
See Also:
EjsNumber, ejsCreateNumber, ejsGetDouble, ejsGetInt, ejsGetNumber, ejsToNumber
struct EjsNumber * EjsNumber* ejsToNumber (Ejs *ejs, EjsVar *vp)

Cast a variable to a number.

Parameters:
ejsEjs reference returned from ejsCreate.
vpVariable to cast.
Returns:
A number object.
See Also:
EjsNumber, ejsCreateNumber, ejsGetDouble, ejsGetInt, ejsGetNumber, ejsIsNumber

EjsObject

EjsObject

Object Type.

Description:
The EjsObject type is used as the foundation for types, blocks, functions and all scripted classes. It implements the EjsVar interface and provides storage and hashed lookup for properties. It supports dynamic objects that can grow the number of properties they store.

Note that native classes may or may not be based on EjsObject. Some native classes may implement the EjsVar interface so they can optimally store their properties - often as native types themselves. Numbers are such a case.
API Stability:
Evolving.
See Also:
ejsCopyObject, ejsCreateObject, ejsCreateObjectEx, ejsCreateSimpleObject, ejsGrowObject, ejsIsObject, ejsMarkObject
Fields:
intcapacity Current capacity for properties.
EjsNames *names Hash table of property names.
intnumProp Number of properties.
EjsVar **slots Vector of slots containing var references.
EjsVarvar Implement EjsVar interface.
EjsObject * ejsCreateObject (Ejs *ejs, struct EjsType *type, int size)

Create an object instance of the specified type.

Description:
Create a new object using the specified type as a base class. Note: the constructor is not called. If you require the constructor to be invoked, use ejsCreateInstance.
Parameters:
ejsInterpreter instance returned from ejsCreate.
typeBase type to use when creating the object instance.
sizeNumber of extra slots to allocate when creating the object.
Returns:
A new object instance.
See Also:
EjsObject, ejsCopyObject, ejsCreateObjectEx, ejsCreateSimpleObject, ejsGrowObject, ejsIsObject, ejsMarkObject
EjsObject * ejsCreateObjectEx (Ejs *ejs, struct EjsType *type, int size, bool dynamic)

Create an object instance of the specified type.

Description:
Create a new object using the specified type as a base class. Note: the constructor is not called. If you require the constructor to be invoked, use ejsCreateInstance.
Parameters:
ejsInterpreter instance returned from ejsCreate.
typeBase type to use when creating the object instance.
sizeNumber of extra slots to allocate when creating the object.
dynamicSet to true to make the object as being dynamic. Dynamic objects can create new properties and grow at any time.
Returns:
A new object instance.
See Also:
EjsObject, ejsCopyObject, ejsCreateObject, ejsCreateSimpleObject, ejsGrowObject, ejsIsObject, ejsMarkObject
EjsObject * ejsCreateSimpleObject (Ejs *ejs)

Create a simple object.

Description:
Create a simple object using Object as its base type.
Parameters:
ejsInterpreter instance returned from ejsCreate.
Returns:
A new object instance.
See Also:
EjsObject, ejsCopyObject, ejsCreateObject, ejsCreateObjectEx, ejsGrowObject, ejsIsObject, ejsMarkObject
int ejsGrowObject (Ejs *ejs, EjsObject *obj, int size)

Grow an object.

Description:
Grow the slot storage for an object. Object properties are stored in slots. To store more properties, you need to grow the slots.
Parameters:
ejsInterpreter instance returned from ejsCreate.
objObject reference to grow.
sizeNew minimum count of properties. If size is less than the current number of properties, the call will be ignored, i.e. it will not shrink objects.
Returns:
A new object instance.
See Also:
EjsObject, ejsCopyObject, ejsCreateObject, ejsCreateObjectEx, ejsCreateSimpleObject, ejsIsObject, ejsMarkObject
bool ejsIsObject (EjsVar *vp)

Determine if a variable is an EjsObject.

Description:
This call tests if the variable is based on EjsObject. Note that all variables are logically objects in that they implement the EjsVar interface. However, only those that are composed of EjsObject will return true for this call. Types, Blocks, Functions and all scripted classes are based on EjsObject and will test true.
Parameters:
vpVariable to test.
Returns:
True if the variable is based on EjsObject.
See Also:
EjsObject, ejsCopyObject, ejsCreateObject, ejsCreateObjectEx, ejsCreateSimpleObject, ejsGrowObject, ejsMarkObject
void ejsMarkObject (Ejs *ejs, EjsVar *parent, EjsObject *obj)

Mark an object as currently in use.

Description:
Mark an object as currently active so the garbage collector will preserve it. This routine should be called by native types that extend EjsObject in their markVar helper.
Parameters:
ejsInterpreter instance returned from ejsCreate.
parentOwning variable for the property.
objObject to mark as currently being used.
See Also:
EjsObject, ejsCopyObject, ejsCreateObject, ejsCreateObjectEx, ejsCreateSimpleObject, ejsGrowObject, ejsIsObject

EjsPath

EjsPath

Path class.

Description:
The Path class provides file path name services.
API Stability:
Prototype.
See Also:
EjsFile, ejsCreatePath, ejsIsPath
Fields:
MprList *files File list for enumeration.
MprPathinfo Cached file info.
EjsObjectobj Extends Object.
char *path Filename path.
EjsFileSystem * ejsCreateFileSystem (Ejs *ejs, cchar *path)

Create a FileSystem object.

Description:
Create a file system object associated with the given pathname.
Parameters:
ejsEjs reference returned from ejsCreate.
pathPath to describe the file system. Can be any path in the file system.
Returns:
A new file system object.
See Also:
EjsFile, ejsCreatePath, ejsIsPath
EjsPath * ejsCreatePath (Ejs *ejs, cchar *path)

Create a Path object.

Description:
Create a file object associated with the given filename. The filename is not opened, just stored.
Parameters:
ejsEjs reference returned from ejsCreate.
pathPath file name.
Returns:
A new Path object.
See Also:
EjsFile, ejsIsPath
bool ejsIsPath (EjsVar *vp)

Determine if a variable is a Path.

Parameters:
vpVariable to test.
Returns:
True if the variable is a Path.
See Also:
EjsFile, ejsCreatePath

EjsRegExp

EjsRegExp

RegExp Class.

Description:
The regular expression class provides string pattern matching and substitution.
API Stability:
Evolving.
See Also:
ejsCreateRegExp, ejsIsRegExp
Fields:
void *compiled Compiled pattern.
intendLastMatch End of the last match (one past end).
boolglobal Search for pattern globally (multiple times).
boolignoreCase Do case insensitive matching.
struct EjsString *matched Last matched component.
boolmultiline Match patterns over multiple lines.
char *pattern Pattern to match with.
intstartLastMatch Start of the last match.
EjsVarvar Logically extends Object.
EjsRegExp * ejsCreateRegExp (Ejs *ejs, cchar *pattern)

Create a new regular expression object.

Parameters:
ejsEjs reference returned from ejsCreate.
patternRegular expression pattern string.
Returns:
A EjsRegExp object.
See Also:
EjsRegExp, ejsIsRegExp
bool ejsIsRegExp (EjsVar *vp)

Determine if the variable is a regular expression.

Returns:
True if the variable is a regular expression.
See Also:
EjsRegExp, ejsCreateRegExp

EjsString

EjsString

String Class.

Description:
The String class provides the base class for all strings. Each String object represents a single immutable linear sequence of characters. Strings have operators for: comparison, concatenation, copying, searching, conversion, matching, replacement, and, subsetting.

Strings are currently sequences of UTF-8 characters. They will soon be upgraded to UTF-16.
API Stability:
Evolving.
See Also:
ejsCreateBareString, ejsCreateString, ejsCreateStringWithLength, ejsDupString, ejsToString
Fields:
intlength String length (sans null).
char *value String value. Currently UTF-8. Will upgrade to UTF-16 soon.
EjsVarvar Logically extentends Object.
EjsString * ejsCreateBareString (Ejs *ejs, int len)

Create an empty string object.

Parameters:
ejsEjs reference returned from ejsCreate.
lenLength of space to reserve for future string data.
Returns:
A string object.
See Also:
EjsString, ejsCreateString, ejsCreateStringWithLength, ejsDupString, ejsToString
EjsString * ejsCreateString (Ejs *ejs, cchar *value)

Create a string object.

Parameters:
ejsEjs reference returned from ejsCreate.
valueC string value to define for the string object. Note: this will soon be changed to unicode.
API Stability:
Prototype.
Returns:
A string object.
See Also:
EjsString, ejsCreateBareString, ejsCreateStringWithLength, ejsDupString, ejsToString
EjsString * ejsCreateStringAndFree (Ejs *ejs, char *value)

Create a string object and free the argument.

Parameters:
ejsEjs reference returned from ejsCreate.
valueC string value to define for the string object. Note: this will soon be changed to unicode.
API Stability:
Prototype.
Returns:
A string object.
See Also:
EjsString, ejsCreateBareString, ejsCreateString, ejsCreateStringWithLength, ejsDupString, ejsToString
EjsString * ejsCreateStringWithLength (Ejs *ejs, cchar *value, int len)

Create a string and reserve extra room.

Parameters:
ejsEjs reference returned from ejsCreate.
valueC string value to define for the string object. Note: this will soon be changed to unicode.
lenLength of the string storage to allocate.
Returns:
A string object.
See Also:
EjsString, ejsCreateBareString, ejsCreateString, ejsDupString, ejsToString
EjsString * ejsDupString (Ejs *ejs, EjsString *sp)

Duplicate a string object.

Parameters:
ejsEjs reference returned from ejsCreate.
spString value to copy.
Returns:
A string object.
See Also:
EjsString, ejsCreateBareString, ejsCreateString, ejsCreateStringWithLength, ejsToString
EjsString * ejsToString (Ejs *ejs, EjsVar *vp)

Cast a variable to a string.

Parameters:
ejsEjs reference returned from ejsCreate.
vpVariable to cast.
Returns:
A string object.
See Also:
EjsString, ejsCreateBareString, ejsCreateString, ejsCreateStringWithLength, ejsDupString

EjsTimer

EjsTimer

Timer Class.

Description:
Timers manage the scheduling and execution of Ejscript functions. Timers run repeatedly until stopped by calling the stop method and are scheduled with a granularity of 1 millisecond.
API Stability:
Evolving.
See Also:
Fields:
EjsFunction *callback Callback function.
intdrift Event is allowed to drift.
Ejs *ejs Need interpreter reference in callback.
MprEvent *event MPR event for the timer.
EjsObjectobj Extends Object.
intperiod Time in msec between invocations.

EjsType

EjsType

Type class.

Description:
Classes in Ejscript are represented by instances of an EjsType. Types are templates for creating instances of the given type, but they are also are runtime accessible objects. Types contain the static properties and methods for objects and store these in their object slots array. They store the instance properties in the type->instance object. EjsType inherits from EjsBlock, EjsObject and EjsVar.
API Stability:
Evolving.
See Also:
ejsBindMethod, ejsCreateType, ejsDefineInstanceProperty, ejsGetType, ejsIsA, ejsIsInstanceBlock, ejsIsType, ejsIsTypeSubType
Fields:
struct EjsType *baseType Base class.
EjsBlockblock Type properties (functions and static properties).
uintcallsSuper Constructor calls super().
uintdynamicInstance Instances may add properties.
uintfinal Type is final.
uintfixupDone Slot fixup performed.
uinthasBaseConstructors Base types has constructors.
uinthasBaseInitializers Base types have initializers.
uinthasBaseStaticInitializers Base types have initializers.
uinthasConstructor Type has a constructor.
uinthasFinalizer Instances need finalization.
uinthasInitializer Type has instance level initialization code.
uinthasObject Type based on EjsObject.
uinthasStaticInitializer Type has static level initialization code.
struct EjsTypeHelpers *helpers Type helper methods.
shortid Unique type id.
MprList *implements List of implemented interfaces.
uintinitialized Static initializer has run.
EjsBlock *instanceBlock Instance properties template.
ushortinstanceSize Size of instances in bytes.
uintisInterface Interface vs class.
struct EjsModule *module Module owning the type - stores the constant pool.
uintneedFixup Slots need fixup.
uintnobind Don't bind properties for this type to slots.
uintnumAlloc Allocation chunking increment.
uintnumericIndicies Instances support direct numeric indicies.
uintoperatorOverload Using overloaded operators - TODO not used.
EjsNameqname Qualified name of the type. Type name and namespace.
uintseparateInstanceSlots Instances slots allocated separately to object.
uintskipScope Skip examining this object when searching the scope chain.
uintsubTypeCount Length of baseType chain Governed by EJS_MAX_BASE_CLASS.
void *typeData Type specific data.
int ejsBindFunction (Ejs *ejs, EjsBlock *block, int slotNum, EjsNativeFunction fn)

Bind a native C function to a function property.

Description:
Bind a native C function to an existing javascript function. Functions are typically created by compiling a script file of native function definitions into a mod file. When loaded, this mod file will create the function properties. This routine will then bind the specified C function to the function property.
Parameters:
ejsInterpreter instance returned from ejsCreate.
blockBlock containing the function property to bind.
slotNumSlot number of the method property.
fnNative C function to bind.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsType, ejsBindMethod, ejsCreateType, ejsDefineInstanceProperty, ejsGetType, ejsIsA, ejsIsInstanceBlock, ejsIsType, ejsIsTypeSubType
int ejsBindMethod (Ejs *ejs, EjsType *type, int slotNum, EjsNativeFunction fn)

Bind a native C function to a method property.

Description:
Bind a native C function to an existing javascript method. Method functions are typically created by compiling a script file of native method definitions into a mod file. When loaded, this mod file will create the method properties. This routine will then bind the specified C function to the method property.
Parameters:
ejsInterpreter instance returned from ejsCreate.
typeType containing the function property to bind.
slotNumSlot number of the method property.
fnNative C function to bind.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsType, ejsCreateType, ejsDefineInstanceProperty, ejsGetType, ejsIsA, ejsIsInstanceBlock, ejsIsType, ejsIsTypeSubType
EjsType * ejsCreateType (Ejs *ejs, EjsName *name, struct EjsModule *up, EjsType *baseType, int size, int slotNum, int numTypeProp, int numInstanceProp, int attributes, void *data)

Create a new type object.

Description:
Create a new type object.
Parameters:
ejsEjs reference returned from ejsCreate.
nameQualified name to give the type. This name is merely referenced by the type and must be persistent. This name is not used to define the type as a global property.
upReference to a module that will own the type. Set to null if not owned by any module.
baseTypeBase type for this type.
sizeSize of instances. This is the size in bytes of an instance object.
slotNumSlot number that the type will be installed at. This is used by core types to define a unique type ID. For non-core types, set to -1.
numTypePropNumber of type (class) properties for the type. These include static properties and methods.
numInstancePropNumber of instance properties.
attributesAttribute mask to modify how the type is initialized. Valid values include:
  • EJS_ATTR_BLOCK_HELPERS - Type uses EjsBlock helpers
  • EJS_ATTR_CALLS_SUPER - Type calls super()
  • EJS_ATTR_DYNAMIC_INSTANCE - Instance objects are dynamic
  • EJS_ATTR_FINAL - Type will be a final class
  • EJS_ATTR_INTERFACE - Type is an interface
  • EJS_ATTR_HAS_CONSTRUCTOR - Type has a constructor to call
  • EJS_ATTR_HAS_INITIALIZER - Type has an initializer
  • EJS_ATTR_HAS_STATIC_INITIALIZER - Type has a static initializer
  • EJS_ATTR_NO_BIND - Instruct the compiler to never bind any property references to slots
  • EJS_ATTR_OBJECT - Type instances are based on EjsObject
  • EJS_ATTR_OPER_OVERLOAD - Type uses operator overload
  • EJS_ATTR_OBJECT_HELPERS - Type uses EjsObject helpers
  • EJS_ATTR_SLOT_NEEDS_FIXUP - Slots will need fixup. Typically because the base type is unknown
.
data
See Also:
EjsType, ejsBindMethod, ejsDefineInstanceProperty, ejsGetType, ejsIsA, ejsIsInstanceBlock, ejsIsType, ejsIsTypeSubType
int ejsDefineGlobalFunction (Ejs *ejs, cchar *name, EjsNativeFunction fn)

Define a global function.

Description:
Define a global public function and bind it to the C native function. This is a simple one liner to define a public global function. The more typical paradigm to define functions is to create a script file of native method definitions and and compile it. This results in a mod file that can be loaded which will create the function/method definitions. Then use ejsBindMethod to associate a C function with a property.
See Also:
EjsType, ejsBindMethod, ejsCreateType, ejsDefineInstanceProperty, ejsGetType, ejsIsA, ejsIsInstanceBlock, ejsIsType, ejsIsTypeSubType
int ejsDefineInstanceProperty (Ejs *ejs, EjsType *type, int slotNum, EjsName *name, EjsType *propType, int attributes, EjsVar *value)

Define an instance property.

Description:
Define an instance property on a type. This routine should not normally be called manually. Instance properties are best created by creating a script file of native property definitions and then loading the resultant mod file.
Parameters:
ejsInterpreter instance returned from ejsCreate.
typeType in which to create the instance property.
slotNumInstance slot number in the type that will hold the property. Set to -1 to allocate the next available free slot.
nameQualified name for the property including namespace and name.
propTypeType of the instance property.
attributesInteger mask of access attributes.
valueInitial value of the instance property.
Returns:
The slot number used for the property.
See Also:
EjsType, ejsBindMethod, ejsCreateType, ejsGetType, ejsIsA, ejsIsInstanceBlock, ejsIsType, ejsIsTypeSubType
EjsType * ejsGetType (Ejs *ejs, int slotNum)

Get a type.

Description:
Get the type installed at the given slot number. All core-types are installed a specific global slots. When Ejscript is built, these slots are converted into C program defines of the form: ES_TYPE where TYPE is the name of the type concerned. For example, you can get the String type object via:.
EjsGetType(ejs, ES_String).
Parameters:
ejsInterpreter instance returned from ejsCreate.
slotNumSlot number of the type to retrieve. Use ES_TYPE defines.
Returns:
A type object if successful or zero if the type could not be found.
See Also:
EjsType, ejsBindMethod, ejsCreateType, ejsDefineInstanceProperty, ejsIsA, ejsIsInstanceBlock, ejsIsType, ejsIsTypeSubType
bool ejsIsA (Ejs *ejs, EjsVar *target, EjsType *type)

Test if an variable is an instance of a given type.

Description:
Perform an "is a" test. This tests if a variable is a direct instance or subclass of a given base type.
Parameters:
ejsInterpreter instance returned from ejsCreate.
targetTarget variable to test.
typeType to compare with the target.
Returns:
True if target is an instance of "type" or an instance of a subclass of "type".
See Also:
EjsType, ejsBindMethod, ejsCreateType, ejsDefineInstanceProperty, ejsGetType, ejsIsInstanceBlock, ejsIsType, ejsIsTypeSubType
bool ejsIsInstanceBlock (EjsVar *vp)

Determine if a variable is an instance block.

Types store the template for instance properties in an instance block object
Parameters:
vpVariable to test.
Returns:
True if the variable is an instance block object.
See Also:
EjsType, ejsBindMethod, ejsCreateType, ejsDefineInstanceProperty, ejsGetType, ejsIsA, ejsIsType, ejsIsTypeSubType
bool ejsIsType (EjsVar *vp)

Determine if a variable is an type.

Parameters:
vpVariable to test.
Returns:
True if the variable is a type.
See Also:
EjsType, ejsBindMethod, ejsCreateType, ejsDefineInstanceProperty, ejsGetType, ejsIsA, ejsIsInstanceBlock, ejsIsTypeSubType
bool ejsIsTypeSubType (Ejs *ejs, EjsType *target, EjsType *baseType)

Test if a type is a derived type of a given base type.

Description:
Test if a type subclasses a base type.
Parameters:
ejsInterpreter instance returned from ejsCreate.
targetTarget type to test.
baseTypeBase class to see if the target subclasses it.
Returns:
True if target is a "baseType" or a subclass of "baseType".
See Also:
EjsType, ejsBindMethod, ejsCreateType, ejsDefineInstanceProperty, ejsGetType, ejsIsA, ejsIsInstanceBlock, ejsIsType

EjsVar

EjsVar

Foundation Variable Interface.

Description:
The EjsVar variable interface forms the most basic contract between Ejscript variables and the virtual machine. It defines the essential attributes, base type and state for managing a variable. Ejscript variables can have properties and methods and participate as full objects in Ejscript programs. All Ejscript data types implement the EjsVar interface either directly or indirectly. Primitive types will implement EjsVar by including it as the first field in their structure. They often don't need a property hash and by implementing EjsVar directly, they can save memory space. Class that do require property hashes will typically implement this interface by composing EjsObject which is a concrete implementation of EjsVar.
API Stability:
Evolving.
See Also:
ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
Fields:
uintbuiltin Property is always present.
uintdynamic Object may add properties. Derrived from type.
uintgeneration GC generation for this var.
uinthasGetterSetter Class has getter/setter functions.
uinthidden Not enumerable via for/in.
uintisFrame Is a frame (stack-based var).
uintisFunction Instance is a function.
uintisInstanceBlock Object is a type instance block object.
uintisObject Instance is an Object.
uintisType Instance is a type object (TODO Could do without this bit).
uintjsonVisited JSON traversal.
uintmarked GC marked in use.
uintnative Native property backed by C/Java implementation.
uintnativeProc Method has native proc.
struct EjsVar *next GC linkage.
uintpermanent Object is immune from GC.
uintrefLinks Cross generational reference mask.
uintrootLinks Cross generational root mask.
uintsurvived Object has survived one GC pass.
struct EjsType *type Type of this object (not base type). ie. type for Object is EjsType.
uintvisited Has been traversed.
EjsVar * ejsAllocVar (Ejs *ejs, struct EjsType *type, int size)

Allocate a new variable.

Description:
This will allocate space for a bare variable. This routine should only be called by type factories when implementing the createVar helper.
Parameters:
ejsInterpreter instance returned from ejsCreate.
typeType object from which to create an object instance.
sizeSize of extra property slots to reserve. This is used for dynamic objects.
Returns:
A newly allocated variable of the requested type. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
EjsVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsVar * ejsCastVar (Ejs *ejs, EjsVar *vp, struct EjsType *type)

Cast a variable to a new type.

Description:
Cast a variable and return a new variable of the required type.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to cast.
typeType to cast to.
Returns:
A newly allocated variable of the requested type. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
EjsVar, ejsAllocVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsVar * ejsCloneVar (Ejs *ejs, EjsVar *vp, bool deep)

Clone a variable.

Description:
Copy a variable and create a new copy. This may do a shallow or deep copy. A shallow copy will not copy the property instances, rather it will only duplicate the property reference. A deep copy will recursively clone all the properties of the variable.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to clone.
deepSet to true to do a deep copy.
Returns:
A newly allocated variable of the requested type. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsObject * ejsCopyObject (Ejs *ejs, EjsObject *src, bool deep)

Copy an object.

Description:
Copy an object create a new instance. This may do a shallow or deep copy depending on the value of deep. A shallow copy will not copy the property instances, rather it will only duplicate the property reference. A deep copy will recursively clone all the properties of the variable.
Parameters:
ejsInterpreter instance returned from ejsCreate.
srcSource object to copy.
deepSet to true to do a deep copy.
Returns:
A newly allocated object. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsVar * ejsCreateInstance (Ejs *ejs, struct EjsType *type, int argc, EjsVar **argv)

Create a new variable instance.

Description:
Create a new variable instance and invoke any required constructors with the given arguments.
Parameters:
ejsInterpreter instance returned from ejsCreate.
typeType from which to create a new instance.
argcCount of args in argv.
argvVector of arguments. Each arg is an EjsVar.
Returns:
A newly allocated variable of the requested type. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsVar * ejsCreateVar (Ejs *ejs, struct EjsType *type, int numSlots)

Create a variable.

Description:
Create a variable of the required type. This invokes the createVar helper method for the specified type.
Parameters:
ejsInterpreter instance returned from ejsCreate.
typeType to cast to.
numSlotsSize of extra property slots to reserve. This is used for dynamic objects.
Returns:
A newly allocated variable of the requested type. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
int ejsDefineProperty (Ejs *ejs, EjsVar *vp, int slotNum, EjsName *qname, struct EjsType *type, int attributes, EjsVar *value)

Define a property.

Description:
Define a property in a variable and give it a name, base type, attributes and default value.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable in which to define a property.
slotNumSlot number in the variable for the property. Slots are numbered sequentially from zero. Set to -1 to request the next available slot number.
qnameQualified name containing a name and a namespace.
typeBase type of the property. Set to ejs->voidType to leave as untyped.
attributesAttribute traits. Useful attributes include:
  • EJS_ATTR_OVERRIDE
  • EJS_ATTR_CONST
  • EJS_ATTR_ENUMERABLE
.
valueInitial value of the property.
Returns:
A postitive slot number or a negative MPR error code.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
int ejsDeleteProperty (Ejs *ejs, EjsVar *vp, int slotNum)

Delete a property.

Description:
Delete a variable's property and set its slot to null. The slot is not reclaimed and subsequent properties are not compacted.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable in which to delete the property.
slotNumSlot number in the variable for the property to delete.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
int ejsDeletePropertyByName (Ejs *ejs, EjsVar *vp, EjsName *qname)

Delete a property by name.

Description:
Delete a variable's property by name and set its slot to null. The property is resolved by using ejsLookupProperty with the specified name. Once deleted, the slot is not reclaimed and subsequent properties are not compacted.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable in which to delete the property.
qnameQualified name for the property including name and namespace.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
void ejsDestroyVar (Ejs *ejs, EjsVar *vp)

Destroy a variable.

Description:
Destroy a variable of the required type. This invokes the destroyVar helper method for the specified type. The default action for the destroyVar helper is to simply invoke ejsFreeVar which will return the variable storage to a type pool or return the memory to the heap.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVaraible to destroy.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
void ejsFinalizeVar (Ejs *ejs, EjsVar *vp)

Finalize a variable before destroying.

Description:
Finalize a variable. Variables can have finalization routines to release any acquired resources before being destroyed.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to cast.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
void ejsFreeVar (Ejs *ejs, EjsVar *vp)

Free a new variable.

Description:
This should typically only be called by the destroyVar type helper which is invoked by the GC when a variable is no longer needed. It should not be called by normal code.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to free.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsVar * ejsGetProperty (Ejs *ejs, EjsVar *vp, int slotNum)

Get a property.

Description:
Get a property from a variable at a given slot.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
slotNumSlot number for the requested property.
Returns:
The variable property stored at the nominated slot.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsVar * ejsGetPropertyByName (Ejs *ejs, EjsVar *vp, EjsName *qname)

Get a property by name.

Description:
Get a property from a variable by name.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
qnameQualified name specifying both a namespace and name.
Returns:
The variable property stored at the nominated slot.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
int ejsGetPropertyCount (Ejs *ejs, EjsVar *vp)

Get a count of properties in a variable.

Description:
Get a property from a variable at a given slot.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
Returns:
A positive integer count of the properties stored by the variable.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsName ejsGetPropertyName (Ejs *ejs, EjsVar *vp, int slotNum)

Get a variable property's name.

Description:
Get a property name for the property at a given slot in the variable.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
slotNumSlot number for the requested property.
Returns:
The qualified property name including namespace and name. Caller must not free.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
struct EjsTrait * EjsTrait* ejsGetPropertyTrait (Ejs *ejs, EjsVar *vp, int slotNum)

Get a property's traits.

Description:
Get a property's trait description. The property traits define the properties base type, and access attributes.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
slotNumSlot number for the requested property.
Returns:
A trait structure reference for the property.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsType * ejsGetVarType (EjsVar *vp)

Get a variables type.

Description:
Get the base type for a variable.
Parameters:
vpVariable reference.
Returns:
A reference to the variables type object.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsVar * ejsInvokeOperator (Ejs *ejs, EjsVar *vp, int opCode, EjsVar *rhs)

Invoke an opcode on a native type.

Description:
Invoke an Ejscript byte code operator on the specified variable given the expression right hand side. Native types would normally implement the invokeOperator helper function to respond to this function call.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
opCodeByte ope code to execute.
rhsExpression right hand side for binary expression op codes. May be null for other op codes.
Returns:
The result of the op code or NULL if the opcode does not require a result.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
int ejsLookupProperty (Ejs *ejs, EjsVar *vp, EjsName *qname)

Lookup a property by name.

Description:
Search for a property by name in the given variable.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
qnameQualified name of the property to search for.
Returns:
The slot number containing the property. Then use ejsGetProperty to retrieve the property or alternatively use ejsGetPropertyByName to lookup and retrieve in one step.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
void ejsMarkVar (Ejs *ejs, EjsVar *parent, EjsVar *vp)

Mark a variable as currently in use.

Description:
Mark a variables as currently active so the garbage collector will preserve it. This routine should be called by native types in their markVar helper.
Parameters:
ejsInterpreter instance returned from ejsCreate.
parentOwning variable for the property.
vpVariable to mark as currently being used.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
EjsVar * ejsSerialize (Ejs *ejs, EjsVar *value, int maxDepth, bool showAll, bool showBase)
int ejsSetProperty (Ejs *ejs, EjsVar *vp, int slotNum, EjsVar *value)

Set a property's value.

Description:
Set a value for a property at a given slot in the specified variable.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
slotNumSlot number for the requested property.
valueReference to a value to store.
Returns:
The slot number of the property updated.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTrait
int ejsSetPropertyByName (Ejs *ejs, EjsVar *vp, EjsName *qname, EjsVar *value)

Set a property's value.

Description:
Set a value for a property. The property is located by name in the specified variable.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
qnameQualified property name.
valueReference to a value to store.
Returns:
The slot number of the property updated.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyName, ejsSetPropertyTrait
int ejsSetPropertyName (Ejs *ejs, EjsVar *vp, int slotNum, EjsName *qname)

Set a property's name.

Description:
Set a qualified name for a property at the specified slot in the variable. The qualified name consists of a namespace and name - both of which must be persistent. A typical paradigm is for these name strings to be owned by the memory context of the variable.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
slotNumSlot number of the property in the variable.
qnameQualified property name.
Returns:
The slot number of the property updated.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyTrait
int ejsSetPropertyTrait (Ejs *ejs, EjsVar *vp, int slotNum, struct EjsType *type, int attributes)

Set a property's traits.

Description:
Set the traits describing a property. These include the property's base type and access attributes.
Parameters:
ejsInterpreter instance returned from ejsCreate.
vpVariable to examine.
slotNumSlot number of the property in the variable.
typeBase type for the property. Set to NULL for an untyped property.
attributesInteger mask of access attributes.
Returns:
The slot number of the property updated.
See Also:
EjsVar, ejsAllocVar, ejsCastVar, ejsCloneVar, ejsCreateInstance, ejsCreateVar, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDestroyVar, ejsFinalizeVar, ejsFreeVar, ejsGetProperty, ejsGetVarType, ejsLookupProperty, ejsMarkVar, ejsSerialize, ejsSerialize, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName

EjsVm

EjsVoid

Functions

int ejsCopyToByteArray (Ejs *ejs, EjsByteArray *ap, int offset, char *data, int length)

Copy data into a byte array.

Description:
Copy data into a byte array at a specified offset.
Parameters:
ejsEjs reference returned from ejsCreate.
apByte array object.
offsetOffset in the byte array to which to copy the data.
dataPointer to the source data.
lengthLength of the data to copy.
Returns:
Zero if successful, otherwise a negative MPR error code.
bool ejsIsFile (EjsVar *vp)

Determine if a variable is a File.

Parameters:
vpVariable to test.
Returns:
True if the variable is a File.
int ejsRun (Ejs *ejs)

Run a script.

Description:
Run a script that has previously ben compiled by ecCompile.
Parameters:
ejsInterpeter object returned from ejsCreate.
Returns:
Zero if successful, otherwise a non-zero Mpr error code.

Typedefs

typedef BLD_FEATURE_NUM_TYPE MprNumber.

Configured numeric type.

The configure program will define BLD_FEATURE_NUM_TYPE to be either double, float, int or int64
EjsCode

Byte code.

Description:
This structure describes a sequence of byte code for a function. It also defines a set of execption handlers pertaining to this byte code.
Fields:
uchar *byteCode Byte code.
intcodeLen Byte code length.
struct EjsConst *constants Constant pool. Reference to module constant pool.
intfinallyIndex Index in handlers for finally handler.
struct EjsEx **handlers Exception handlers.
intnumHandlers Number of exception handlers.
intsizeHandlers Size of handlers array.
EjsEx

Exception Handler Record.

Description:
Each exception handler has an exception handler record allocated that describes it.
Fields:
struct EjsType *catchType Type of error to catch.
uintflags Exception flags.
uinthandlerEnd Ptr to one past the end.
uinthandlerStart Ptr to start of catch block.
uinttryEnd Ptr to one past the end.
uinttryStart Ptr to start of try block.
EjsHashEntry

Hash entry for a property.

Description:
Properties are indexed by hash entries. These store the property name and a reference to the next slot in the hash collision chain.
Fields:
intnextSlot Next property in hash chain.
EjsNameqname Property name.
EjsList

List type.

Description:
The MprList is a dynamic growable array suitable for storing pointers to arbitrary objects.
Fields:
API Stability:
Prototype.
See Also:
EjsLookup

Lookup State.

Description:
Location information returned when looking up properties.
Fields:
EjsNames

Property Names.

Description:
This structure stores the names of all the properties in an object and holds the hash table state.
Fields:
int *buckets Hash buckets and head of link chains.
EjsHashEntry *entries Hash entries.
intsizeBuckets Size of buckets.
intsizeEntries Size of entries array in elements.
EjsService

Ejscript Service structure.

Description:
The Ejscript service manages the overall language runtime. It is the factory that creates interpreter instances via ejsCreate.
Fields:
EjsStack

Evaluation stack.

Fields:
EjsTrait

Property traits.

Description:
Property traits describe the type and access attributes of a property. The Trait structure is used by EjsBlock to describe the attributes of properties defined within a block. Note: These traits apply to a property definition and not to the referenced object. ie. two property definitions may have different traits but will refer to the same object.
Fields:
intattributes Property attributes.
struct EjsType *type Property type.
API Stability:
Evolving.
EjsTypeHelpers

Type Helpers.

Description:
The type helpers interface defines the set of primitive operations a type must support to interact with the virtual machine.
Fields:

© Embedthis Software LLC, 2003-2009. All rights reserved. Embedthis, Ejscript and Appweb are trademarks of Embedthis Software LLC.