Home > Programmers Reference > Native APIs > Ejscript

See Also

Quick Nav

Ejscript - Native API

Components

Ejs Ejsript VM Structure.
EjsArray Array class.
EjsBlock Block class.
EjsBoolean Boolean class.
EjsByteArray ByteArray class.
EjsCache EjsCache.
EjsCmd Cmd class.
EjsDate Date class.
EjsError Error classes.
EjsFile File class.
EjsFileSystem FileSystem class.
EjsFrame Frame record.
EjsFunction Function class.
EjsHttp Http Class.
EjsHttpServer HttpServer Class.
EjsIterator Iterator Class.
EjsModule Module control structure.
EjsName Qualified name structure.
EjsNamespace Namespace Class.
EjsNull Null Class.
EjsNumber Number class.
EjsObj Base object from which all objects inherit.
EjsPath Path class.
EjsPool Cached pooled of virtual machines.
EjsPot Object with properties Type.
EjsRegExp RegExp Class.
EjsRequest Request Class.
EjsSession Session Class.
EjsSocket Socket Class.
EjsString String Class.
EjsTimer Timer Class.
EjsType Type class.
EjsUri Uri class.
EjsVoid Void class.
EjsWorker Worker Class.
EjsXML XML and XMLList class.

Functions

intEJS_MAKE_VERSION(int maj, int min, int patch)
 Make an integer version number.
EjsType*EST(void *name)
 Special type.
EjsAny*ESV(void *name)
 Get immutable special value.
EjsEx*ejsAddException(Ejs *ejs, EjsFunction *fun, uint tryStart, uint tryEnd, struct EjsType *catchType, uint handlerStart, uint handlerEnd, int numBlocks, int numStack, int flags, int preferredIndex)
 Add an exception record.
intejsAddImmutable(struct Ejs *ejs, int slotNum, EjsName qname, EjsAny *obj)
 Add an immutable reference.
intejsAddItem(Ejs *ejs, EjsArray *ap, EjsAny *item)
 Add an item to the array.
intejsAddObserver(Ejs *ejs, EjsObj **emitterPtr, EjsObj *name, struct EjsFunction *observer)
 Add an observer.
EjsAny*ejsAlloc(Ejs *ejs, struct EjsType *type, ssize extra)
 Allocate a new variable.
Ejs*ejsAllocPoolVM(EjsPool *pool, int flags)
 Allocate a VM from the pool.
intejsAppendAttributeToXML(Ejs *ejs, EjsXML *parent, EjsXML *attribute)
 Append an attribute.
EjsXML*ejsAppendToXML(Ejs *ejs, EjsXML *dest, EjsXML *node)
 Append a node.
intejsAtoi(Ejs *ejs, EjsString *sp, int radix)
 Parse a string and convert to an integer.
intejsBindAccess(Ejs *ejs, EjsAny *obj, int slotNum, void *getter, void *setter)
 Bind a native C functions to method accessors.
voidejsBindConstructor(Ejs *ejs, EjsType *type, void *constructor)
 Bind a constructor.
intejsBindFunction(Ejs *ejs, EjsAny *obj, int slotNum, void *fun)
 Bind a native C function to a function property.
intejsBindMethod(Ejs *ejs, EjsAny *obj, int slotNum, void *fn)
 Bind a native C function to a method property.
intejsBlendObject(Ejs *ejs, EjsObj *dest, EjsObj *src, int flags)
 Blend objects.
intejsBlockGC(Ejs *ejs)
 Block garbage collection.
EjsAny*ejsCacheExpire(Ejs *ejs, EjsObj *cache, struct EjsString *key, struct EjsDate *when)
 Expire a cache item.
EjsAny*ejsCacheRead(Ejs *ejs, EjsObj *cache, struct EjsString *key, EjsObj *options)
 Read an item from the cache.
EjsAny*ejsCacheReadObj(Ejs *ejs, EjsObj *cache, struct EjsString *key, EjsObj *options)
 Read an object from the cache.
EjsBoolean*ejsCacheRemove(Ejs *ejs, EjsObj *cache, struct EjsString *key)
 Read an item from the cache.
EjsAny*ejsCacheSetLimits(Ejs *ejs, EjsObj *cache, EjsObj *limits)
 Set the cache limits.
struct EjsNumber*ejsCacheWrite(Ejs *ejs, EjsObj *cache, struct EjsString *key, struct EjsString *value, EjsObj *options)
 Write an item to the cache.
struct EjsNumber*ejsCacheWriteObj(Ejs *ejs, EjsObj *cache, struct EjsString *key, EjsAny *value, EjsObj *options)
 Write an object to the cache.
EjsArray*ejsCaptureStack(Ejs *ejs, int skip)
 Capture the execution stack.
EjsAny*ejsCast(Ejs *ejs, EjsAny *obj, void *name)
 Cast the object to the given type name.
EjsAny*ejsCastType(Ejs *ejs, EjsAny *obj, struct EjsType *type)
 Cast a variable to a new type.
intejsCheckSlot(Ejs *ejs, EjsPot *obj, int slotNum)
 Check the slot.
voidejsClearArray(Ejs *ejs, EjsArray *ap)
 Clear an array and remove all items.
voidejsClearException(Ejs *ejs)
 Clear an exception.
EjsAny*ejsClone(Ejs *ejs, EjsAny *obj, bool deep)
 Clone a variable.
EjsArray*ejsCloneArray(Ejs *ejs, EjsArray *ap, bool deep)
 Clone an array.
EjsFunction*ejsCloneFunction(Ejs *ejs, EjsFunction *fun, int deep)
 Clone a function.
EjsHttpServer*ejsCloneHttpServer(Ejs *ejs, EjsHttpServer *server, bool deep)
 Clone a http server.
EjsAny*ejsClonePot(Ejs *ejs, EjsAny *src, bool deep)
 Copy an object.
EjsRequest*ejsCloneRequest(Ejs *ejs, EjsRequest *req, bool deep)
 Clone a request into another interpreter.
Ejs*ejsCloneVM(Ejs *ejs)
 Clone an ejs virtual machine.
EjsAny*ejsCoerceOperands(Ejs *ejs, EjsObj *lhs, int opcode, EjsObj *rhs)
 Cast the operands as required by the operation code.
intejsCompactPot(Ejs *ejs, EjsPot *obj)
 Compact an object.
intejsCompareAsc(Ejs *ejs, EjsString *s1, cchar *s2)
 Compare a string with a multibyte string.
intejsCompareString(Ejs *ejs, EjsString *s1, EjsString *s2)
 Compare two strings.
intejsCompareSubstring(Ejs *ejs, EjsString *s1, EjsString *s2, ssize offset, ssize len)
 Compare a substring.
intejsCompareWide(Ejs *ejs, EjsString *s1, MprChar *s2, ssize len)
 Compare a string with a wide string.
EjsType*ejsConfigureType(Ejs *ejs, EjsType *type, struct EjsModule *up, EjsType *baseType, int numTypeProp, int numInstanceProp, int64 attributes)
 Configure a type.
intejsContainsAsc(Ejs *ejs, EjsString *sp, cchar *pat)
 Test if a string contains an ascii substring.
intejsContainsChar(Ejs *ejs, EjsString *sp, int charPat)
 Test if a string contains a character.
intejsContainsString(Ejs *ejs, EjsString *sp, EjsString *pat)
 Test if a string contains another string.
ssizeejsCopyToByteArray(Ejs *ejs, EjsByteArray *ba, ssize offset, cchar *data, ssize length)
 Copy data into a byte array.
EjsPot*ejsCreateActivation(Ejs *ejs, EjsFunction *fun, int numSlots)
 Create an activation record for a function.
EjsType*ejsCreateArchetype(Ejs *ejs, struct EjsFunction *fun, EjsPot *prototype)
 Create an Archetype.
EjsArray*ejsCreateArray(Ejs *ejs, int size)
 Create an array.
EjsFunction*ejsCreateBareFunction(Ejs *ejs, EjsString *name, int attributes)
 Create a bare function.
EjsString*ejsCreateBareString(Ejs *ejs, ssize len)
 Create an empty string object.
EjsBoolean*ejsCreateBoolean(Ejs *ejs, int value)
 Create a boolean.
EjsByteArray*ejsCreateByteArray(Ejs *ejs, ssize size)
 Create a byte array.
EjsCode*ejsCreateCode(Ejs *ejs, EjsFunction *fun, struct EjsModule *module, cuchar *byteCode, ssize len, EjsDebug *debug)
 Create a code block.
EjsType*ejsCreateCoreType(Ejs *ejs, EjsName qname, int size, int slotNum, int numTypeProp, void *manager, int64 attributes)
 Create a core type object.
EjsDate*ejsCreateDate(Ejs *ejs, MprTime value)
 Create a new date instance.
EjsAny*ejsCreateEmptyPot(Ejs *ejs)
 Create an empty property object.
EjsError*ejsCreateError(Ejs *ejs, struct EjsType *type, EjsObj *message)
 Create an error object.
EjsFile*ejsCreateFile(Ejs *ejs, cchar *filename)
 Create a File object.
EjsFile*ejsCreateFileFromFd(Ejs *ejs, int fd, cchar *name, int mode)
 Create a file object from an O/S file descriptor.
EjsFileSystem*ejsCreateFileSystem(Ejs *ejs, cchar *path)
 Create a FileSystem object.
EjsFunction*ejsCreateFunction(Ejs *ejs, EjsString *name, cuchar *code, int codeLen, int numArgs, int numDefault, int numExceptions, struct EjsType *returnType, int attributes, struct EjsModule *module, EjsBlock *scope, int strict)
 Create a function object.
EjsHttp*ejsCreateHttp(Ejs *ejs)
 Create a new Http object.
EjsAny*ejsCreateInstance(Ejs *ejs, struct EjsType *type, int argc, void *argv)
 Create a new variable instance.
EjsIterator*ejsCreateIterator(Ejs *ejs, EjsAny *target, void *next, bool deep, EjsArray *namespaces)
 Create an iterator object.
EjsNamespace*ejsCreateNamespace(Ejs *ejs, EjsString *name)
 Create a namespace object.
EjsNull*ejsCreateNull(Ejs *ejs)
 Create the null object.
EjsNumber*ejsCreateNumber(Ejs *ejs, MprNumber value)
 Create a number object.
EjsAny*ejsCreateObj(Ejs *ejs, struct EjsType *type, int numSlots)
 Create a variable.
EjsPath*ejsCreatePath(Ejs *ejs, EjsString *path)
 Create a Path object.
EjsPath*ejsCreatePathFromAsc(Ejs *ejs, cchar *path)
 Create a Path object.
EjsPool*ejsCreatePool(int poolMax, cchar *templateScript, cchar *startScript, cchar *startScriptPath, char *home)
 Create a pool for virutal machines.
EjsAny*ejsCreatePot(Ejs *ejs, struct EjsType *type, int size)
 Create an object instance of the specified type.
voidejsCreatePotHelpers(Ejs *ejs)
 Create the Pot helpers.
EjsObj*ejsCreatePrototype(Ejs *ejs, EjsType *type, int numProp)
 Create a type prototype.
EjsRegExp*ejsCreateRegExp(Ejs *ejs, EjsString *pattern)
 Create a new regular expression object.
EjsRequest*ejsCreateRequest(Ejs *ejs, EjsHttpServer *server, HttpConn *conn, cchar *dir)
 Create a new request.
EjsNamespace*ejsCreateReservedNamespace(Ejs *ejs, EjsName *typeName, EjsString *name)
 Create a reserved namespace.
struct EjsArray*ejsCreateSearchPath(Ejs *ejs, cchar *searchPath)
 Create a search path array.
EjsSocket*ejsCreateSocket(Ejs *ejs)
 Create a new Socket object.
EjsString*ejsCreateString(Ejs *ejs, MprChar *value, ssize len)
 Create a string object.
EjsString*ejsCreateStringFromAsc(Ejs *ejs, cchar *value)
 Create a string from ascii.
EjsString*ejsCreateStringFromBytes(Ejs *ejs, cchar *value, ssize len)
 Create a string from an ascii block.
EjsString*ejsCreateStringFromConst(Ejs *ejs, struct EjsModule *mp, int index)
 Create a string from a module string constant.
EjsString*ejsCreateStringFromMulti(Ejs *ejs, cchar *value, ssize len)
 Create a string from UTF-8 multibyte string.
EjsType*ejsCreateType(Ejs *ejs, EjsName name, struct EjsModule *up, EjsType *baseType, EjsPot *prototype, int slotNum, int numTypeProp, int numInstanceProp, int size, void *manager, int64 attributes)
 Create a new type object.
EjsVoid*ejsCreateUndefined(Ejs *ejs)
 Create the undefined object.
EjsUri*ejsCreateUri(Ejs *ejs, EjsString *uri)
 Create a Uri object.
EjsUri*ejsCreateUriFromAsc(Ejs *ejs, cchar *uri)
 Create a URI from an ascii path.
EjsUri*ejsCreateUriFromParts(Ejs *ejs, cchar *scheme, cchar *host, int port, cchar *path, cchar *query, cchar *reference, bool complete)
Ejs*ejsCreateVM(int argc, cchar **argv, int flags)
 Create an ejs virtual machine.
EjsWorker*ejsCreateWorker(Ejs *ejs)
 Create a worker.
EjsXML*ejsCreateXML(Ejs *ejs, int kind, EjsName name, EjsXML *parent, EjsString *value)
 Create an XML node object.
EjsXML*ejsCreateXMLList(Ejs *ejs, EjsXML *targetObject, EjsName targetProperty)
 Create an XML list object.
intejsDefineGlobalFunction(Ejs *ejs, EjsString *name, EjsProc fn)
 Define a global function.
intejsDefineInstanceProperty(Ejs *ejs, EjsType *type, int slotNum, EjsName name, EjsType *propType, int attributes, EjsAny *value)
 Define an instance property.
intejsDefineProperty(Ejs *ejs, EjsAny *obj, int slotNum, EjsName qname, struct EjsType *type, int64 attributes, EjsAny *value)
 Define a property.
EjsNamespace*ejsDefineReservedNamespace(Ejs *ejs, EjsBlock *block, EjsName *typeName, cchar *name)
 Define a reserved namespace on a block.
intejsDeleteProperty(Ejs *ejs, EjsAny *obj, int slotNum)
 Delete a property.
intejsDeletePropertyByName(Ejs *ejs, EjsAny *obj, EjsName qname)
 Delete a property by name.
EjsAny*ejsDeserialize(Ejs *ejs, struct EjsString *str)
 Deserialize a JSON encoded string.
voidejsDestroyIntern(struct EjsIntern *intern)
 Destroy the intern string cache.
intejsDestroySession(Ejs *ejs, EjsSession *session)
 Destroy as session.
voidejsDestroyVM(Ejs *ejs)
 Destroy an interpreter.
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.
EjsType*ejsFinalizeCoreType(Ejs *ejs, EjsName qname)
 Finalize a core type.
EjsType*ejsFinalizeScriptType(Ejs *ejs, EjsName qname, int size, void *manager, int64 attributes)
 Finalize a script type.
voidejsFixTraits(Ejs *ejs, EjsPot *obj)
 Fix traits.
EjsString*ejsFormatReservedNamespace(Ejs *ejs, EjsName *typeName, EjsString *spaceName)
 Format a reserved namespace name to create a unique namespace.
voidejsFreePoolVM(EjsPool *pool, Ejs *ejs)
 Free a VM back to the pool.
boolejsGetBoolean(Ejs *ejs, EjsAny *obj)
 Get the C boolean value from a boolean object.
ssizeejsGetByteArrayAvailableData(EjsByteArray *ba)
 Get the number of available bytes.
ssizeejsGetByteArrayRoom(EjsByteArray *ba)
 Determine the spare room in the byte array for more data.
MprTimeejsGetDate(Ejs *ejs, EjsDate *date)
 Get the numeric value stored in a EjsDate object.
doubleejsGetDouble(Ejs *ejs, EjsAny *obj)
 Get the numeric value stored in a EjsNumber object.
cchar*ejsGetErrorMsg(Ejs *ejs, int withStack)
 Get the interpreter error message.
EjsObj*ejsGetException(Ejs *ejs)
 Get the Ejs exception object for this interpreter.
EjsAny*ejsGetFirstItem(Ejs *ejs, EjsArray *ap)
 Get the first item from an array.
void*ejsGetHandle(Ejs *ejs)
 Get the hosting handle.
intejsGetHashSize(int numProp)
 Get the preferred hash size.
voidejsGetHttpLimits(Ejs *ejs, EjsObj *obj, HttpLimits *limits, bool server)
 Get a Http limits.
EjsAny*ejsGetImmutable(struct Ejs *ejs, int slotNum)
 Get an immutable object.
EjsAny*ejsGetImmutableByName(struct Ejs *ejs, EjsName qname)
 Get an immutable object by name.
intejsGetInt(Ejs *ejs, EjsAny *obj)
 Get the numeric value stored in a EjsNumber object.
int64ejsGetInt64(Ejs *ejs, EjsAny *obj)
 Get an 64 bit integer value equivalent to that stored in an EjsNumber object.
EjsAny*ejsGetItem(Ejs *ejs, EjsArray *ap, int index)
 Get an item from an array.
EjsAny*ejsGetLastItem(Ejs *ejs, EjsArray *ap)
 Get the last item from an array.
intejsGetLength(Ejs *ejs, EjsAny *obj)
 Get a count of properties in a variable.
EjsAny*ejsGetNextItem(Ejs *ejs, EjsArray *ap, int *next)
 Get the next item from an array.
MprNumberejsGetNumber(Ejs *ejs, EjsAny *obj)
 Get the numeric value stored in a EjsNumber object.
EjsNameejsGetPotPropertyName(Ejs *ejs, EjsPot *obj, int slotNum)
 Get a property name.
EjsAny*ejsGetPrevItem(Ejs *ejs, EjsArray *ap, int *prev)
 Get the previous item from an array.
EjsAny*ejsGetProperty(Ejs *ejs, EjsAny *obj, int slotNum)
 Get a property.
EjsAny*ejsGetPropertyByName(Ejs *ejs, EjsAny *obj, EjsName qname)
 Get a property by name.
EjsNameejsGetPropertyName(Ejs *ejs, EjsAny *obj, int slotNum)
 Get a variable property's name.
struct EjsTrait*ejsGetPropertyTraits(Ejs *ejs, EjsAny *obj, int slotNum)
 Get a property's traits.
EjsPot*ejsGetPrototype(Ejs *ejs, EjsAny *obj)
 Get the prototype object for an object.
EjsSession*ejsGetSession(Ejs *ejs, EjsString *key, MprTime timeout, int create)
 Get a session object for a given key.
EjsType*ejsGetType(Ejs *ejs, int slotNum)
 Get a type.
EjsType*ejsGetTypeByName(Ejs *ejs, EjsName qname)
 Get a type given its name.
EjsString*ejsGetTypeName(struct Ejs *ejs, EjsAny *obj)
 Get the type name of an object.
EjsString*ejsGetTypeOf(struct Ejs *ejs, EjsAny *obj)
 TypeOf operator.
EjsAny*ejsGetVarByName(Ejs *ejs, EjsAny *obj, EjsName name, EjsLookup *lookup)
 Get a variable by name.
EjsXML*ejsGetXMLDescendants(Ejs *ejs, EjsXML *xml, EjsName qname)
 Get the descendants of an XML node that match the given name.
ssizeejsGrowByteArray(Ejs *ejs, EjsByteArray *ba, ssize size)
 Grow the byte array.
intejsGrowPot(Ejs *ejs, EjsPot *obj, int numSlots)
 Grow a pot object.
boolejsHasException(Ejs *ejs)
 Determine if an exception has been thrown.
intejsIndexProperties(Ejs *ejs, EjsPot *obj)
 Make or remake a property index.
intejsInitFunction(Ejs *ejs, EjsFunction *fun, EjsString *name, cuchar *code, int codeLen, int numArgs, int numDefault, int numExceptions, struct EjsType *returnType, int attributes, struct EjsModule *module, EjsBlock *scope, int strict)
 Initialize a function object.
intejsInsertItem(Ejs *ejs, EjsArray *ap, int index, EjsAny *item)
 Insert an item.
intejsInsertPotProperties(Ejs *ejs, EjsPot *pot, int numSlots, int offset)
 Insert properties.
EjsString*ejsInternAsc(struct Ejs *ejs, cchar *value, ssize len)
 Intern a string object from an Ascii string.
EjsString*ejsInternMulti(struct Ejs *ejs, cchar *value, ssize len)
 Intern a string object from a UTF-8 string.
EjsString*ejsInternString(EjsString *sp)
 Intern a string object.
EjsString*ejsInternWide(struct Ejs *ejs, MprChar *value, ssize len)
 Intern a string object from a UTF-16 string.
EjsAny*ejsInvokeOperator(Ejs *ejs, EjsAny *obj, int opCode, EjsAny *rhs)
 Invoke an opcode on a native type.
EjsAny*ejsInvokeOperatorDefault(Ejs *ejs, EjsAny *obj, int opCode, EjsAny *rhs)
 Default implementation for operator invoke.
boolejsIs(Ejs *ejs, EjsAny *obj, void *name)
 Test the type of an object.
boolejsIsA(Ejs *ejs, EjsAny *target, EjsType *type)
 Test if an variable is an instance of a given type.
boolejsIsBlock(Ejs *ejs, EjsObj *obj)
 Determine if a variable is a block.
boolejsIsDefined(Ejs *ejs, EjsAny *obj)
 Test the object is not null and not undefined.
boolejsIsError(Ejs *ejs, EjsAny *obj)
 Test if the given object is an error instance.
boolejsIsFrame(Ejs *ejs, EjsAny *obj)
 Determine if a variable is a frame.
boolejsIsFunction(Ejs *ejs, EjsAny *obj)
 Determine if a variable is a function.
boolejsIsInfinite(MprNumber n)
 Test if a number is infinite.
boolejsIsInitializer(Ejs *ejs, EjsAny *obj)
 Determine if the function is an initializer.
boolejsIsNan(MprNumber n)
 Test if a value is not-a-number.
boolejsIsNativeFunction(Ejs *ejs, EjsAny *obj)
 Determine if the function is a native function.
boolejsIsPot(Ejs *ejs, EjsAny *obj)
 Determine if a variable is a Pot.
boolejsIsPrototype(Ejs *ejs, EjsAny *obj)
 Determine if a variable is a prototype object.
boolejsIsType(Ejs *ejs, EjsAny *obj)
 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.
boolejsIsXML(Ejs *ejs, EjsAny *obj)
 Determine if a variable is an XML object.
intejsJoinArray(Ejs *ejs, EjsArray *dest, EjsArray *src)
 Join an array.
EjsString*ejsJoinString(Ejs *ejs, EjsString *s1, EjsString *s2)
 Join two strings.
EjsString*ejsJoinStrings(Ejs *ejs, EjsString *src, ...)
 Join strings.
voidejsLoadHttpService(Ejs *ejs)
 Load the Http service.
intejsLoadModule(Ejs *ejs, EjsString *name, int minVer, int maxVer, int flags)
 Load a module.
intejsLoadModules(Ejs *ejs, cchar *search, MprList *require)
 Load modules into an interpreter.
intejsLoadScriptFile(Ejs *ejs, cchar *script, cchar *cache, int flags)
 Load a script from a file.
intejsLoadScriptLiteral(Ejs *ejs, EjsString *script, cchar *cache, int flags)
 Load a script from a string.
voidejsLoadXMLAsc(Ejs *ejs, EjsXML *xml, cchar *xmlString)
 Load an XML document from an Ascii string.
voidejsLoadXMLString(Ejs *ejs, EjsXML *xml, EjsString *xmlString)
 Load an XML document.
voidejsLog(Ejs *ejs, cchar *fmt, ...)
 Enter a message into the log file.
intejsLookupItem(Ejs *ejs, EjsArray *ap, EjsAny *item)
 Lookup an item in the array.
intejsLookupPotProperty(Ejs *ejs, EjsPot *obj, EjsName qname)
 Lookup a property in a Pot.
intejsLookupProperty(Ejs *ejs, EjsAny *obj, EjsName qname)
 Lookup a property by name.
intejsLookupScope(Ejs *ejs, EjsName name, EjsLookup *lookup)
 Lookup a variable using the current scope.
intejsLookupVar(Ejs *ejs, EjsAny *obj, EjsName name, EjsLookup *lookup)
 Lookup a variable.
intejsLookupVarWithNamespaces(Ejs *ejs, EjsAny *obj, EjsName name, EjsLookup *lookup)
 Lookup a variable in an object (only).
boolejsMakeRoomInByteArray(Ejs *ejs, EjsByteArray *ba, ssize require)
 Make room in the byte array for data.
voidejsManagePot(void *obj, int flags)
 Mark an object as currently in use.
voidejsMarkName(EjsName *qname)
 Mark a name for GC.
boolejsMatchName(Ejs *ejs, EjsName *a, EjsName *b)
 Test if two names match.
EjsNameejsName(struct Ejs *ejs, cchar *space, cchar *name)
 Initialize a Qualified Name structure.
struct EjsString*ejsObjToJSON(Ejs *ejs, EjsObj *obj, int argc, EjsObj **argv)
 Method proc for conversion to a JSON string.
struct EjsString*ejsObjToString(Ejs *ejs, EjsObj *obj, int argc, EjsObj **argv)
 Method proc for conversion to a string.
EjsAny*ejsParse(Ejs *ejs, MprChar *str, int prefType)
 Parse a string.
intejsPropertyHasTrait(Ejs *ejs, EjsAny *obj, int slotNum, int attributes)
 Test a property's traits.
EjsString*ejsRegExpToString(Ejs *ejs, EjsRegExp *rp)
 Get a string representation of a regular expression.
voidejsRemoveConstructor(Ejs *ejs, struct EjsType *type)
 Remove a constructor function from a type.
intejsRemoveItem(Ejs *ejs, EjsArray *ap, EjsAny *item)
 Remove an item from the array.
intejsRemoveItemAtPos(Ejs *ejs, EjsArray *ap, int index)
 Remove an item at a given index from the array.
intejsRemoveLastItem(Ejs *ejs, EjsArray *ap)
 Remove the last item from the array.
intejsRemoveObserver(Ejs *ejs, EjsObj *emitter, EjsObj *name, struct EjsFunction *observer)
 Remove an observer.
intejsRemovePotProperty(Ejs *ejs, EjsAny *obj, int slotNum)
 Remove a property.
voidejsRemoveWorkers(Ejs *ejs)
 Remove workers before exiting.
voidejsReportError(Ejs *ejs, char *fmt, ...)
 Report an error message using the MprLog error channel.
voidejsResetByteArray(Ejs *ejs, EjsByteArray *ba)
 Reset the byte.
intejsRun(Ejs *ejs)
 Run a script.
EjsAny*ejsRunFunction(Ejs *ejs, EjsFunction *fn, EjsAny *thisObj, int argc, void *argv)
 Run a function.
EjsAny*ejsRunFunctionByName(Ejs *ejs, EjsAny *container, EjsName qname, EjsAny *thisObj, int argc, void *argv)
 Run a function by name.
EjsAny*ejsRunFunctionBySlot(Ejs *ejs, EjsAny *obj, int slotNum, int argc, void *argv)
 Run a function by slot number.
EjsObj*ejsRunInitializer(Ejs *ejs, struct EjsModule *module)
 Run the initializer for a module.
intejsRunProgram(Ejs *ejs, cchar *className, cchar *methodName)
 Run a program.
char*ejsSearchForModule(Ejs *ejs, cchar *name, int minVer, int maxVer)
 Search for a module in the module search path.
intejsSendEvent(Ejs *ejs, EjsObj *emitter, cchar *name, EjsAny *thisObj, EjsAny *arg)
 Send an event to observers.
intejsSendEventv(Ejs *ejs, EjsObj *emitter, cchar *name, EjsAny *thisObj, int argc, void *argv)
 Send an event to observers.
EjsString*ejsSerialize(Ejs *ejs, EjsAny *obj, int flags)
 Serialize a variable into JSON format.
EjsString*ejsSerializeWithOptions(Ejs *ejs, EjsAny *obj, EjsObj *options)
 Serialize a variable into JSON format.
voidejsSetByteArrayPositions(Ejs *ejs, EjsByteArray *ba, ssize readPosition, ssize writePosition)
 Set the I/O byte array positions.
voidejsSetDispatcher(Ejs *ejs, MprDispatcher *dispatcher)
 Set the MPR dispatcher to use for an interpreter.
intejsSetFunctionCode(Ejs *ejs, EjsFunction *fun, struct EjsModule *module, cuchar *byteCode, ssize len, EjsDebug *debug)
 Set the byte code for a function.
voidejsSetHttpLimits(Ejs *ejs, HttpLimits *limits, EjsObj *obj, bool server)
 Set a Http limits.
intejsSetPathAttributes(Ejs *ejs, cchar *path, EjsObj *options)
 Set the owner, group and permissions of a file.
intejsSetProperty(Ejs *ejs, void *obj, int slotNum, void *value)
 Set a property's value.
intejsSetPropertyByName(Ejs *ejs, void *obj, EjsName qname, void *value)
 Set a property's value.
intejsSetPropertyName(Ejs *ejs, EjsAny *obj, int slotNum, EjsName qname)
 Set a property's name.
intejsSetPropertyTraits(Ejs *ejs, EjsAny *obj, int slotNum, struct EjsType *type, int attributes)
 Set a property's traits.
voidejsSetSearchPath(Ejs *ejs, struct EjsArray *search)
 Set the module search path.
voidejsSetSessionTimeout(Ejs *ejs, EjsSession *sp, MprTime lifespan)
 Set a session timeout.
EjsXML*ejsSetXMLElement(Ejs *ejs, EjsXML *xml, int index, EjsXML *node)
 Set an indexed element to a value.
intejsSetupHttpTrace(Ejs *ejs, HttpTrace *trace, EjsObj *options)
 Setup tracing for Http transactions.
EjsString*ejsSprintf(Ejs *ejs, cchar *fmt, ...)
 Format arguments.
intejsStartsWithAsc(Ejs *ejs, EjsString *sp, cchar *pat)
 Test if a string starts with an ascii pattern.
EjsString*ejsSubstring(Ejs *ejs, EjsString *src, ssize offset, ssize len)
 Get a substring.
EjsError*ejsThrowArgError(Ejs *ejs, cchar *fmt, ...)
 Throw an argument exception.
EjsError*ejsThrowArithmeticError(Ejs *ejs, cchar *fmt, ...)
 Throw an math exception.
EjsError*ejsThrowAssertError(Ejs *ejs, cchar *fmt, ...)
 Throw an assertion exception.
EjsError*ejsThrowError(Ejs *ejs, cchar *fmt, ...)
 Throw an general error exception.
EjsAny*ejsThrowException(Ejs *ejs, EjsAny *error)
 Throw an exception.
EjsError*ejsThrowIOError(Ejs *ejs, cchar *fmt, ...)
 Throw an IO exception.
EjsError*ejsThrowInstructionError(Ejs *ejs, cchar *fmt, ...)
 Throw an instruction code exception.
EjsError*ejsThrowInternalError(Ejs *ejs, cchar *fmt, ...)
 Throw an internal error exception.
EjsError*ejsThrowMemoryError(Ejs *ejs)
 Throw an Memory depletion exception.
EjsError*ejsThrowOutOfBoundsError(Ejs *ejs, cchar *fmt, ...)
 Throw an out of bounds exception.
EjsError*ejsThrowReferenceError(Ejs *ejs, cchar *fmt, ...)
 Throw an reference exception.
EjsError*ejsThrowResourceError(Ejs *ejs, cchar *fmt, ...)
 Throw an resource exception.
EjsError*ejsThrowStateError(Ejs *ejs, cchar *fmt, ...)
 Throw an state exception.
EjsObj*ejsThrowStopIteration(Ejs *ejs)
 Throw an stop iteration exception.
EjsString*ejsThrowString(Ejs *ejs, cchar *fmt, ...)
 Throw a string message.
EjsError*ejsThrowSyntaxError(Ejs *ejs, cchar *fmt, ...)
 Throw an syntax error exception.
EjsError*ejsThrowTypeError(Ejs *ejs, cchar *fmt, ...)
 Throw an type error exception.
EjsBoolean*ejsToBoolean(Ejs *ejs, EjsAny *obj)
 Cast a variable to a boolean.
EjsString*ejsToJSON(Ejs *ejs, EjsAny *obj, EjsObj *options)
 Convert a variable to a string in JSON format.
EjsString*ejsToLiteralString(Ejs *ejs, EjsObj *obj)
 Convert a string to a literal string style representation.
EjsString*ejsToLower(Ejs *ejs, EjsString *sp)
 Convert a string to lower case.
char*ejsToMulti(Ejs *ejs, void *obj)
 Convert an object to a UTF-8 string representation.
struct EjsNumber*ejsToNumber(Ejs *ejs, EjsAny *obj)
 Cast a variable to a number.
EjsPath*ejsToPath(Ejs *ejs, EjsAny *obj)
 Convert the object to a Path.
EjsString*ejsToString(Ejs *ejs, EjsAny *obj)
 Cast a variable to a string.
EjsString*ejsToUpper(Ejs *ejs, EjsString *sp)
 Convert a string to upper case.
EjsUri*ejsToUri(Ejs *ejs, EjsAny *obj)
 Convert an object to a URI.
EjsString*ejsTruncateString(Ejs *ejs, EjsString *src, ssize len)
 Truncate a string.
voidejsUnblockGC(Ejs *ejs, int blocked)
 Unblock garbage collection.
EjsNameejsWideName(struct Ejs *ejs, MprChar *space, MprChar *name)
 Initialize a Qualified Name structure using a wide namespace and name.
struct EjsNumber*ejsWriteToByteArray(Ejs *ejs, EjsByteArray *ba, int argc, EjsObj **argv)
 Write data to the byte array This implements the ByteArray.write function.
intejsXMLToBuf(Ejs *ejs, MprBuf *buf, EjsXML *xml, int indentLevel)
 Convert an xml node to string representation in a buffer.

Typedefs

EjsCodeByte code.
EjsConstantsConstant pool for module files.
EjsDebugDebug record for module files.
EjsExException Handler Record.
EjsHashProperty hash linkage.
EjsHelpersAllocation and Type Helpers.
EjsInternInterned string hash shared over all interpreters.
EjsLineSymbolic debugging storage for source code in module files.
EjsLookupLookup State.
EjsNativeCallbackNative module initialization callback.
EjsObjNative Function signature.
EjsPropertiesObject properties.
EjsServiceEjscript Service structure.
EjsSlotProperty slot structure.
EjsStateVM Evaluation state.
EjsTraitProperty traits.
EjsXmlTagStateXml tag state.

Defines

#define_h_EJS_WEB_h   1
 ejsWeb.h — Header for the Ejscript Web Framework Copyright (c) All Rights Reserved.
#defineBLD_FEATURE_NUM_TYPE   double
 Configured numeric type.
#defineEBC_POPN   101
 ejsByteCodeTable.h - Master Byte Code Table.
#defineEC_BUFSIZE   4096
 General buffer size.
#defineEC_CODE_BUFSIZE   4096
 Initial size of code gen buffer.
#defineEC_FLAGS_BIND   0x1
 ejsLoad flags to bind global references and type/object properties.
#defineEC_FLAGS_DEBUG   0x2
 ejsLoad flags to generate symbolic debugging information.
#defineEC_FLAGS_DOC   0x100
 ejsLoad flags to parse inline doc.
#defineEC_FLAGS_MERGE   0x8
 ejsLoad flags to merge all output onto one output file.
#defineEC_FLAGS_NO_OUT   0x10
 ejsLoad flags discard all output.
#defineEC_FLAGS_PARSE_ONLY   0x20
 ejsLoad flags to only parse source.
#defineEC_FLAGS_THROW   0x40
 ejsLoad flags to throw errors when compiling.
#defineEC_FLAGS_VISIBLE   0x80
 ejsLoad flags to make global vars visible to all.
#defineEC_LINE_INCR   1024
 Growth increment for input lines.
#defineEC_MAX_ERRORS   25
 Max compilation errors before giving up.
#defineEC_MAX_INCLUDE   32
 Max number of nested includes.
#defineEC_NUM_PAK_PROP   32
 Initial number of properties.
#defineEC_TOKEN_INCR   64
 Growth increment for tokens.
#defineEJS_ARENA_SIZE   ((1 * 1024 * 1024) - MPR_HEAP_OVERHEAD)
 Initial virt memory for objects.
#defineEJS_BLEND_DEEP   0x1
 Flag for ejsBlendObject to copy nested object recursively.
#defineEJS_BLEND_FUNCTIONS   0x2
 Flag for ejsBlendObject to copy function properties.
#defineEJS_BLEND_OVERWRITE   0x4
 Flag for ejsBlendObject to overwrite existing properties.
#defineEJS_BLEND_PRIVATE   0x10
 Flag for ejsBlendObject to copy private properties.
#defineEJS_BLEND_SUBCLASSES   0x8
 Flag for ejsBlendObject to copy subclassed properties.
#defineEJS_BLEND_TRACE   0x20
 Flag for ejsBlendObject to trace blend operations to the log.
#defineEJS_CODE_MAGIC   0x91917128
 Code record integrity check.
#defineEJS_DEBUG_INCR   16
 Growth increment for EjsDebug
#defineEJS_DEBUG_MAGIC   0x78654423
 Debug record integrity check.
#defineEJS_DIR_PERMS   0775
 Default dir perms.
#defineEJS_DOC_HASH_SIZE   1007
 Hash for doc descriptions.
#defineEJS_EX_CATCH   0x1
 EjsEx flag for a catch block.
#defineEJS_EX_FINALLY   0x2
 EjsEx flag for a finally block.
#defineEJS_EX_INC   4
 Growth increment for exception handlers.
#defineEJS_EX_ITERATION   0x4
 EjsEx flag for an iteration catch block.
#defineEJS_FILE_PERMS   0664
 Default file perms.
#defineEJS_FLAG_DOC   0x40
 Load documentation from modules.
#defineEJS_FLAG_EVENT   0x1
 Event pending.
#defineEJS_FLAG_HOSTED   0x400
 Interp is hosted in a web server.
#defineEJS_FLAG_NO_INIT   0x8
 Don't initialize any modules.
#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_FUN_CONSTRUCTOR   0x2000
 Method is a constructor.
#defineEJS_FUN_FULL_SCOPE   0x4000
 Function needs closure when defined.
#defineEJS_FUN_HAS_RETURN   0x8000
 Function has a return statement.
#defineEJS_FUN_INITIALIZER   0x10000
 Type initializer code.
#defineEJS_FUN_MODULE_INITIALIZER   0x40000
 Module initializer.
#defineEJS_FUN_OVERRIDE   0x20000
 Override base type.
#defineEJS_FUN_REST_ARGS   0x80000
 Parameter is a "..." rest.
#defineEJS_HASH_MIN_PROP   8
 Min props to hash.
#defineEJS_INC_ARGS   8
 Frame stack increment.
#defineEJS_INDEX_INCR   256
 Constant pool growth increment.
#defineEJS_JSON_SHOW_HIDDEN   0x2
 ejsSerialize flag to include hidden properties.
#defineEJS_JSON_SHOW_NAMESPACES   0x4
 ejsSerialize flag to include namespaces in names.
#defineEJS_JSON_SHOW_PRETTY   0x8
 ejsSerialize flag to render in human-readible multiline format.
#defineEJS_JSON_SHOW_SUBCLASSES   0x1
 ejsSerialize flag to include subclass properties.
#defineEJS_LOADER_BUILTIN   0x8
 Loading builtins.
#defineEJS_LOADER_DEP   0x10
 Loading a dependency.
#defineEJS_LOADER_ETERNAL   0x4
 Make all loaded types eternal.
#defineEJS_LOADER_NO_INIT   0x2
 Load module code in strict mode.
#defineEJS_LOADER_RELOAD   0x20
 Force a reload if already loaded.
#defineEJS_LOADER_STRICT   0x1
 Load module code in strict mode.
#defineEJS_LOTSA_PROP   256
 Object with lots of properties.
#defineEJS_MAX_ARGS   8192
 Max number of args.
#defineEJS_MAX_BASE_CLASSES   256
 Max inheritance chain.
#defineEJS_MAX_COLLISIONS   4
 Max intern string collion chain.
#defineEJS_MAX_EXCEPTIONS   8192
 Max number of exceptions.
#defineEJS_MAX_LOCALS   (10*1024)
 Max number of locals.
#defineEJS_MAX_OBJ_POOL   512
 Maximum number of objects per type to cache.
#defineEJS_MAX_POOL   (4*1024*1024)
 Size of constant pool.
#defineEJS_MAX_RECURSION   10000
 Maximum recursion.
#defineEJS_MAX_REGEX_MATCHES   32
 Maximum regular sub-expressions.
#defineEJS_MAX_SQLITE_MEM   (2*1024*1024)
 Maximum buffering for Sqlite.
#defineEJS_MAX_TRAITS   (0x7fff)
 Max number of declared properties per block.
#defineEJS_MAX_TYPE   256
 Maximum number of types.
#defineEJS_MIN_FRAME_SLOTS   16
 Miniumum number of slots for function frames.
#defineEJS_NUM_GLOBAL   256
 Number of globals slots to pre-create.
#defineEJS_POOL_INACTIVITY_TIMEOUT   (60 * 1000)
 Prune inactive pooled VMs older than this.
#defineEJS_PROP_ENUMERABLE   0x1000
 Property will be enumerable (compiler use only).
#defineEJS_PROP_HAS_VALUE   0x200
 Property has a value record.
#defineEJS_PROP_NATIVE   0x400
 Property is backed by native code.
#defineEJS_PROP_STATIC   0x800
 Class static property.
#defineEJS_ROUND_PROP   16
 Rounding for growing properties.
#defineEJS_SESSION   "-ejs-session-"
 Default session cookie string.
#defineEJS_SESSION_TIMER_PERIOD   (60 * 1000)
 Timer checks ever minute.
#defineEJS_SQLITE_TIMEOUT   30000
 Database busy timeout.
#defineEJS_STACK_MAX   (1024 * 32)
 Stack size without MMU.
#defineEJS_STREAM_BOTH   0x3
 Http constant Stream.Both.
#defineEJS_STREAM_READ   0x1
 Http constant Stream.Read.
#defineEJS_STREAM_WRITE   0x2
 Http constant Stream.Write.
#defineEJS_TRAIT_CAST_NULLS   0x1
 Property casts nulls.
#defineEJS_TRAIT_DELETED   0x2
 Property has been deleted.
#defineEJS_TRAIT_FIXED   0x8
 Property is not configurable.
#defineEJS_TRAIT_GETTER   0x4
 Property is a getter.
#defineEJS_TRAIT_HIDDEN   0x10
 !Enumerable.
#defineEJS_TRAIT_INITIALIZED   0x20
 Readonly property has been initialized.
#defineEJS_TRAIT_MASK   0xFFFFF
 Mask of trait attributes.
#defineEJS_TRAIT_READONLY   0x40
 !Writable (used for const).
#defineEJS_TRAIT_SETTER   0x80
 Property is a settter.
#defineEJS_TRAIT_THROW_NULLS   0x100
 Property rejects null.
#defineEJS_TYPE_BLOCK   0x40000000
 Type is using block helpers.
#defineEJS_TYPE_CALLS_SUPER   0x100000
 Constructor calls super().
#defineEJS_TYPE_DYNAMIC_INSTANCES   0x400000
 Instances are not sealed and can add properties.
#defineEJS_TYPE_FINAL   0x800000
 Type can't be subclassed.
#defineEJS_TYPE_FIXUP   0x1000000
 Type needs to inherit base types properties.
#defineEJS_TYPE_HAS_CONSTRUCTOR   0x2000000
 Type has a constructor.
#defineEJS_TYPE_HAS_INSTANCE_VARS   0x200000
 Type has non-method instance vars (state).
#defineEJS_TYPE_HAS_TYPE_INITIALIZER   0x4000000
 Type has an initializer.
#defineEJS_TYPE_IMMUTABLE_INSTANCES   UINT64(0x200000000)
 Type has immutable instances.
#defineEJS_TYPE_INTERFACE   0x8000000
 Type is an interface.
#defineEJS_TYPE_MUTABLE   0x80000000
 Type is mutable.
#defineEJS_TYPE_MUTABLE_INSTANCES   UINT64(0x100000000)
 Type has mutable instances.
#defineEJS_TYPE_NUMERIC_INDICIES   UINT64(0x800000000)
 Type is using numeric indicies for properties.
#defineEJS_TYPE_OBJ   0x10000000
 Type is using object helpers.
#defineEJS_TYPE_POT   0x20000000
 Type is using pot helpers.
#defineEJS_TYPE_VIRTUAL_SLOTS   UINT64(0x400000000)
 Type is unsing virtual slots.
#defineEJS_WORK_QUOTA   1024
 Allocations required before garbage colllection.
#defineEJS_WORKER_BEGIN   1
 Worker state before starting.
#defineEJS_WORKER_CLOSED   3
 Worker state when finished.
#defineEJS_WORKER_COMPLETE   4
 Worker state when completed all messages.
#defineEJS_WORKER_STARTED   2
 Worker state once started a script.
#defineEJS_XML_ATTRIBUTE   3
 XML node is an attribute.
#defineEJS_XML_BUF_MAX   (256 * 1024)
 Max XML document size.
#defineEJS_XML_COMMENT   5
 XML node is a comment.
#defineEJS_XML_ELEMENT   2
 XML node is an element.
#defineEJS_XML_LIST   1
 XML node is a list.
#defineEJS_XML_MAX_NODE_DEPTH   64
 Max nesting of tags.
#defineEJS_XML_PROCESSING   6
 XML node is a processing instruction.
#defineEJS_XML_TEXT   4
 XML node is text.

Ejs

Ejs

Ejsript VM Structure.

Description:
The Ejs structure contains the state for a single interpreter. The ejsCreateVM routine may be used to create multiple interpreters and returns a reference to be used in subsequent Ejscript API calls.
API Stability:
Evolving.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
Fields:
intargc Count of command line args.
cchar **argv Command line args (not alloced).
cchar *bootSearch Module search when bootstrapping the VM (not alloced).
cchar *className Name of a specific class to run for a program.
uintcompiling Currently executing the compiler.
uintconfigSet Config properties defined.
uintdestroying Interpreter is being destroyed.
MprDispatcher *dispatcher Event dispatcher.
MprHash *doc Documentation.
uintdontExit Prevent App.exit() from exiting.
uintempty Interpreter will be created empty.
char *errorMsg Error message.
EjsAny *exception Pointer to exception object.
EjsAny *exceptionArg Exception object for catch block.
uintexiting VM should exit.
intexitStatus Status to exit().
intfirstGlobal First global to examine for GC.
intflags Execution flags.
intgc GC required (don't make bit field).
EjsAny *global The "global" object.
uinthasError Interpreter has an initialization error.
uinthosted Interp is hosted (webserver).
char *hostedHome Home directory for hosted HttpServer.
Http *http Http service object (copy of EjsService.http).
void *httpServer HttpServer instance when VM is embedded.
MprList *httpServers Configured HttpServers.
uintinitialized Interpreter fully initialized and not empty.
intjoining In Worker.join.
void *loadData Arg to load callbacks.
cchar *methodName Name of a specific method to run for a program.
MprList *modules Loaded modules.
MprMutex *mutex Multithread locking.
char *name Unique interpreter name.
EjsAny *result Last expression result.
struct EjsArray *search Module load search path.
intserializeDepth Serialization depth.
struct EjsService *service Back pointer to the service.
intspreadArgs Count of spread args.
void *sqlite Sqlite context information.
struct EjsState *state Current evaluation state and stack.
MprList *workers Worker interpreters.
int ejsAddImmutable (struct Ejs *ejs, int slotNum, EjsName qname, EjsAny *obj)

Add an immutable reference.

Description:
Ejscript keeps a set of immutable objects that are shared across virtual machines. This call adds an object to that set. If the object already exists in the immutable set, its slot number if returned.
Parameters:
ejsEjs reference returned from ejsCreateVM
slotNumUnique slot number for the object.
qnameQualified name for the object.
objObject to store.
Returns:
The actual slot number allocated for the object.
See Also:
ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
int ejsBlockGC (Ejs *ejs)

Block garbage collection.

Description:
Garbage collection requires cooperation from threads. However, the VM will normally permit garbage collection at various points in the execution of byte code. This call block garbage collection while allowing program execution to continue. This is useful for short periods when transient objects are not reachable by the GC marker.
Parameters:
ejsInterpeter object returned from ejsCreateVM
Returns:
The previous GC blocked state.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
Ejs * ejsCloneVM (Ejs *ejs)

Clone an ejs virtual machine.

Description:
Create a virtual machine interpreter boy cloning an existing interpreter. Cloning is a fast way to create a new interpreter. This saves memory and speeds initialization.
Parameters:
ejsBase VM upon which to base the new VM.
Returns:
A new interpreter.
See Also:
ejsAddImmutable, ejsClearException, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
Ejs * ejsCreateVM (int argc, cchar **argv, int flags)

Create an ejs virtual machine.

Description:
Create a virtual machine interpreter object to evalute Ejscript programs. Ejscript supports multiple interpreters.
Parameters:
argcCount of command line argumements in argv.
argvCommand line arguments.
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_DOC - Load documentation from modules
  • EJS_FLAG_NOEXIT - App should service events and not exit unless explicitly instructed
Returns:
A new interpreter.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
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:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
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:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
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:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
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 ejsCreateVM
statusReserved and ignored.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
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 ejsCreateVM
Returns:
Hosting handle.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
EjsAny * ejsGetImmutable (struct Ejs *ejs, int slotNum)

Get an immutable object.

Description:
Ejscript keeps a set of immutable objects that are shared across virtual machines. This call retrieves an immutable object from that set.
Parameters:
ejsEjs reference returned from ejsCreateVM
slotNumUnique slot number for the object.
Returns:
Obj Immutable object found at the given slotNum.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
EjsAny * ejsGetImmutableByName (struct Ejs *ejs, EjsName qname)

Get an immutable object by name.

Description:
Ejscript keeps a set of immutable objects that are shared across virtual machines. This call retrieves an immutable object from that set.
Parameters:
ejsEjs reference returned from ejsCreateVM
qnameQualified name for the object.
Returns:
Obj Immutable object found at the given slotNum.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
EjsAny * ejsGetVarByName (Ejs *ejs, EjsAny *obj, EjsName name, EjsLookup *lookup)

Get a variable by name.

Description:
This looks for a property name in an object, its prototype or base classes.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to search.
nameProperty name to search for.
lookupLookup residuals.
Returns:
The variable.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
int ejsLoadScriptFile (Ejs *ejs, cchar *script, cchar *cache, int flags)

Load a script from a file.

Description:
This will read a script from a file, compile it and run. If the cache path argument is provided, the compiled module will be saved to this path.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
scriptScript pathname.
cacheCache pathname to save compiled module.
flagsCompilation control flags. Select from:
  • EC_FLAGS_BIND - Bind global references and type/object properties
  • EC_FLAGS_DEBUG - Generate symbolic debugging information
  • EC_FLAGS_MERGE - Merge all output onto one output file
  • EC_FLAGS_NO_OUT - Discard all output
  • EC_FLAGS_PARSE_ONLY - Only parse source. Don't generate code
  • EC_FLAGS_THROW - Throw errors when compiling. Used for eval()
  • EC_FLAGS_VISIBLE - Make global vars visible to all
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
int ejsLoadScriptLiteral (Ejs *ejs, EjsString *script, cchar *cache, int flags)

Load a script from a string.

Description:
This will compile the script string and then run it. If the cache path argument is provided, the compiled module will be saved to this path.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
scriptScript string.
cacheCache pathname to save compiled module.
flagsCompilation control flags. Select from:
  • EC_FLAGS_BIND - Bind global references and type/object properties
  • EC_FLAGS_DEBUG - Generate symbolic debugging information
  • EC_FLAGS_MERGE - Merge all output onto one output file
  • EC_FLAGS_NO_OUT - Discard all output
  • EC_FLAGS_PARSE_ONLY - Only parse source. Don't generate code
  • EC_FLAGS_THROW - Throw errors when compiling. Used for eval()
  • EC_FLAGS_VISIBLE - Make global vars visible to all
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
int ejsLookupScope (Ejs *ejs, EjsName name, EjsLookup *lookup)

Lookup a variable using the current scope.

Description:
This looks for a property name in the current lexical scope.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
nameProperty name to search for.
lookupLookup residuals.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
int ejsLookupVar (Ejs *ejs, EjsAny *obj, EjsName name, EjsLookup *lookup)

Lookup a variable.

Description:
This looks for a property name in an object, its prototype or base classes. If name.space is null, the variable is searched using the set of currently open namespaces.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to search.
nameProperty name to search for.
lookupLookup residuals.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
int ejsLookupVarWithNamespaces (Ejs *ejs, EjsAny *obj, EjsName name, EjsLookup *lookup)

Lookup a variable in an object (only).

Description:
This looks for a property name in an object, its prototype or base classes. If name.space is null, the variable is searched using the set of currently open namespaces.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to search.
nameProperty name to search for.
lookupLookup residuals.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
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 ejsCreateVM
fmtIs an alternate printf style format to emit if the interpreter has no valid error message.
...Arguments for fmt.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
int ejsRun (Ejs *ejs)

Run a script.

Description:
Run a script that has previously ben compiled by ecCompile.
Parameters:
ejsInterpeter object returned from ejsCreateVM
Returns:
Zero if successful, otherwise a non-zero Mpr error code.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
void ejsSetDispatcher (Ejs *ejs, MprDispatcher *dispatcher)
EjsAny * ejsThrowException (Ejs *ejs, EjsAny *error)

Throw an exception.

Description:
Throw an exception object.
Parameters:
ejsInterpeter object returned from ejsCreateVM
errorException argument object.
Returns:
The exception argument for chaining.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath
void ejsUnblockGC (Ejs *ejs, int blocked)

Unblock garbage collection.

Description:
Unblock garbage collection that was blocked via ejsBlockGC
Parameters:
ejsInterpeter object returned from ejsCreateVM
blockedBlocked state to re-establish.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException

EjsArray

EjsArray

Array class.

Description:
Arrays provide a resizable, 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 EjsObj and has all the capabilities of EjsObj
API Stability:
Evolving.
See Also:
ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
Fields:
EjsObj **data Array elements.
intlength Array length property.
EjsPotpot Property storage.
int ejsAddItem (Ejs *ejs, EjsArray *ap, EjsAny *item)

Add an item to the array.

Description:
This will add a new item to the end of the array and grow the array if required.
Parameters:
ejsEjs reference returned from ejsCreateVM
apArray to modify.
itemObject item to add.
Returns:
The item index in the array.
See Also:
EjsArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
void ejsClearArray (Ejs *ejs, EjsArray *ap)

Clear an array and remove all items.

Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to modify.
See Also:
EjsArray, ejsAddItem, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
EjsArray * ejsCloneArray (Ejs *ejs, EjsArray *ap, bool deep)

Clone an array.

Description:
This will create a new array and copy the contents from the source array. Both array elements and object properties are copied. If deep is true, the call creates a distinct clone with no shared elements. If deep is false, object references will be copied and shared between the source and cloned array.
Parameters:
ejsEjs reference returned from ejsCreateVM
apArray source.
deepSet to true to clone each element of the array. Otherwise object references will have their references copied and not the reference targets.
Returns:
A new array.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
EjsArray * ejsCreateArray (Ejs *ejs, int size)

Create an array.

Parameters:
ejsEjs reference returned from ejsCreateVM
sizeInitial size of the array.
Returns:
A new array object.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
EjsAny * ejsGetFirstItem (Ejs *ejs, EjsArray *ap)

Get the first item from an array.

Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to examine.
Returns:
The item.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
EjsAny * ejsGetItem (Ejs *ejs, EjsArray *ap, int index)

Get an item from an array.

Description:
This will retrieve the item at the index location.
Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to examine.
indexLocation to retrieve.
Returns:
The item.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
EjsAny * ejsGetLastItem (Ejs *ejs, EjsArray *ap)

Get the last item from an array.

Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to examine.
Returns:
The item.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
EjsAny * ejsGetNextItem (Ejs *ejs, EjsArray *ap, int *next)

Get the next item from an array.

Description:
This will retrieve the item at *next and increment *next.
Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to examine.
nextPointer to an integer index. The *next location is updated to prepare to advance to the next element. The *next location should be initialized to zero for the first call to an ejsGetNextItem sequence.
Returns:
The item.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
EjsAny * ejsGetPrevItem (Ejs *ejs, EjsArray *ap, int *prev)

Get the previous item from an array.

Description:
This will retrieve the item at *prev and increment *prev.
Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to examine.
prevPointer to an integer index. The *prev location is updated to prepare to advance to the previous element. The *prev location should be initialized to zero for the first call to an ejsGetPrevItem sequence.
Returns:
The item.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
int ejsInsertItem (Ejs *ejs, EjsArray *ap, int index, EjsAny *item)

Insert an item.

Description:
This will insert an item at the given index. Items at the index and above will be moved upward to make room for the inserted item.
Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to modify.
indexIndex at which to insert the item. The item will be inserted at the "index" position.
itemItem to insert.
Returns:
The index.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
int ejsJoinArray (Ejs *ejs, EjsArray *dest, EjsArray *src)

Join an array.

Description:
This will append the contents of the source array to the destination array.
Parameters:
ejsEjs reference returned from ejsCreateVM
destDestination array to modify.
srcSource array from which to copy elements.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
int ejsLookupItem (Ejs *ejs, EjsArray *ap, EjsAny *item)

Lookup an item in the array.

Description:
This search for the given item (reference) in the array. NOTE: currently numbers are implemented as object references and so using this routine to search for a number reference will not work.
Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to examine.
itemItem to search for.
Returns:
A positive array element index. Otherwise return MPR_ERR_CANT_FIND.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
int ejsRemoveItem (Ejs *ejs, EjsArray *ap, EjsAny *item)

Remove an item from the array.

Description:
This will remove an item from the array. The array will not be compacted.
Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to modify.
itemItem to remove.
Returns:
The index where the item was found. Otherwise return MPR_ERR_CANT_FIND.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItemAtPos, ejsRemoveLastItem
int ejsRemoveItemAtPos (Ejs *ejs, EjsArray *ap, int index)

Remove an item at a given index from the array.

Description:
This will remove an item from the array. The array will not be compacted.
Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to modify.
indexArray index from which to remove the item.
Returns:
The index where the item was found. Otherwise return MPR_ERR_CANT_FIND.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveLastItem
int ejsRemoveLastItem (Ejs *ejs, EjsArray *ap)

Remove the last item from the array.

Description:
This will remove the last item from the array. The array will not be compacted.
Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to modify.
Returns:
The index where the item was found. Otherwise return MPR_ERR_CANT_FIND.
See Also:
EjsArray, ejsAddItem, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsJoinArray, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos

EjsBlock

EjsBlock

Block class.

Description:
The block class is the base class for all program code 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 EjsObj. See ejsBlock.c for details.
API Stability:
Evolving.
See Also:
ejsBindFunction, ejsIsBlock
Fields:
uintbreakCatch Return, break or continue in a catch block.
MprListnamespaces Current list of namespaces open in this block of properties.
uintnobind Don't bind to properties in this block.
EjsPotpot Property storage.
struct EjsBlock *prev Previous block in activation chain.
EjsObj *prevException Previous exception if nested exceptions.
struct EjsBlock *scope Lexical scope chain for this block.
EjsObj **stackBase Start of stack in this block.
bool ejsIsBlock (Ejs *ejs, EjsObj *obj)

Determine if a variable is a block.

Description:
This call tests if the variable is a block.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject 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 EjsObj. 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, ejsToBoolean
Fields:
EjsObjobj Base object.
boolvalue Boolean value.
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 ejsCreateVM
valueDesired boolean value. Set to 1 for true and zero for false.
See Also:
EjsBoolean, ejsGetBoolean, ejsToBoolean
bool ejsGetBoolean (Ejs *ejs, EjsAny *obj)

Get the C boolean value from a boolean object.

Parameters:
ejsEjs reference returned from ejsCreateVM
objBoolean variable to access.
Returns:
True or false.
See Also:
EjsBoolean, ejsCreateBoolean, ejsToBoolean
EjsBoolean * ejsToBoolean (Ejs *ejs, EjsAny *obj)

Cast a variable to a boolean.

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

EjsByteArray

EjsByteArray

ByteArray class.

Description:
ByteArrays provide a resizable, integer indexed, in-memory store for bytes. ByteArrays can be used as a simple array type to store and encode data as bytes or they can be used as buffered Streams 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. Access to the byte array is from index zero up to the size defined by the length property. When constructed, the ByteArray can be designated as resizable, 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 additional write methods to store data at the location specified by the $writePosition property and read methods to read from the $readPosition property. The $available method indicates how much data is available between the read and write position pointers. The $reset method can reset the pointers to the start of the array. When used with for/in, ByteArrays will iterate or enumerate over the available data between the read and write pointers.

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

In Stream mode ByteArrays can be configured to run in sync or async mode. Adding observers via the $addObserver method will put a stream into async mode. Events will then be issued for close, EOF, read and write events.
API Stability:
Evolving.
See Also:
ejsCopyToByteArray, ejsCreateByteArray, ejsGetByteArrayAvailableData, ejsGetByteArrayRoom, ejsGrowByteArray, ejsMakeRoomInByteArray, ejsResetByteArray, ejsSetByteArrayPositions, ejsWriteToByteArray
Fields:
intasync Async mode.
EjsObj *emitter Event emitter for listeners.
intendian Endian encoding.
intgrowInc Current read position.
ssizelength Length property.
EjsObjobj Base object.
ssizereadPosition Current read position.
boolresizable Aray is resizable.
intswap I/O must swap bytes due to endian byte ordering.
uchar *value Data bytes in the array.
ssizewritePosition Current write position.
ssize ejsCopyToByteArray (Ejs *ejs, EjsByteArray *ba, ssize offset, cchar *data, ssize length)

Copy data into a byte array.

Description:
Copy data into a byte array at a specified offset.
Parameters:
ejsEjs reference returned from ejsCreateVM
baByte 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:
Count of bytes written or negative MPR error code.
See Also:
EjsByteArray, ejsCreateByteArray, ejsGetByteArrayAvailableData, ejsGetByteArrayRoom, ejsGrowByteArray, ejsMakeRoomInByteArray, ejsResetByteArray, ejsSetByteArrayPositions, ejsWriteToByteArray
EjsByteArray * ejsCreateByteArray (Ejs *ejs, ssize size)

Create a byte array.

Description:
Create a new byte array instance.
Parameters:
ejsEjs reference returned from ejsCreateVM
sizeInitial size of the byte array.
Returns:
A new byte array instance.
See Also:
EjsByteArray, ejsCopyToByteArray, ejsGetByteArrayAvailableData, ejsGetByteArrayRoom, ejsGrowByteArray, ejsMakeRoomInByteArray, ejsResetByteArray, ejsSetByteArrayPositions, ejsWriteToByteArray
ssize ejsGetByteArrayAvailableData (EjsByteArray *ba)

Get the number of available bytes.

Parameters:
baByte array to examine.
Returns:
The number of bytes of data available to read.
See Also:
EjsByteArray, ejsCopyToByteArray, ejsCreateByteArray, ejsGetByteArrayRoom, ejsGrowByteArray, ejsMakeRoomInByteArray, ejsResetByteArray, ejsSetByteArrayPositions, ejsWriteToByteArray
ssize ejsGetByteArrayRoom (EjsByteArray *ba)

Determine the spare room in the byte array for more data.

Parameters:
baByte array to examine.
Returns:
The number of bytes the byte array can fit without growing.
See Also:
EjsByteArray, ejsCopyToByteArray, ejsCreateByteArray, ejsGetByteArrayAvailableData, ejsGrowByteArray, ejsMakeRoomInByteArray, ejsResetByteArray, ejsSetByteArrayPositions, ejsWriteToByteArray
ssize ejsGrowByteArray (Ejs *ejs, EjsByteArray *ba, ssize size)

Grow the byte array.

Parameters:
ejsEjs reference returned from ejsCreateVM
baByte array to grow.
sizeThe requested new size of the byte array.
Returns:
The new size of the byte array. Otherwise EJS_ERROR if the memory cannot be allocated.
See Also:
EjsByteArray, ejsCopyToByteArray, ejsCreateByteArray, ejsGetByteArrayAvailableData, ejsGetByteArrayRoom, ejsMakeRoomInByteArray, ejsResetByteArray, ejsSetByteArrayPositions, ejsWriteToByteArray
bool ejsMakeRoomInByteArray (Ejs *ejs, EjsByteArray *ba, ssize require)

Make room in the byte array for data.

Description:
This will ensure there is sufficient room in the byte array. If the required number of bytes of spare room is not available, the byte array will grow.
Parameters:
ejsEjs reference returned from ejsCreateVM
baByte array to examine.
requireNumber of bytes needed.
Returns:
The number of bytes of data available to read.
See Also:
EjsByteArray, ejsCopyToByteArray, ejsCreateByteArray, ejsGetByteArrayAvailableData, ejsGetByteArrayRoom, ejsGrowByteArray, ejsResetByteArray, ejsSetByteArrayPositions, ejsWriteToByteArray
void ejsResetByteArray (Ejs *ejs, EjsByteArray *ba)

Reset the byte.

Description:
This will reset the byte array read/write positions if the array is empty.
Parameters:
ejsEjs reference returned from ejsCreateVM
baByte array to modify.
See Also:
EjsByteArray, ejsCopyToByteArray, ejsCreateByteArray, ejsGetByteArrayAvailableData, ejsGetByteArrayRoom, ejsGrowByteArray, ejsMakeRoomInByteArray, ejsSetByteArrayPositions, ejsWriteToByteArray
void ejsSetByteArrayPositions (Ejs *ejs, EjsByteArray *ba, ssize readPosition, ssize 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 ejsCreateVM
baByte array object.
readPositionNew read position to set.
writePositionNew write position to set.
See Also:
EjsByteArray, ejsCopyToByteArray, ejsCreateByteArray, ejsGetByteArrayAvailableData, ejsGetByteArrayRoom, ejsGrowByteArray, ejsMakeRoomInByteArray, ejsResetByteArray, ejsWriteToByteArray
struct EjsNumber * EjsNumber* ejsWriteToByteArray (Ejs *ejs, EjsByteArray *ba, int argc, EjsObj **argv)

Write data to the byte array This implements the ByteArray.write function.

It is most useful for other types to implement a write to byte array capability
Parameters:
ejsEjs reference returned from ejsCreateVM
baByte array to examine.
argcCount of args in argv.
argvArguments to write.
Returns:
The number of bytes of data written (EjsNumber).
See Also:
EjsByteArray, ejsCopyToByteArray, ejsCreateByteArray, ejsGetByteArrayAvailableData, ejsGetByteArrayRoom, ejsGrowByteArray, ejsMakeRoomInByteArray, ejsResetByteArray, ejsSetByteArrayPositions

EjsCache

EjsAny * ejsCacheExpire (Ejs *ejs, EjsObj *cache, struct EjsString *key, struct EjsDate *when)

Expire a cache item.

Parameters:
ejsInterpreter instance returned from ejsCreateVM
cacheCache object.
keyCache item key.
whenWhen to expire the cache item.
Returns:
Returns Null.
See Also:
ejsCacheRead, ejsCacheReadObj, ejsCacheRemove, ejsCacheWrite, ejsCacheWriteObj
EjsAny * ejsCacheRead (Ejs *ejs, EjsObj *cache, struct EjsString *key, EjsObj *options)

Read an item from the cache.

Parameters:
ejsInterpreter instance returned from ejsCreateVM
cacheCache object.
keyCache item key.
optionsCache read options.
Returns:
String cache item.
See Also:
ejsCacheExpire, ejsCacheReadObj, ejsCacheRemove, ejsCacheWrite, ejsCacheWriteObj
EjsAny * ejsCacheReadObj (Ejs *ejs, EjsObj *cache, struct EjsString *key, EjsObj *options)

Read an object from the cache.

Description:
This call reads a cache item and then deserializes using JSON encoding into an object.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
cacheCache object.
keyCache item key.
optionsCache read options.
Returns:
Cache item object.
See Also:
ejsCacheExpire, ejsCacheRead, ejsCacheRemove, ejsCacheWrite, ejsCacheWriteObj
EjsBoolean * ejsCacheRemove (Ejs *ejs, EjsObj *cache, struct EjsString *key)

Read an item from the cache.

Parameters:
ejsInterpreter instance returned from ejsCreateVM
cacheCache object.
keyCache item key.
Returns:
String cache item.
See Also:
ejsCacheExpire, ejsCacheRead, ejsCacheReadObj, ejsCacheWrite, ejsCacheWriteObj
EjsAny * ejsCacheSetLimits (Ejs *ejs, EjsObj *cache, EjsObj *limits)

Set the cache limits.

Parameters:
ejsInterpreter instance returned from ejsCreateVM
cacheCache object.
limitsLimits is an object hash. Depending on the cache backend in-use, the limits object may have some of the following properties. Consult the documentation for the actual cache backend for which properties are supported by the backend.
  • keys Maximum number of keys in the cache. Set to zero for no limit.
  • lifespan Default time in seconds to preserve key data. Set to zero for no timeout.
  • memory Total memory to allocate for cache keys and data. Set to zero for no limit.
  • retries Maximum number of times to retry I/O operations with cache backends.
  • timeout Maximum time to transact I/O operations with cache backends. Set to zero for no timeout.
Returns:
String cache item.
See Also:
ejsCacheExpire, ejsCacheRead, ejsCacheReadObj, ejsCacheRemove, ejsCacheWrite, ejsCacheWriteObj
struct EjsNumber * EjsNumber* ejsCacheWrite (Ejs *ejs, EjsObj *cache, struct EjsString *key, struct EjsString *value, EjsObj *options)

Write an item to the cache.

Parameters:
ejsInterpreter instance returned from ejsCreateVM
cacheCache object.
keyCache item key.
valueValue to write.
optionsCache write options
  • lifespan Preservation time for the key in seconds.
  • expire When to expire the key. Takes precedence over lifetime.
  • mode Mode of writing: "set" is the default and means set a new value and create if required. "add" means set the value only if the key does not already exist. "append" means append to any existing value and create if required. "prepend" means prepend to any existing value and create if required.
  • version Unique version identifier to be used for a conditional write. The write will only be performed if the version id for the key has not changed. This implements an atomic compare and swap.
  • throw Throw an exception rather than returning null if the version id has been updated for the key.
Returns:
String cache item.
See Also:
ejsCacheExpire, ejsCacheRead, ejsCacheReadObj, ejsCacheRemove, ejsCacheWriteObj
struct EjsNumber * EjsNumber* ejsCacheWriteObj (Ejs *ejs, EjsObj *cache, struct EjsString *key, EjsAny *value, EjsObj *options)

Write an object to the cache.

Parameters:
ejsInterpreter instance returned from ejsCreateVM
cacheCache object.
keyCache item key.
valueValue to write.
optionsCache write options
  • lifespan Preservation time for the key in seconds.
  • expire When to expire the key. Takes precedence over lifetime.
  • mode Mode of writing: "set" is the default and means set a new value and create if required. "add" means set the value only if the key does not already exist. "append" means append to any existing value and create if required. "prepend" means prepend to any existing value and create if required.
  • version Unique version identifier to be used for a conditional write. The write will only be performed if the version id for the key has not changed. This implements an atomic compare and swap.
  • throw Throw an exception rather than returning null if the version id has been updated for the key.
Returns:
String cache item.
See Also:
ejsCacheExpire, ejsCacheRead, ejsCacheReadObj, ejsCacheRemove, ejsCacheWrite

EjsCmd

EjsCmd

Cmd class.

Fields:
intargc Length of argv.
char **argv Actual argv when invoking the command.
intasync Async mode.
EjsAny *command Command to run.
Ejs *ejs Interpreter back link.
EjsObj *emitter Event emitter for listeners.
EjsAny *env Optional environment.
struct EjsByteArray *error Error stream.
MprCmd *mc MprCmd object.
EjsAny *options Command options object.
EjsPotpot Property storage.
MprBuf *stderrBuf Stderr from the command.
MprBuf *stdoutBuf Stdout from the command.
intthrow Set to true if the command should throw exceptions for failures.
MprTimetimeout Command timeout in milliseconds.

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 EjsObj. It is still logically an Object, but implements Object properties and methods itself.
API Stability:
Evolving.
See Also:
ejsCreateDate, ejsGetDate
Fields:
EjsObjobj Object base.
MprTimevalue Time in milliseconds since "1970/01/01 GMT".
EjsDate * ejsCreateDate (Ejs *ejs, MprTime value)

Create a new date instance.

Parameters:
ejsEjs reference returned from ejsCreateVM
valueDate/time value to set the new date instance to.
Returns:
An initialized date instance.
See Also:
EjsDate, ejsGetDate
MprTime ejsGetDate (Ejs *ejs, EjsDate *date)

Get the numeric value stored in a EjsDate object.

Parameters:
ejsEjs reference returned from ejsCreateVM
dateDate object to examine.
Returns:
An MprTime value.
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.
See Also:
ejsCaptureStack, ejsGetErrorMsg, ejsGetException, ejsHasException, ejsIsError, ejsThrowArgError, ejsThrowArithmeticError, ejsThrowAssertError, ejsThrowError, ejsThrowIOError, ejsThrowInstructionError, ejsThrowInternalError, ejsThrowMemoryError, ejsThrowOutOfBoundsError, ejsThrowReferenceError, ejsThrowResourceError, ejsThrowStateError, ejsThrowStopIteration, ejsThrowString, ejsThrowSyntaxError, ejsThrowTypeError
Fields:
EjsArray * ejsCaptureStack (Ejs *ejs, int skip)
EjsError * ejsCreateError (Ejs *ejs, struct EjsType *type, EjsObj *message)
cchar * 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 ejsCreateVM
withStackSet to 1 to include a stack backtrace in the error message.
Returns:
A string containing the error message. The caller must not free.
See Also:
ejsCaptureStack, ejsGetException, ejsHasException, ejsIsError, ejsThrowArgError, ejsThrowArithmeticError, ejsThrowAssertError, ejsThrowError, ejsThrowIOError, ejsThrowInstructionError, ejsThrowInternalError, ejsThrowMemoryError, ejsThrowOutOfBoundsError, ejsThrowReferenceError, ejsThrowResourceError, ejsThrowStateError, ejsThrowStopIteration, ejsThrowString, ejsThrowSyntaxError, ejsThrowTypeError
EjsError * ejsThrowInstructionError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowInternalError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowOutOfBoundsError (Ejs *ejs, cchar *fmt, ...)
EjsString * ejsThrowString (Ejs *ejs, cchar *fmt, ...)

Throw a string message.

This will not capture the stack as part of the exception message
Parameters:
ejsEjs reference returned from ejsCreateVM
fmtPrintf style format string to use for the error message.
...Message arguments.
See Also:
ejsCaptureStack, ejsGetErrorMsg, ejsGetException, ejsHasException, ejsIsError, ejsThrowArgError, ejsThrowArithmeticError, ejsThrowAssertError, ejsThrowError, ejsThrowIOError, ejsThrowInstructionError, ejsThrowInternalError, ejsThrowMemoryError, ejsThrowOutOfBoundsError, ejsThrowReferenceError, ejsThrowResourceError, ejsThrowStateError, ejsThrowStopIteration, ejsThrowSyntaxError, ejsThrowTypeError

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:
Evolving.
See Also:
ejsCreateFile, ejsCreateFileFromFd
Fields:
intattached Attached to existing descriptor.
Ejs *ejs Interp reference.
MprFile *file Open file handle.
MprPathinfo Cached file info.
intmode Current open mode.
char *modeString User supplied mode string.
EjsObjobj Base 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 ejsCreateVM
filenameFilename to associate with the file object.
Returns:
A new file object.
See Also:
EjsFile, ejsCreateFileFromFd
EjsFile * ejsCreateFileFromFd (Ejs *ejs, int fd, cchar *name, int mode)

Create a file object from an O/S file descriptor.

Parameters:
ejsEjs reference returned from ejsCreateVM
fdO/S file descriptor handle.
nameFilename to associate with the file object.
modeO/S file access mode (see man 2 open).
Returns:
A new file object.
See Also:
EjsFile, ejsCreateFile

EjsFileSystem

EjsFileSystem

FileSystem class.

Description:
The FileSystem class provides file system services.
API Stability:
Evolving.
See Also:
EjsFile, ejsCreateFile
Fields:
MprFileSystem *fs MPR file system object.
EjsObjobj Base object.
char *path Filename path.

EjsFrame

EjsFrame

Frame record.

See Also:
ejsIsFrame
Fields:
uintargc Actual parameter count.
uchar *attentionPc Restoration PC value after attention.
struct EjsFrame *caller Previous invoking frame.
EjsFunctionfunction Activation frame for function calls. Stores local variables.
uintgetter Frame is a getter.
EjsLine *line Debug source line.
EjsFunction *orig Original function frame is based on.
uchar *pc Program counter.
intslotNum Slot in owner.
EjsObj **stackBase Start of stack in this function.
EjsObj **stackReturn Top of stack to return to.
bool ejsIsFrame (Ejs *ejs, EjsAny *obj)

Determine if a variable is a frame.

Only used internally in the VM
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to test.
Returns:
True if the variable is a frame.
See Also:

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:
ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
Fields:
EjsPot *activation Function properties.
uintallowMissingArgs Allow unsufficient args for native functions.
struct EjsType *archetype Type to use to create instances.
struct EjsArray *boundArgs Bound "args".
EjsAny *boundThis Bound "this" object value.
uintcastNulls Cast return values of null.
EjsCode *code Byte code.
intendFunction Offset in mod file for end of function.
uintfullScope Closures must capture full scope.
uinthasReturn Has a return stmt.
uintinCatch Executing catch block.
uintinException Executing catch/finally exception processing.
uintisConstructor Is a constructor.
uintisInitializer Is a type initializer.
uintisNativeProc Is native procedure.
uintmoduleInitializer Is a module initializer.
EjsString *name Parameter and local properties.
uintnumArgs Count of formal parameters.
uintnumDefault Count of formal parameters with default initializers.
EjsProcproc Native function pointer.
uintrest Has a "..." rest of args parameter.
struct EjsType *resultType Return type of method.
struct EjsFunction *setter Function name. Setter function for this property.
uintstaticMethod Is a static method.
uintstrict Language strict mode (vs standard).
uintthrowNulls Return type cannot be null.
EjsEx * ejsAddException (Ejs *ejs, EjsFunction *fun, uint tryStart, uint tryEnd, struct EjsType *catchType, uint handlerStart, uint handlerEnd, int numBlocks, int numStack, int flags, int preferredIndex)

Add an exception record.

Description:
This creates an exception record to define a catch or finally block.
Parameters:
ejsEjs reference returned from ejsCreateVM
funFunction to modify.
tryStartPointer to the bytecode start of try block.
tryEndPointer to one past the end of the try block.
catchTypeType of error to catch. Set to null for all.
handlerStartPointer to the start of the catch / finally block.
handlerEndPointer ot one past the end of the catch / finally block.
numBlocksCount of blocks opened before the try block.
numStackCount of stack slots pushed before the try block.
flagsMOB.
preferredIndexPreferred index in the function exceptions list. Set to -1 for the next available slot.
Returns:
The allocated exception object.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
EjsFunction * ejsCloneFunction (Ejs *ejs, EjsFunction *fun, int deep)

Clone a function.

Description:
Copy a function 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:
ejsEjs reference returned from ejsCreateVM
funFunction to clone.
deepSet to true to clone each property of the function. Otherwise object references will have their references copied and not the reference targets.
Returns:
The allocated activation object.
See Also:
EjsFunction, ejsBindFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
EjsPot * ejsCreateActivation (Ejs *ejs, EjsFunction *fun, int numSlots)

Create an activation record for a function.

Description:
This creates an activation object that stores the local variables for a function This is a onetime operation and is not done for each function invocation.
Parameters:
ejsEjs reference returned from ejsCreateVM
funFunction to examine.
numSlotsNumber of local variables to reserve room for.
Returns:
The allocated activation object.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
EjsFunction * ejsCreateBareFunction (Ejs *ejs, EjsString *name, int attributes)

Create a bare function.

Description:
This creates a function without code, exceptions or module linkage.
Parameters:
ejsEjs reference returned from ejsCreateVM
nameFunction name.
attributesFunction attributes.
Returns:
The allocated function.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
EjsCode * ejsCreateCode (Ejs *ejs, EjsFunction *fun, struct EjsModule *module, cuchar *byteCode, ssize len, EjsDebug *debug)

Create a code block.

Parameters:
ejsEjs reference returned from ejsCreateVM
funFunction to examine.
moduleModule owning the function.
byteCodeByteCode buffer.
lenSize of the byteCode buffer.
debugDebug record with symbolic debug information.
Returns:
An allocated code block.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
EjsFunction * ejsCreateFunction (Ejs *ejs, EjsString *name, cuchar *code, int codeLen, int numArgs, int numDefault, int numExceptions, struct EjsType *returnType, int attributes, struct EjsModule *module, EjsBlock *scope, int strict)

Create a function object.

Description:
This creates a function object and optionally associates byte code with the function.
Parameters:
ejsEjs reference returned from ejsCreateVM
nameFunction name used in stack backtraces.
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.
numDefaultNumber of default args to the function.
numExceptionsNumber of exception handlers.
returnTypeReturn type of the function. Set to NULL for no defined type.
attributesInteger mask of access attributes.
moduleReference to the module owning the function.
scopeReference to the chain of blocks that that comprises the lexical scope chain for this function.
strictRun code in strict mode (vs standard).
Returns:
An initialized function object.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
int ejsInitFunction (Ejs *ejs, EjsFunction *fun, EjsString *name, cuchar *code, int codeLen, int numArgs, int numDefault, int numExceptions, struct EjsType *returnType, int attributes, struct EjsModule *module, EjsBlock *scope, int strict)

Initialize a function object.

Description:
This initializes a pre-existing function object and optionally associates byte code with the function. This is useful to create constructors which are stored inside type objects.
Parameters:
ejsEjs reference returned from ejsCreateVM
funFunction object.
nameFunction name used in stack backtraces.
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.
numDefaultNumber of default args to the function.
numExceptionsNumber of exception handlers.
returnTypeReturn type of the function. Set to NULL for no defined type.
attributesInteger mask of access attributes.
moduleReference to the module owning the function.
scopeReference to the chain of blocks that that comprises the lexical scope chain for this function.
strictRun code in strict mode (vs standard).
Returns:
An initialized function object.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
bool ejsIsFunction (Ejs *ejs, EjsAny *obj)

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:
ejsInterpreter instance returned from ejsCreateVM
objVariable to test.
Returns:
True if the variable is a function.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
bool ejsIsInitializer (Ejs *ejs, EjsAny *obj)

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:
ejsInterpreter instance returned from ejsCreateVM
objObject to test.
Returns:
True if the variable is an initializer.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
bool ejsIsNativeFunction (Ejs *ejs, EjsAny *obj)

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:
ejsInterpreter instance returned from ejsCreateVM
objObject to test.
Returns:
True if the variable is a native function.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
EjsAny * ejsRunFunction (Ejs *ejs, EjsFunction *fn, EjsAny *thisObj, int argc, void *argv)

Run a function.

Description:
Run a function with the given actual parameters.
Parameters:
ejsEjs reference returned from ejsCreateVM
fnFunction object to run.
thisObjObject 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, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
EjsAny * ejsRunFunctionByName (Ejs *ejs, EjsAny *container, EjsName qname, EjsAny *thisObj, int argc, void *argv)

Run a function by name.

Description:
Run a function identified by name in the given container with the given actual parameters.
Parameters:
ejsEjs reference returned from ejsCreateVM
containerObject that holds the function at its "name".
qnameQualified name for the function in container.
thisObjObject to use as "this" when invoking 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, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
EjsAny * ejsRunFunctionBySlot (Ejs *ejs, EjsAny *obj, int slotNum, int argc, void *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 ejsCreateVM
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, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunInitializer, ejsRunInitializer
EjsObj * 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 ejsCreateVM
moduleModule object reference.
Returns:
The last expression result of global code executed.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot
int ejsSetFunctionCode (Ejs *ejs, EjsFunction *fun, struct EjsModule *module, cuchar *byteCode, ssize len, EjsDebug *debug)

Set the byte code for a function.

Parameters:
ejsEjs reference returned from ejsCreateVM
funFunction to examine.
moduleModule owning the function.
byteCodeByteCode buffer.
lenSize of the byteCode buffer.
debugDebug record with symbolic debug information.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer

EjsHttp

EjsHttp

Http Class.

Description:
API Stability:
Evolving.
See Also:
ejsCreateHttp, ejsGetHttpLimits, ejsLoadHttpService, ejsSetHttpLimits, ejsSetupHttpTrace
Fields:
char *certFile SSL certificate file.
intclosed Http is closed and "close" event has been issued.
HttpConn *conn Http connection object.
EjsByteArray *data Buffered write data.
Ejs *ejs Interp reference.
EjsObj *emitter Event emitter.
interror Http errored and "error" event has been issued.
char *keyFile SSL key file.
EjsObj *limits Limits object.
char *method HTTP method.
EjsObjobj Base object.
ssizereadCount Count of body bytes read.
MprBuf *requestContent Request body data supplied.
ssizerequestContentCount Count of bytes written from requestContent.
EjsString *responseCache Cached response (only used if response() is used).
MprBuf *responseContent Response data.
char *uri Target uri.
ssizewriteCount Count of bytes written via write().
EjsHttp * ejsCreateHttp (Ejs *ejs)

Create a new Http object.

Parameters:
ejsEjs reference returned from ejsCreateVM
Returns:
A new Http object.
See Also:
EjsHttp, ejsGetHttpLimits, ejsLoadHttpService, ejsSetHttpLimits, ejsSetupHttpTrace
void ejsGetHttpLimits (Ejs *ejs, EjsObj *obj, HttpLimits *limits, bool server)

Get a Http limits.

Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to contain the limits properties.
limitsThe HttpLimits object.
serverSet to true if defining server side limits.
See Also:
EjsHttp, ejsCreateHttp, ejsLoadHttpService, ejsSetHttpLimits, ejsSetupHttpTrace
void ejsSetHttpLimits (Ejs *ejs, HttpLimits *limits, EjsObj *obj, bool server)

Set a Http limits.

Parameters:
ejsEjs reference returned from ejsCreateVM
limitsThe HttpLimits object receiving the limit settings.
objObject containing the limits values.
serverSet to true if defining server side limits.
See Also:
EjsHttp, ejsCreateHttp, ejsGetHttpLimits, ejsLoadHttpService, ejsSetupHttpTrace

EjsHttpServer

EjsHttpServer

HttpServer Class.

Description:
API Stability:
Prototype.
See Also:
ejsCloneHttpServer
Fields:
intasync Async mode.
char *certFile SSL certificate file.
char *ciphers SSL ciphers.
struct EjsHttpServer *cloned Server that was cloned.
cchar *connector Pipeline connector.
Ejs *ejs Ejscript interpreter handle.
EjsObj *emitter Event emitter.
HttpEndpoint *endpoint Http endpoint object.
inthosted Server being hosted inside a web server.
EjsArray *incomingStages Incoming Http pipeline stages.
char *ip Listening address.
char *keyFile SSL key file.
EjsObj *limits Limits object.
char *name Server name.
EjsArray *outgoingStages Outgoing Http pipeline stages.
intport Listening port.
EjsPotpot Extends Object.
char *protocols SSL protocols.
struct MprSsl *ssl SSL configuration.
HttpTracetrace[2] Default tracing for requests.
EjsHttpServer * ejsCloneHttpServer (Ejs *ejs, EjsHttpServer *server, bool deep)

Clone a http server.

Parameters:
ejsEjs interpreter handle returned from $ejsCreate.
serverHttpServer object.
deepIgnored.
Returns:
A new server object.
See Also:
EjsHttpServer

EjsIterator

EjsIterator

Iterator Class.

Description:
Iterator is a helper class to implement iterators in other native classes.
API Stability:
Evolving.
See Also:
ejsCreateIterator
Fields:
booldeep Iterator deep (recursively over all properties).
intindex Current index.
EjsObj *indexVar Reference to current item.
EjsArray *namespaces Namespaces to consider in iteration.
EjsProcnativeNext Native next function.
EjsObjobj Base object.
EjsObj *target Object to be enumerated.
EjsIterator * ejsCreateIterator (Ejs *ejs, EjsAny *target, void *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 ejsCreateVM
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

EjsModule

EjsModule

Module control structure.

See Also:
ejsCreateSearchPath, ejsLoadModule, ejsLoadModules, ejsSearchForModule, ejsSetSearchPath
Fields:
intchecksum Checksum of slots and names.
struct EcCodeGen *code Code generation buffer.
uintcompiling Module currently being compiled from source.
uintconfigured Module types have been configured with native code.
EjsConstants *constants Constant pool.
MprList *current Current stack of open objects.
EjsFunction *currentMethod Current method being loaded.
MprList *dependencies Module file dependencies. List of EjsModules.
EjsString *doc Current doc string.
MprFile *file File handle for loading and code generation.
intfirstGlobal First global property.
intflags Loading flags.
MprList *globalProperties List of global properties.
uinthasError Module has a loader error.
uinthasInitializer Has initializer function.
uinthasNative Has native property definitions.
uintinitialized Initializer has run.
EjsFunction *initializer Initializer method.
intlastGlobal Last global property + 1.
uintloaded Module has been loaded from an external file.
EjsLoadState *loadState State while loading.
intmaxVersion Maximum version when used as a dependency.
intminVersion Minimum version when used as a dependency.
MprMutex *mutex Multithread locking.
EjsString *name Name of this module - basename of the filename without .mod extension.
uintnativeLoaded Backing shared library loaded.
char *path Module file path name.
EjsBlock *scope Lexical scope chain.
intversion Made with EJS_MAKE_VERSION.
uintvisited Module has been traversed.
MprList *vms List of VMs referencing the module.
EjsString *vname Versioned name - name with optional version suffix.
struct EjsArray * EjsArray* ejsCreateSearchPath (Ejs *ejs, cchar *searchPath)

Create a search path array.

This can be used in ejsCreate
Description:
Create and array of search paths.
Parameters:
ejsEjs interpreter.
searchPathSearch path string. This is a colon (or semicolon on Windows) separated string of directories.
Returns:
An array of search paths.
See Also:
ejsLoadModule, ejsLoadModules, ejsSearchForModule, ejsSetSearchPath
int ejsLoadModule (Ejs *ejs, EjsString *name, int minVer, int maxVer, int flags)

Load a module.

Description:
This will emit an error message of the format:
  • program:line:errorCode:SEVERITY: message
Parameters:
ejsInterpeter object returned from ejsCreateVM
nameModule path name.
maxVerMaximum acceptable version to load. Use EJS_MAKE_VERSION to create a version number or set to -1 if any version is acceptable.
minVerMinimum acceptable version to load. Use EJS_MAKE_VERSION to create a version number or set to -1 if any version is acceptable.
flagsModule loading flags. Select from: EJS_LOADER_STRICT, EJS_LOADER_NO_INIT, EJS_LOADER_ETERNAL, EJS_LOADER_BUILTIN, EJS_LOADER_DEP, EJS_LOADER_RELOAD.
Returns:
A postitive slot number or a negative MPR error code.
See Also:
ejsCreateSearchPath, ejsLoadModules, ejsSearchForModule, ejsSetSearchPath
int ejsLoadModules (Ejs *ejs, cchar *search, MprList *require)

Load modules into an interpreter.

Description:
Initialize an interpreter by loading modules. A list of modules to load can be provided via the "require" argument. If the "require" argument is set to null, then the default modules will be loaded. If "require" is set to a list of module names, these will be loaded. If set to an empty list, then no modules will be loaded and the interpreter will be marked as an "empty" interpreter.
Parameters:
ejsInterpreter to modify.
searchModule search path to use. Set to NULL for the default search path.
requireOptional list of required modules to load. If NULL, the following modules will be loaded: ejs, ejs.io, ejs.events, ejs.xml, ejs.sys and ejs.unix.
Returns:
Zero if successful, otherwise return a negative MPR error code.
See Also:
ejsCreateSearchPath, ejsLoadModule, ejsSearchForModule, ejsSetSearchPath
char * ejsSearchForModule (Ejs *ejs, cchar *name, int minVer, int maxVer)

Search for a module in the module search path.

Parameters:
ejsInterpeter object returned from ejsCreateVM
nameModule name.
minVerMinimum acceptable version to load. Use EJS_MAKE_VERSION to create a version number or set to -1 if any version is acceptable.
maxVerMaximum acceptable version to load. Use EJS_MAKE_VERSION to create a version number or set to -1 if any version is acceptable.
Returns:
Path name to the module.
See Also:
ejsCreateSearchPath, ejsLoadModule, ejsLoadModules, ejsSetSearchPath
void ejsSetSearchPath (Ejs *ejs, struct EjsArray *search)

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.
searchArray of search paths.
See Also:
ejsCreateSearchPath, ejsLoadModule, ejsLoadModules, ejsSearchForModule

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:
Evolving.
See Also:
ejsMarkName
Fields:
struct EjsString *name Property name.
struct EjsString *space Property namespace.
void ejsMarkName (EjsName *qname)

Mark a name for GC.

Parameters:
qnameQualified name reference.
See Also:
EjsName
EjsName ejsName (struct Ejs *ejs, cchar *space, cchar *name)

Initialize a Qualified Name structure.

Description:
Initialize the statically allocated qualified name structure using a name and namespace.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
spaceNamespace string.
nameName string.
Returns:
A reference to the qname structure.
See Also:
EjsName, ejsMarkName
EjsName ejsWideName (struct Ejs *ejs, MprChar *space, MprChar *name)

Initialize a Qualified Name structure using a wide namespace and name.

Description:
Initialize the statically allocated qualified name structure using a name and namespace.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
spaceNamespace string.
nameName string.
Returns:
A reference to the qname structure.
See Also:
EjsName, ejsMarkName

EjsNamespace

EjsNamespace

Namespace Class.

Description:
Namespaces are used to qualify names into discrete spaces.
API Stability:
Evolving.
See Also:
ejsCreateNamespace, ejsCreateReservedNamespace, ejsDefineReservedNamespace, ejsFormatReservedNamespace
Fields:
EjsObjobj Base object.
EjsString *value Textual name of the namespace.
EjsNamespace * ejsCreateNamespace (Ejs *ejs, EjsString *name)

Create a namespace object.

Parameters:
ejsEjs reference returned from ejsCreateVM
nameSpace name to use for the namespace.
Returns:
A new namespace object.
See Also:
EjsNamespace, ejsCreateReservedNamespace, ejsDefineReservedNamespace, ejsFormatReservedNamespace
EjsNamespace * ejsCreateReservedNamespace (Ejs *ejs, EjsName *typeName, EjsString *name)

Create a reserved namespace.

Parameters:
ejsEjs reference returned from ejsCreateVM
typeNameType on which to base the formatted namespace name.
nameFormatted base name for the namespace.
Returns:
A new namespace object.
See Also:
EjsNamespace, ejsCreateNamespace, ejsDefineReservedNamespace, ejsFormatReservedNamespace
EjsNamespace * ejsDefineReservedNamespace (Ejs *ejs, EjsBlock *block, EjsName *typeName, cchar *name)

Define a reserved namespace on a block.

Parameters:
ejsEjs reference returned from ejsCreateVM
blockBlock to modify.
typeNameType on which to base the formatted namespace name.
nameFormatted base name for the namespace.
blockBlock to modify.
Returns:
A new namespace object.
See Also:
EjsNamespace, ejsCreateNamespace, ejsCreateReservedNamespace, ejsFormatReservedNamespace
EjsString * ejsFormatReservedNamespace (Ejs *ejs, EjsName *typeName, EjsString *spaceName)

Format a reserved namespace name to create a unique namespace.

Description:
This is used to extend the "internal", "public", "private", and "protected" namespaces to be unique for their owning class.

Namespaces are formatted as strings using the following format, where type is optional. Types may be qualified. [type,space]

Example: [debug::Shape,public] where Shape was declared as "debug class Shape".
Parameters:
ejsEjs reference returned from ejsCreateVM
typeNameType on which to base the formatted namespace name.
spaceNameNamespace name.
Returns:
A string containing the formatted name.
See Also:
EjsNamespace, ejsCreateNamespace, ejsCreateReservedNamespace, ejsDefineReservedNamespace

EjsNull

EjsNull

Null Class.

Description:
The Null class provides the base class for the singleton null instance. This instance is stored in ejs->nullValue.
API Stability:
Evolving.
See Also:
ejsCreateNull
Fields:
EjsNull * ejsCreateNull (Ejs *ejs)

Create the null object.

Description:
There is one null object in the system.
Parameters:
ejsEjs reference returned from ejsCreateVM
Returns:
The null object.
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, ejsGetInt64, ejsGetNumber, ejsIsInfinite, ejsIsNan, ejsToNumber
Fields:
EjsObjobj Base object.
MprNumbervalue Numeric value.
EjsNumber * ejsCreateNumber (Ejs *ejs, MprNumber value)

Create a number object.

Parameters:
ejsEjs reference returned from ejsCreateVM
valueNumeric value to initialize the number object.
Returns:
A number object.
See Also:
EjsNumber, ejsGetDouble, ejsGetInt, ejsGetInt64, ejsGetNumber, ejsIsInfinite, ejsIsNan, ejsToNumber
double ejsGetDouble (Ejs *ejs, EjsAny *obj)

Get the numeric value stored in a EjsNumber object.

Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to examine.
Returns:
A double value.
See Also:
EjsNumber, ejsCreateNumber, ejsGetInt, ejsGetInt64, ejsGetNumber, ejsIsInfinite, ejsIsNan, ejsToNumber
int ejsGetInt (Ejs *ejs, EjsAny *obj)

Get the numeric value stored in a EjsNumber object.

Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to examine.
Returns:
An integer value.
See Also:
EjsNumber, ejsCreateNumber, ejsGetDouble, ejsGetInt64, ejsGetNumber, ejsIsInfinite, ejsIsNan, ejsToNumber
int64 ejsGetInt64 (Ejs *ejs, EjsAny *obj)

Get an 64 bit integer value equivalent to that stored in an EjsNumber object.

Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to examine.
Returns:
A 64 bit integer value.
See Also:
EjsNumber, ejsCreateNumber, ejsGetDouble, ejsGetInt, ejsGetNumber, ejsIsInfinite, ejsIsNan, ejsToNumber
MprNumber ejsGetNumber (Ejs *ejs, EjsAny *obj)

Get the numeric value stored in a EjsNumber object.

Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to examine.
Returns:
A numeric value.
See Also:
EjsNumber, ejsCreateNumber, ejsGetDouble, ejsGetInt, ejsGetInt64, ejsIsInfinite, ejsIsNan, ejsToNumber
bool ejsIsInfinite (MprNumber n)

Test if a number is infinite.

Parameters:
nNumber to test.
Returns:
True if the number is infinite.
See Also:
EjsNumber, ejsCreateNumber, ejsGetDouble, ejsGetInt, ejsGetInt64, ejsGetNumber, ejsIsNan, ejsToNumber
bool ejsIsNan (MprNumber n)

Test if a value is not-a-number.

Parameters:
nNumber to test.
Returns:
True if the number is not-a-number.
See Also:
EjsNumber, ejsCreateNumber, ejsGetDouble, ejsGetInt, ejsGetInt64, ejsGetNumber, ejsIsInfinite, ejsToNumber
struct EjsNumber * EjsNumber* ejsToNumber (Ejs *ejs, EjsAny *obj)

Cast a variable to a number.

Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to cast.
Returns:
A number object.
See Also:
EjsNumber, ejsCreateNumber, ejsGetDouble, ejsGetInt, ejsGetInt64, ejsGetNumber, ejsIsInfinite, ejsIsNan

EjsObj

int ejsAddObserver (Ejs *ejs, EjsObj **emitterPtr, EjsObj *name, struct EjsFunction *observer)

Add an observer.

Description:
Add an observer for events when implementing the createVar helper.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
emitterPtrReference to an emitter. If the reference location is NULL, a new emitter will be created and passed back via *emitterPtr.
nameName of events to observe. Can be an array of events.
observerFunction to run when selected events are triggered.
Returns:
Zero if successful.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreat