Ejscript API Native API

Extensions

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.
EjsWebSocket WebSocket 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.
intejsAppendArray(Ejs *ejs, EjsArray *dest, EjsArray *src)
 Append an array.
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, wchar *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, int length, 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, cchar *home, cchar *documents)
 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, cchar *pattern, cchar *flags)
 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, MprSocket *sock, bool async)
 Create a new Socket object.
EjsString*ejsCreateString(Ejs *ejs, wchar *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, int flags)
Ejs*ejsCreateVM(int argc, cchar **argv, int flags)
 Create an ejs virtual machine.
EjsWebSocket*ejsCreateWebSocket(Ejs *ejs)
 Create a new WebSocket object.
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.
EjsArray*ejsGetPathFiles(Ejs *ejs, EjsPath *path, int argc, EjsAny **argv)
 Get files below a path.
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, MprTicks 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, wchar *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.
EjsString*ejsJoinArray(Ejs *ejs, EjsArray *ap, EjsString *join)
 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, wchar *str, int prefType)
 Parse a string.
EjsRegExp*ejsParseRegExp(Ejs *ejs, EjsString *pattern)
 Parse a string and create a regular expression object.
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, int compact)
 Remove an item from the array.
intejsRemoveItemAtPos(Ejs *ejs, EjsArray *ap, int index, int compact)
 Remove an item at a given index from the array.
EjsArray*ejsRemoveItems(Ejs *ejs, EjsArray *ap, EjsArray *items)
 Remove items 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.
cchar*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, MprTicks 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, wchar *space, wchar *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.
EjsProcNative 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.
#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_BLEND_ADD   0x80
 Flag for ejsBlendObject for "+" property blend.
#defineEJS_BLEND_ASSIGN   0x200
 Flag for ejsBlendObject for "=" property blend.
#defineEJS_BLEND_COMBINE   0x1
 Flag for ejsBlendObject to combine key values.
#defineEJS_BLEND_COND_ASSIGN   0x400
 Flag for ejsBlendObject for "?" property blend.
#defineEJS_BLEND_DEEP   0x2
 Flag for ejsBlendObject to copy nested object recursively.
#defineEJS_BLEND_FUNCTIONS   0x4
 Flag for ejsBlendObject to copy function properties.
#defineEJS_BLEND_OVERWRITE   0x8
 Flag for ejsBlendObject to overwrite existing properties.
#defineEJS_BLEND_PRIVATE   0x20
 Flag for ejsBlendObject to copy private properties.
#defineEJS_BLEND_PUBLIC   0x800
 Flag for ejsBlendObject for blending into public properties.
#defineEJS_BLEND_SUB   0x100
 Flag for ejsBlendObject for "-" property blend.
#defineEJS_BLEND_SUBCLASSES   0x10
 Flag for ejsBlendObject to copy subclassed properties.
#defineEJS_BLEND_TRACE   0x40
 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_COMMAS   0x1
 ejsSerialize flag to always put commas after properties.
#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_NOQUOTES   0x20
 ejsSerialize flag to omit quotes if property has no spaces.
#defineEJS_JSON_SHOW_NULLS   0x80
 ejsSerialize flag to emit null properties.
#defineEJS_JSON_SHOW_PRETTY   0x8
 ejsSerialize flag to render in human-readible multiline format.
#defineEJS_JSON_SHOW_REGEXP   0x40
 ejsSerialize flag to emit native RegExp literals.
#defineEJS_JSON_SHOW_SUBCLASSES   0x10
 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 before rehash.
#defineEJS_MAX_EXCEPTIONS   8192
 Max number of exceptions.
#defineEJS_MAX_LOCALS   (10*1024)
 Max number of locals.
#defineEJS_MAX_POOL   (4*1024*1024)
 Size of constant pool.
#defineEJS_MAX_TRAITS   (0x7fff)
 Max number of declared properties per block.
#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_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_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_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_PROCESSING   6
 XML node is a processing instruction.
#defineEJS_XML_TEXT   4
 XML node is text.
#defineME_MAX_EJS_STACK   (1024 * 32)
 Stack size without MMU.
#defineME_NUM_TYPE   double
 Configured numeric type.

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.
See Also:
ejsAddImmutable, ejsClearException, ejsCloneVM, ejsCreateVM, ejsEvalFile, ejsEvalModule, ejsEvalScript, ejsExit, ejsGetImmutable, ejsGetImmutableByName, ejsGetVarByName, ejsLog, ejsLookupScope, ejsLookupVar, ejsLookupVarWithNamespaces, ejsReportError, ejsRun, ejsRunProgram, ejsSetDispatcher, ejsSetSearchPath, ejsThrowException
API Stability:
Internal.
Fields:
uintabandoned Pooled VM is released awaiting GC.
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 *hostedDocuments Documents directory for hosted HttpServer.
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
void ejsClearException (Ejs *ejs)
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
void ejsLog (Ejs *ejs, cchar *fmt, ...)
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.
See Also:
ejsAddItem, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
API Stability:
Internal.
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, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
int ejsAppendArray (Ejs *ejs, EjsArray *dest, EjsArray *src)

Append 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
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, ejsAppendArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, 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, ejsAppendArray, ejsClearArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, 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, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, 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, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, 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, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, 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, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, 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, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetPrevItem, ejsInsertItem, 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, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsInsertItem, 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, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
EjsString * ejsJoinArray (Ejs *ejs, EjsArray *ap, EjsString *join)

Join an array.

Description:
This will join the array elements using the given join string separator.
Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to modify.
joinString to use as a delimiter between elements.
Returns:
The result string.
See Also:
EjsArray, ejsAddItem, ejsAppendArray, 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, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsRemoveItem, ejsRemoveItemAtPos, ejsRemoveLastItem
int ejsRemoveItem (Ejs *ejs, EjsArray *ap, EjsAny *item, int compact)

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.
compactSet to true to compact following properties.
Returns:
The index where the item was found. Otherwise return MPR_ERR_CANT_FIND.
See Also:
EjsArray, ejsAddItem, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsLookupItem, ejsRemoveItemAtPos, ejsRemoveLastItem
int ejsRemoveItemAtPos (Ejs *ejs, EjsArray *ap, int index, int compact)

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.
compactSet to true to compact following properties.
Returns:
The index where the item was found. Otherwise return MPR_ERR_CANT_FIND.
See Also:
EjsArray, ejsAddItem, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsLookupItem, ejsRemoveItem, ejsRemoveLastItem
EjsArray * ejsRemoveItems (Ejs *ejs, EjsArray *ap, EjsArray *items)

Remove items from the array.

Description:
This will remove items from the array. The array will be compacted.
Parameters:
ejsEjs reference returned from ejsCreateVM
apSource array to modify.
itemsArray items to remove.
Returns:
The original array.
See Also:
EjsArray, ejsAddItem, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, ejsLookupItem, ejsRemoveItem, ejsRemoveItemAtPos, 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, ejsAppendArray, ejsClearArray, ejsCloneArray, ejsCreateArray, ejsGetFirstItem, ejsGetItem, ejsGetLastItem, ejsGetNextItem, ejsGetPrevItem, ejsInsertItem, 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.
See Also:
ejsBindFunction, ejsIsBlock
API Stability:
Internal.
Fields:
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.
uchar *restartAddress Restart instruction address.
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.
See Also:
ejsCreateBoolean, ejsGetBoolean, ejsToBoolean
API Stability:
Internal.
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.
See Also:
ejsCopyToByteArray, ejsCreateByteArray, ejsGetByteArrayAvailableData, ejsGetByteArrayRoom, ejsGrowByteArray, ejsMakeRoomInByteArray, ejsResetByteArray, ejsSetByteArrayPositions, ejsWriteToByteArray
API Stability:
Internal.
Fields:
intasync Async mode.
EjsObj *emitter Event emitter for listeners.
intendian Endian encoding.
intgrowInc Current read position.
EjsObjobj Base object.
ssizereadPosition Current read position.
boolresizable Aray is resizable.
ssizesize Size property.
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

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.

API Stability:
Internal.
Fields:
intargc Length of argv.
cchar **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.
MprTickstimeout 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.
See Also:
ejsCreateDate, ejsGetDate
API Stability:
Internal.
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
EjsObj * ejsGetException (Ejs *ejs)
bool ejsHasException (Ejs *ejs)
bool ejsIsError (Ejs *ejs, EjsAny *obj)
EjsError * ejsThrowArgError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowArithmeticError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowAssertError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowInstructionError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowInternalError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowIOError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowMemoryError (Ejs *ejs)
EjsError * ejsThrowOutOfBoundsError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowReferenceError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowResourceError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowStateError (Ejs *ejs, cchar *fmt, ...)
EjsObj * ejsThrowStopIteration (Ejs *ejs)
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
EjsError * ejsThrowSyntaxError (Ejs *ejs, cchar *fmt, ...)
EjsError * ejsThrowTypeError (Ejs *ejs, cchar *fmt, ...)

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.
See Also:
ejsCreateFile, ejsCreateFileFromFd
API Stability:
Internal.
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.
See Also:
EjsFile, ejsCreateFile
API Stability:
Internal.
Fields:
MprFileSystem *fs MPR file system object.
EjsObjobj Base object.
char *path Filename path.

EjsFrame

EjsFrame

Frame record.

See Also:
ejsIsFrame
API Stability:
Internal.
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.
See Also:
ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
API Stability:
Internal.
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.
flagsReserved.
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
void ejsRemoveConstructor (Ejs *ejs, struct EjsType *type)
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:
Http objects represents a Hypertext Transfer Protocol version 1.1 client connection and are used HTTP requests and capture responses. This class supports the HTTP/1.1 standard including methods for GET, POST, PUT, DELETE, OPTIONS, and TRACE. It also supports Keep-Alive and SSL connections.
See Also:
ejsCreateHttp, ejsGetHttpLimits, ejsLoadHttpService, ejsSetHttpLimits, ejsSetupHttpTrace
API Stability:
Internal.
Fields:
char *caFile SSL CA certificate file.
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.
MprSsl *ssl SSL configuration.
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:
HttpServer objects represents a Hypertext Transfer Protocol version 1.1 client connection and are used HTTP requests and capture responses. This class supports the HTTP/1.1 standard including methods for GET, POST, PUT, DELETE, OPTIONS, and TRACE. It also supports Keep-Alive and SSL connections.
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.
HttpTrace *trace 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.
See Also:
ejsCreateIterator
API Stability:
Internal.
Fields:
booldeep Iterator deep (recursively over all properties).
intindex Current index.
EjsObj *indexVar Reference to current item.
intlength Collection length prior to iteration.
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, int length, 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.
lengthLength of collection prior to iteration.
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
API Stability:
Internal.
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.
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
cchar * 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.
See Also:
ejsMarkName
API Stability:
Internal.
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, wchar *space, wchar *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.
See Also:
ejsCreateNamespace, ejsCreateReservedNamespace, ejsDefineReservedNamespace, ejsFormatReservedNamespace
API Stability:
Internal.
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.
See Also:
ejsCreateNumber, ejsGetDouble, ejsGetInt, ejsGetInt64, ejsGetNumber, ejsIsInfinite, ejsIsNan, ejsToNumber
API Stability:
Internal.
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

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, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsAlloc (Ejs *ejs, struct EjsType *type, ssize extra)

Allocate a new variable.

Description:
This will allocate space for a bare variable. This routine should only be called by type factories when implementing the createVar helper.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
typeType object from which to create an object instance.
extraSize of extra property slots to reserve. This is used for dynamic objects.
Returns:
A newly allocated variable of the requested type. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsCastType (Ejs *ejs, EjsAny *obj, struct EjsType *type)

Cast a variable to a new type.

Description:
Cast a variable and return a new variable of the required type.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to cast.
typeType to cast to.
Returns:
A newly allocated variable of the requested type. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
ejsAlloc, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsClone (Ejs *ejs, EjsAny *obj, bool deep)

Clone a variable.

Description:
Copy a variable and create a new copy. This may do a shallow or deep copy. A shallow copy will not copy the property instances, rather it will only duplicate the property reference. A deep copy will recursively clone all the properties of the variable.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to clone.
deepSet to true to do a deep copy.
Returns:
A newly allocated variable of the requested type. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
ejsAlloc, ejsCastType, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsClonePot (Ejs *ejs, EjsAny *src, bool deep)

Copy an object.

Description:
Copy an object create a new instance. This may do a shallow or deep copy depending on the value of deep. A shallow copy will not copy the property instances, rather it will only duplicate the property reference. A deep copy will recursively clone all the properties of the variable.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
srcSource object to copy.
deepSet to true to do a deep copy.
Returns:
A newly allocated object. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsCompactPot (Ejs *ejs, EjsPot *obj)

Compact an object.

Description:
This removes deleted properties and compacts property slot references.
Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to compact.
Returns:
The number of properties in the object.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsCreateEmptyPot (Ejs *ejs)
EjsAny * ejsCreateInstance (Ejs *ejs, struct EjsType *type, int argc, void *argv)

Create a new variable instance.

Description:
Create a new variable instance and invoke any required constructors with the given arguments.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
typeType from which to create a new instance.
argcCount of args in argv.
argvVector of arguments. Each arg is an EjsAny.
Returns:
A newly allocated variable of the requested type. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsCreateObj (Ejs *ejs, struct EjsType *type, int numSlots)

Create a variable.

Description:
Create a variable of the required type. This invokes the createVar helper method for the specified type.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
typeType to cast to.
numSlotsSize of extra property slots to reserve. This is used for dynamic objects.
Returns:
A newly allocated variable of the requested type. Caller must not free as the GC will manage the lifecycle of the variable.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsCreatePot (Ejs *ejs, struct EjsType *type, int size)

Create an object instance of the specified type.

Description:
Create a new object using the specified type as a base class. Note: the constructor is not called. If you require the constructor to be invoked, use ejsCreateInstance.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
typeBase type to use when creating the object instance.
sizeNumber of extra slots to allocate when creating the object.
Returns:
A new object instance.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsDefineProperty (Ejs *ejs, EjsAny *obj, int slotNum, EjsName qname, struct EjsType *type, int64 attributes, EjsAny *value)

Define a property.

Description:
Define a property in a variable and give it a name, base type, attributes and default value.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject in which to define a property.
slotNumSlot number in the variable for the property. Slots are numbered sequentially from zero. Set to -1 to request the next available slot number.
qnameQualified name containing a name and a namespace.
typeBase type of the property. Set to ejs->voidType to leave as untyped.
attributesAttribute traits.
valueInitial value of the property.
Returns:
A postitive slot number or a negative MPR error code.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsDeleteProperty (Ejs *ejs, EjsAny *obj, int slotNum)

Delete a property.

Description:
Delete a variable's property and set its slot to null. The slot is not reclaimed and subsequent properties are not compacted.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objVariable in which to delete the property.
slotNumSlot number in the variable for the property to delete.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsDeletePropertyByName (Ejs *ejs, EjsAny *obj, EjsName qname)

Delete a property by name.

Description:
Delete a variable's property by name and set its slot to null. The property is resolved by using ejsLookupProperty with the specified name. Once deleted, the slot is not reclaimed and subsequent properties are not compacted.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objVariable in which to delete the property.
qnameQualified name for the property including name and namespace.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsDeserialize (Ejs *ejs, struct EjsString *str)

Deserialize a JSON encoded string.

Description:
This is the calling signature for C Functions.
Parameters:
ejsEjs reference returned from ejsCreateVM
strJSON string to deserialize.
Returns:
Returns an allocated object equivalent to the supplied JSON encoding.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsGetLength (Ejs *ejs, EjsAny *obj)

Get a count of properties in a variable.

Description:
Get a property from a variable at a given slot.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objVariable to examine.
Returns:
A positive integer count of the properties stored by the variable.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsGetProperty (Ejs *ejs, EjsAny *obj, int slotNum)

Get a property.

Description:
Get a property from a variable at a given slot.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to examine.
slotNumSlot number for the requested property.
Returns:
The variable property stored at the nominated slot.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsGetPropertyByName (Ejs *ejs, EjsAny *obj, EjsName qname)

Get a property by name.

Description:
Get a property from a variable by name.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to examine.
qnameQualified name specifying both a namespace and name.
Returns:
The variable property stored at the nominated slot.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsName ejsGetPropertyName (Ejs *ejs, EjsAny *obj, int slotNum)

Get a variable property's name.

Description:
Get a property name for the property at a given slot in the variable.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to examine.
slotNumSlot number for the requested property.
Returns:
The qualified property name including namespace and name. Caller must not free.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
struct EjsTrait * EjsTrait* ejsGetPropertyTraits (Ejs *ejs, EjsAny *obj, int slotNum)

Get a property's traits.

Description:
Get a property's trait description. The property traits define the properties base type, and access attributes.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objVariable to examine.
slotNumSlot number for the requested property.
Returns:
A trait structure reference for the property.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsGrowPot (Ejs *ejs, EjsPot *obj, int numSlots)

Grow a pot object.

Description:
Grow the property storage for an object. Object properties are stored in slots. To store more properties, you need to grow the slots.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject reference to grow.
numSlotsNew minimum count of properties. If size is less than the current number of properties, the call will be ignored, i.e. it will not shrink objects.
Returns:
Zero if successful.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsInvokeOperator (Ejs *ejs, EjsAny *obj, int opCode, EjsAny *rhs)

Invoke an opcode on a native type.

Description:
Invoke an Ejscript byte code operator on the specified variable given the expression right hand side. Native types would normally implement the invokeOperator helper function to respond to this function call.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objVariable to examine.
opCodeByte ope code to execute.
rhsExpression right hand side for binary expression op codes. May be null for other op codes.
Returns:
The result of the op code or NULL if the opcode does not require a result.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsInvokeOperatorDefault (Ejs *ejs, EjsAny *obj, int opCode, EjsAny *rhs)

Default implementation for operator invoke.

Description:
Invoke an Ejscript byte code operator on the specified variable given the expression right hand side.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objVariable to examine.
opCodeByte ope code to execute.
rhsExpression right hand side for binary expression op codes. May be null for other op codes.
Returns:
The result of the op code or NULL if the opcode does not require a result.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsLookupProperty (Ejs *ejs, EjsAny *obj, EjsName qname)

Lookup a property by name.

Description:
Search for a property by name in the given variable.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objVariable to examine.
qnameQualified name of the property to search for.
Returns:
The slot number containing the property. Then use $ejsGetProperty to retrieve the property or alternatively use ejsGetPropertyByName to lookup and retrieve in one step.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
void ejsManagePot (void *obj, int flags)

Mark an object as currently in use.

Description:
Mark an object as currently active so the garbage collector will preserve it. This routine should be called by native types that extend EjsObj in their markVar helper.
Parameters:
objObject to mark as currently being used.
flagsmanager flags.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
EjsAny * ejsParse (Ejs *ejs, wchar *str, int prefType)

Parse a string.

Description:
This parses a string and intelligently interprets the data type.
Parameters:
ejsEjs reference returned from ejsCreateVM
strString to parse.
prefTypePreferred type. Set to the reserved type slot number. E.g. S_Number, S_String etc.
Returns:
Returns an allocated object. Returns undefined if the input cannot be parsed.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsRemoveObserver (Ejs *ejs, EjsObj *emitter, EjsObj *name, struct EjsFunction *observer)

Remove an observer.

Parameters:
ejsInterpreter instance returned from ejsCreateVM
emitterEmitter created via ejsAddObserver
nameName of observed events. Can be an array of events.
observerObserver function provided to ejsAddObserver
Returns:
Zero if successful.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsSendEvent (Ejs *ejs, EjsObj *emitter, cchar *name, EjsAny *thisObj, EjsAny *arg)

Send an event to observers.

Description:
This call allows one argument to pass to the observer. If you need to pass more, use ejsSendEventv
Parameters:
ejsInterpreter instance returned from ejsCreateVM
emitterEmitter object.
nameName of event to fire.
thisObjObject to use for "this" when invoking the observer.
argArgument to pass to the observer.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsSendEventv (Ejs *ejs, EjsObj *emitter, cchar *name, EjsAny *thisObj, int argc, void *argv)

Send an event to observers.

Description:
This call allows multiple arguments to be passed to the observer. If you only need to pass one, use ejsSendEvent
Parameters:
ejsInterpreter instance returned from ejsCreateVM
emitterEmitter object.
nameName of event to fire.
thisObjObject to use for "this" when invoking the observer.
argcArgument count of argv.
argvArguments to pass to the observer.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsSetProperty (Ejs *ejs, void *obj, int slotNum, void *value)

Set a property's value.

Description:
Set a value for a property at a given slot in the specified variable.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to examine.
slotNumSlot number for the requested property.
valueReference to a value to store.
Returns:
The slot number of the property updated.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsSetPropertyByName (Ejs *ejs, void *obj, EjsName qname, void *value)

Set a property's value.

Description:
Set a value for a property. The property is located by name in the specified variable.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to examine.
qnameQualified property name.
valueReference to a value to store.
Returns:
The slot number of the property updated.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyName, ejsSetPropertyTraits
int ejsSetPropertyName (Ejs *ejs, EjsAny *obj, int slotNum, EjsName qname)

Set a property's name.

Description:
Set a qualified name for a property at the specified slot in the variable. The qualified name consists of a namespace and name - both of which must be persistent. A typical paradigm is for these name strings to be owned by the memory context of the variable.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objVariable to examine.
slotNumSlot number of the property in the variable.
qnameQualified property name.
Returns:
The slot number of the property updated.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyTraits
int ejsSetPropertyTraits (Ejs *ejs, EjsAny *obj, int slotNum, struct EjsType *type, int attributes)

Set a property's traits.

Description:
Set the traits describing a property. These include the property's base type and access attributes.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objVariable to examine.
slotNumSlot number of the property in the variable.
typeBase type for the property. Set to NULL for an untyped property.
attributesInteger mask of access attributes.
Returns:
The slot number of the property updated.
See Also:
ejsAlloc, ejsCastType, ejsClone, ejsCreateInstance, ejsCreateObj, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsGetLength, ejsGetProperty, ejsGetPropertyByName, ejsGetPropertyName, ejsGetPropertyTraits, ejsInvokeOperator, ejsInvokeOperatorDefault, ejsLookupProperty, ejsParse, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName

EjsPath

EjsPath

Path class.

Description:
The Path class provides file path name services.
See Also:
EjsFile, ejsCreatePath, ejsCreatePathFromAsc, ejsToPath
API Stability:
Internal.
Fields:
MprList *files File list for enumeration.
MprPathinfo Cached file info.
EjsObjobj Base object.
cchar *value Filename path.
EjsFileSystem * ejsCreateFileSystem (Ejs *ejs, cchar *path)

Create a FileSystem object.

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

Create a Path object.

Description:
Create a path object associated with the given pathname.
Parameters:
ejsEjs reference returned from ejsCreateVM
pathPath object.
Returns:
A new Path object.
See Also:
EjsFile, ejsCreatePathFromAsc, ejsToPath
EjsPath * ejsCreatePathFromAsc (Ejs *ejs, cchar *path)

Create a Path object.

Description:
Create a path object from the given ascii path string.
Parameters:
ejsEjs reference returned from ejsCreateVM
pathNull terminated Ascii pathname.
Returns:
A new Path object.
See Also:
EjsFile, ejsCreatePath, ejsToPath
void ejsLoadHttpService (Ejs *ejs)

Load the Http service.

Parameters:
ejsEjs reference returned from ejsCreateVM
See Also:
EjsFile, ejsCreatePath, ejsCreatePathFromAsc, ejsToPath
int ejsSetPathAttributes (Ejs *ejs, cchar *path, EjsObj *options)

Set the owner, group and permissions of a file.

Description:
Convert the object to a string and then to a Path.
Parameters:
ejsEjs reference returned from ejsCreateVM
pathPath name to modify.
optionsOwner, group and permissions options.
  • permissions optional Posix permissions number mask. Defaults to 0664.
  • owner String representing the file owner
  • group String representing the file group
Returns:
A new Path object.
See Also:
EjsFile, ejsCreatePath, ejsCreatePathFromAsc, ejsToPath
int ejsSetupHttpTrace (Ejs *ejs, HttpTrace *trace, EjsObj *options)

Setup tracing for Http transactions.

Parameters:
ejsEjs reference returned from ejsCreateVM
traceHttpTrace object.
optionsTrace options.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsFile, ejsCreatePath, ejsCreatePathFromAsc, ejsToPath
EjsPath * ejsToPath (Ejs *ejs, EjsAny *obj)

Convert the object to a Path.

Description:
Convert the object to a string and then to a Path.
Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to convert.
Returns:
A new Path object.
See Also:
EjsFile, ejsCreatePath, ejsCreatePathFromAsc

EjsPool

EjsPool

Cached pooled of virtual machines.

See Also:
ejsAllocPoolVM, ejsCreatePool, ejsFreePoolVM
API Stability:
Internal.
Fields:
intcount Count of allocated VMs.
char *hostedDocuments Documents directory for hosted HttpServer.
char *hostedHome Home directory for hosted HttpServer.
MprTickslastActivity When a VM was last used.
MprList *list Free list.
intmax Maximum number of VMs.
MprMutex *mutex Multithread lock.
char *startScript Template initialization literal script.
char *startScriptPath Template initialization script filename.
Ejs *template VM template to clone.
char *templateScript Template initialization script filename.
MprEvent *timer VM prune timer.
Ejs * ejsAllocPoolVM (EjsPool *pool, int flags)

Allocate a VM from the pool.

Parameters:
poolEjsPool reference.
flagsReserved.
Returns:
Returns an Ejs VM instance.
See Also:
ejsCreatePool, ejsFreePoolVM
EjsPool * ejsCreatePool (int poolMax, cchar *templateScript, cchar *startScript, cchar *startScriptPath, cchar *home, cchar *documents)

Create a pool for virutal machines.

Description:
Parameters:
poolMaxMaximum number of VMs in the pool.
templateScriptScript to execute to initialize a template VM from which all VMs in the pool will be cloned. This is executed only once when the pool is created. This is typically used to pre-load modules.
startScriptStartup script literal. This script is executed each time the VM is allocated from the pool.
startScriptPathAs an alternative to startScript, a path to a script may be provided in startScriptPath. If startScriptPath is specified, startScript is ignored.
homeDefault home directory for virtual machines.
documentsDefault documents directory for virtual machines.
Returns:
Allocated pool object.
See Also:
ejsAllocPoolVM, ejsFreePoolVM
void ejsFreePoolVM (EjsPool *pool, Ejs *ejs)

Free a VM back to the pool.

Parameters:
poolEjsPool reference.
ejsEjs reference returned from ejsCreateVM
See Also:
ejsAllocPoolVM, ejsCreatePool

EjsPot

EjsPot

Object with properties Type.

Description:
The EjsPot type is the foundation for types, blocks, functions and scripted classes. It provides storage and hashed lookup for properties.

EjsPots may be either dynamic or sealed. Dynamic objects can grow the number of properties. Sealed objects cannot. Sealed objects will store the properties as part of the EjsPot memory chunk. Dynamic objects will perform a separate allocation for the properties that it can grow.

EjsPot stores properties in an array of slots. These slots store the property name and a reference to the property value. Dynamic objects own their own name hash. Sealed object instances of a type, will refer to the hash of names owned by the type.
See Also:
ejsAlloc, ejsBlendObject, ejsCast, ejsCheckSlot, ejsClone, ejsClonePot, ejsCoerceOperands, ejsCompactPot, ejsCreateEmptyPot, ejsCreateInstance, ejsCreatePot, ejsCreatePotHelpers, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsFixTraits, ejsGetHashSize, ejsGetPotPropertyName, ejsGetProperty, ejsGrowPot, ejsIndexProperties, ejsInsertPotProperties, ejsIsPot, ejsLookupPotProperty, ejsLookupProperty, ejsManagePot, ejsMatchName, ejsObjToJSON, ejsObjToString, ejsParse, ejsPropertyHasTrait, ejsRemovePotProperty, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
API Stability:
Internal.
Fields:
uintisBlock Instance is a block.
uintisFrame Instance is a frame.
uintisFunction Instance is a function.
uintisPrototype Object is a type prototype object.
uintisType Instance is a type object.
intnumProp Object properties.
EjsObjobj Base object.
uintseparateHash Object has separate hash memory.
uintseparateSlots Object has separate slots[] memory.
uintshortScope Don't follow type or base classes.
int ejsBlendObject (Ejs *ejs, EjsObj *dest, EjsObj *src, int flags)

Blend objects.

Description:
Merge one object into another. This is useful for inheriting and optionally overwriting option hashes (among other things). The blending is done at the primitive property level. If overwrite is true, the property is replaced. If overwrite is false, the property will be added if it does not already exist index worthwhile.
Parameters:
ejsEjs reference returned from ejsCreateVM
destDestination object.
srcSource object.
flagsSelect from:
  • EJS_BLEND_DEEP - to copy nested objects recursively
  • EJS_BLEND_FUNCTIONS - to copy function properties
  • EJS_BLEND_OVERWRITE - to overwrite existing properties in the destination when copying from source
  • EJS_BLEND_SUBCLASSES - to copy subclasses in src
  • EJS_BLEND_PRIVATE - to copy private properties
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsPot, ejsAlloc, ejsCast, ejsCheckSlot, ejsClone, ejsClonePot, ejsCoerceOperands, ejsCompactPot, ejsCreateEmptyPot, ejsCreateInstance, ejsCreatePot, ejsCreatePotHelpers, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsFixTraits, ejsGetHashSize, ejsGetPotPropertyName, ejsGetProperty, ejsGrowPot, ejsIndexProperties, ejsInsertPotProperties, ejsIsPot, ejsLookupPotProperty, ejsLookupProperty, ejsManagePot, ejsMatchName, ejsObjToJSON, ejsObjToString, ejsParse, ejsPropertyHasTrait, ejsRemovePotProperty, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsCheckSlot (Ejs *ejs, EjsPot *obj, int slotNum)
EjsAny * ejsCoerceOperands (Ejs *ejs, EjsObj *lhs, int opcode, EjsObj *rhs)
void ejsCreatePotHelpers (Ejs *ejs)
void ejsFixTraits (Ejs *ejs, EjsPot *obj)
int ejsGetHashSize (int numProp)
EjsName ejsGetPotPropertyName (Ejs *ejs, EjsPot *obj, int slotNum)
int ejsIndexProperties (Ejs *ejs, EjsPot *obj)

Make or remake a property index.

Description:
Make a hash lookup of properties. This will be skipped if there are insufficient properties to make the index worthwhile.
Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to index.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsPot, ejsAlloc, ejsBlendObject, ejsCast, ejsCheckSlot, ejsClone, ejsClonePot, ejsCoerceOperands, ejsCompactPot, ejsCreateEmptyPot, ejsCreateInstance, ejsCreatePot, ejsCreatePotHelpers, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsFixTraits, ejsGetHashSize, ejsGetPotPropertyName, ejsGetProperty, ejsGrowPot, ejsInsertPotProperties, ejsIsPot, ejsLookupPotProperty, ejsLookupProperty, ejsManagePot, ejsMatchName, ejsObjToJSON, ejsObjToString, ejsParse, ejsPropertyHasTrait, ejsRemovePotProperty, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsInsertPotProperties (Ejs *ejs, EjsPot *pot, int numSlots, int offset)
bool ejsIsPot (Ejs *ejs, EjsAny *obj)
int ejsLookupPotProperty (Ejs *ejs, EjsPot *obj, EjsName qname)
bool ejsMatchName (Ejs *ejs, EjsName *a, EjsName *b)
struct EjsString * EjsString* ejsObjToJSON (Ejs *ejs, EjsObj *obj, int argc, EjsObj **argv)

Method proc for conversion to a JSON string.

Description:
This method provides the default conversion to a JSON string implementation.
Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to convert to a JSON string.
argcIgnored.
argvIgnored.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsPot, ejsAlloc, ejsBlendObject, ejsCast, ejsCheckSlot, ejsClone, ejsClonePot, ejsCoerceOperands, ejsCompactPot, ejsCreateEmptyPot, ejsCreateInstance, ejsCreatePot, ejsCreatePotHelpers, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsFixTraits, ejsGetHashSize, ejsGetPotPropertyName, ejsGetProperty, ejsGrowPot, ejsIndexProperties, ejsInsertPotProperties, ejsIsPot, ejsLookupPotProperty, ejsLookupProperty, ejsManagePot, ejsMatchName, ejsObjToString, ejsParse, ejsPropertyHasTrait, ejsRemovePotProperty, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
struct EjsString * EjsString* ejsObjToString (Ejs *ejs, EjsObj *obj, int argc, EjsObj **argv)

Method proc for conversion to a string.

Description:
This method provides the default conversion to a string implementation.
Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to convert to a string.
argcIgnored.
argvIgnored.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsPot, ejsAlloc, ejsBlendObject, ejsCast, ejsCheckSlot, ejsClone, ejsClonePot, ejsCoerceOperands, ejsCompactPot, ejsCreateEmptyPot, ejsCreateInstance, ejsCreatePot, ejsCreatePotHelpers, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsFixTraits, ejsGetHashSize, ejsGetPotPropertyName, ejsGetProperty, ejsGrowPot, ejsIndexProperties, ejsInsertPotProperties, ejsIsPot, ejsLookupPotProperty, ejsLookupProperty, ejsManagePot, ejsMatchName, ejsObjToJSON, ejsParse, ejsPropertyHasTrait, ejsRemovePotProperty, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsPropertyHasTrait (Ejs *ejs, EjsAny *obj, int slotNum, int attributes)

Test a property's traits.

Description:
Make a hash lookup of properties. This will be skipped if there are insufficient properties to make the index worthwhile.
Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to examine.
slotNumProperty slot number in obj to examine.
attributesAttribute mask to test with the selected property's traits.
Returns:
A mask of the selected attributes. Returns zero if none match.
See Also:
EjsPot, ejsAlloc, ejsBlendObject, ejsCast, ejsCheckSlot, ejsClone, ejsClonePot, ejsCoerceOperands, ejsCompactPot, ejsCreateEmptyPot, ejsCreateInstance, ejsCreatePot, ejsCreatePotHelpers, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsFixTraits, ejsGetHashSize, ejsGetPotPropertyName, ejsGetProperty, ejsGrowPot, ejsIndexProperties, ejsInsertPotProperties, ejsIsPot, ejsLookupPotProperty, ejsLookupProperty, ejsManagePot, ejsMatchName, ejsObjToJSON, ejsObjToString, ejsParse, ejsRemovePotProperty, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits
int ejsRemovePotProperty (Ejs *ejs, EjsAny *obj, int slotNum)

Remove a property.

Description:
Remove a property and compact previous properties. WARNING: this should only be used by the compiler.
Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to index.
slotNumProperty slot number to remove.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsPot, ejsAlloc, ejsBlendObject, ejsCast, ejsCheckSlot, ejsClone, ejsClonePot, ejsCoerceOperands, ejsCompactPot, ejsCreateEmptyPot, ejsCreateInstance, ejsCreatePot, ejsCreatePotHelpers, ejsDefineProperty, ejsDeleteProperty, ejsDeletePropertyByName, ejsDeserialize, ejsFixTraits, ejsGetHashSize, ejsGetPotPropertyName, ejsGetProperty, ejsGrowPot, ejsIndexProperties, ejsInsertPotProperties, ejsIsPot, ejsLookupPotProperty, ejsLookupProperty, ejsManagePot, ejsMatchName, ejsObjToJSON, ejsObjToString, ejsParse, ejsPropertyHasTrait, ejsSetProperty, ejsSetPropertyByName, ejsSetPropertyName, ejsSetPropertyTraits

EjsRegExp

EjsRegExp

RegExp Class.

Description:
The regular expression class provides string pattern matching and substitution.
See Also:
ejsCreateRegExp, ejsRegExpToString
API Stability:
Internal.
Fields:
void *compiled Compiled pattern (not alloced).
intendLastMatch End of the last match (one past end).
boolglobal Search for pattern globally (multiple times).
boolignoreCase Do case insensitive matching.
EjsString *matched Last matched component.
boolmultiline Match patterns over multiple lines.
EjsObjobj Base object.
intoptions Pattern matching options.
wchar *pattern Pattern to match.
intstartLastMatch Start of the last match.
EjsRegExp * ejsCreateRegExp (Ejs *ejs, cchar *pattern, cchar *flags)

Create a new regular expression object.

Parameters:
ejsEjs reference returned from ejsCreateVM
patternRegular expression pattern string. The regular expression string should not contain the leading or trailing slash. Embedded slash characters should not be back-quoted.
flagsRegular expression flags. Support flags include "g" for global match, "i" to ignore case, "m" match over multiple lines, "y" for sticky match.
Returns:
A EjsRegExp object.
See Also:
EjsRegExp, ejsRegExpToString
EjsRegExp * ejsParseRegExp (Ejs *ejs, EjsString *pattern)

Parse a string and create a regular expression object.

Parameters:
ejsEjs reference returned from ejsCreateVM
patternRegular expression pattern string.
Returns:
A EjsRegExp object.
See Also:
EjsRegExp, ejsCreateRegExp, ejsRegExpToString
EjsString * ejsRegExpToString (Ejs *ejs, EjsRegExp *rp)

Get a string representation of a regular expression.

Parameters:
ejsEjs reference returned from ejsCreateVM
rpRegular expression.
Returns:
A string representation of a regular expression. The result will be of the format: "/PATTERN/suffixes".
See Also:
EjsRegExp, ejsCreateRegExp

EjsRequest

EjsRequest

Request Class.

Description:
Request objects represent a single Http request.
API Stability:
Prototype.
See Also:
ejsCloneRequest, ejsCreateRequest
Fields:
EjsObj *absHome Absolute URI to the home of the application from this request.
struct EjsRequest *cloned Request that was cloned.
intclosed Request closed and "close" event has been issued.
EjsObj *config Request config environment.
HttpConn *conn Underlying Http connection object.
EjsObj *cookies Cached cookies.
EjsPath *dir Home directory containing the application.
intdontAutoFinalize Suppress auto-finalization.
Ejs *ejs Ejscript interpreter handle.
EjsObj *emitter Event emitter.
EjsObj *env Request.env.
interror Request errored and "error" event has been issued.
EjsPath *filename Physical resource filename.
EjsObj *files Files object.
intfinalized Request has written all output data.
EjsString *formData Form data as a stable, sorted string.
EjsObj *headers Headers object.
EjsUri *home Relative URI to the home of the application from this request.
EjsString *host Host property.
EjsObj *limits Limits object.
EjsObj *log Log object.
EjsObj *originalUri Saved original URI.
EjsObj *params Form variables + routing variables.
EjsString *pathInfo PathInfo property.
EjsNumber *port Port property.
EjsPotpot Base object storage.
intprobedSession Determined if a session exists.
EjsString *query Query property.
EjsString *reference Reference property.
EjsObj *responseHeaders Headers object.
EjsObj *route Matching route in route table.
intrunning Request has started.
EjsString *scheme Scheme property.
EjsString *scriptName ScriptName property.
EjsHttpServer *server Owning server.
struct EjsSession *session Current session.
EjsUri *uri Complete uri.
EjsByteArray *writeBuffer Write buffer for capturing output.
ssizewritten Count of data bytes written to the client.
EjsRequest * ejsCloneRequest (Ejs *ejs, EjsRequest *req, bool deep)

Clone a request into another interpreter.

Parameters:
ejsEjs interpreter handle returned from $ejsCreate.
reqOriginal request to copy.
deepIgnored.
Returns:
A new request object.
See Also:
EjsRequest, ejsCreateRequest
EjsRequest * ejsCreateRequest (Ejs *ejs, EjsHttpServer *server, HttpConn *conn, cchar *dir)

Create a new request.

Create a new request object associated with the given Http connection
Parameters:
ejsEjs interpreter handle returned from $ejsCreate.
serverEjsHttpServer owning this request.
connHttp connection object.
dirDefault directory containing web documents.
Returns:
A new request object.
See Also:
EjsRequest, ejsCloneRequest

EjsSession

EjsSession

Session Class.

Description:
Session objects represent a shared session state object into which Http Requests and store and retrieve data that persists beyond a single request.
API Stability:
Prototype.
See Also:
ejsDestroySession, ejsGetSession
Fields:
int ejsDestroySession (Ejs *ejs, EjsSession *session)

Destroy as session.

This destroys the session object so that subsequent requests will need to establish a new session
Parameters:
ejsEjs interpreter handle returned from $ejsCreate.
sessionSession object created via ejsGetSession()
See Also:
EjsSession, ejsGetSession
EjsSession * ejsGetSession (Ejs *ejs, EjsString *key, MprTicks timeout, int create)

Get a session object for a given key.

This will create a session if the given key is NULL or has expired
Parameters:
ejsEjs interpreter handle returned from $ejsCreate.
keyString containing the session ID.
timeoutTimeout to use for the session if one is created.
createCreate a new session if an existing session cannot be found or it has expired.
Returns:
A new session object.
See Also:
EjsSession, ejsDestroySession
void ejsSetSessionTimeout (Ejs *ejs, EjsSession *sp, MprTicks lifespan)

Set a session timeout.

Parameters:
ejsEjs interpreter handle returned from $ejsCreate.
spSession object.
lifespanLifespan in milliseconds.
See Also:
EjsSession, ejsDestroySession, ejsGetSession

EjsSocket

EjsSocket

Socket Class.

Description:
See Also:
ejsCreateSocket
API Stability:
Internal.
Fields:
char *address Remote address.
intasync In async mode.
EjsByteArray *data Buffered write data.
Ejs *ejs Interp reference.
EjsObj *emitter Event emitter.
intmask IO event mask.
MprMutex *mutex Multithread sync.
EjsObjobj Base object.
intport Remote port.
MprSocket *sock Underlying MPR socket object.
EjsSocket * ejsCreateSocket (Ejs *ejs, MprSocket *sock, bool async)

Create a new Socket object.

Parameters:
ejsEjs reference returned from ejsCreateVM
sockSocket object.
asyncTrue if running in async non-blocking mode.
Returns:
A new Socket object.
See Also:
EjsSocket

EjsString

EjsString

String Class.

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

Strings are currently sequences of Unicode characters. Depending on the configuration, they may be 8, 16 or 32 bit code point values.
See Also:
ejsAtoi, ejsCompareAsc, ejsCompareString, ejsCompareSubstring, ejsCompareWide, ejsContainsAsc, ejsContainsChar, ejsContainsString, ejsCreateBareString, ejsCreateString, ejsCreateStringFromAsc, ejsCreateStringFromBytes, ejsCreateStringFromConst, ejsCreateStringFromMulti, ejsDestroyIntern, ejsInternAsc, ejsInternMulti, ejsInternString, ejsInternWide, ejsJoinString, ejsJoinStrings, ejsSerialize, ejsSerializeWithOptions, ejsSprintf, ejsStartsWithAsc, ejsSubstring, ejsToJSON, ejsToLower, ejsToMulti, ejsToString, ejsToUpper, ejsTruncateString
API Stability:
Internal.
Fields:
ssizelength Length of string.
struct EjsString *next Next string in hash chain link when interning.
struct EjsObjobj Base object.
struct EjsString *prev Prev string in hash chain.
wcharvalue[ARRAY_FLEX] String value.
int ejsAtoi (Ejs *ejs, EjsString *sp, int radix)
int ejsCompareAsc (Ejs *ejs, EjsString *s1, cchar *s2)
int ejsCompareString (Ejs *ejs, EjsString *s1, EjsString *s2)
int ejsCompareSubstring (Ejs *ejs, EjsString *s1, EjsString *s2, ssize offset, ssize len)

Compare a substring.

Description:
This call compares the first string with a substring in the second.
Parameters:
ejsEjs reference returned from ejsCreateVM
s1First string to compare.
s2Second string.
offsetOffset in string to take the substring.
lenLength of the substring.
Returns:
Return zero if the strings are identical. Return -1 if s1 is less than s2. Otherwise return 1.
See Also:
EjsString, ejsAtoi, ejsCompareAsc, ejsCompareString, ejsCompareWide, ejsContainsAsc, ejsContainsChar, ejsContainsString, ejsCreateBareString, ejsCreateString, ejsCreateStringFromAsc, ejsCreateStringFromBytes, ejsCreateStringFromConst, ejsCreateStringFromMulti, ejsDestroyIntern, ejsInternAsc, ejsInternMulti, ejsInternString, ejsInternWide, ejsJoinString, ejsJoinStrings, ejsSerialize, ejsSerializeWithOptions, ejsSprintf, ejsStartsWithAsc, ejsSubstring, ejsToJSON, ejsToLower, ejsToMulti, ejsToString, ejsToUpper, ejsTruncateString
int ejsCompareWide (Ejs *ejs, EjsString *s1, wchar *s2, ssize len)

Compare a string with a wide string.

Parameters:
ejsEjs reference returned from ejsCreateVM
s1First string.
s2Wide string.
lenMaximum length in characters to compare.
Returns:
Return zero if the strings are identical. Return -1 if s1 is less than s2. Otherwise return 1.
See Also:
EjsString, ejsAtoi, ejsCompareAsc, ejsCompareString, ejsCompareSubstring, ejsContainsAsc, ejsContainsChar, ejsContainsString, ejsCreateBareString, ejsCreateString, ejsCreateStringFromAsc, ejsCreateStringFromBytes, ejsCreateStringFromConst, ejsCreateStringFromMulti, ejsDestroyIntern, ejsInternAsc, ejsInternMulti, ejsInternString, ejsInternWide, ejsJoinString, ejsJoinStrings, ejsSerialize, ejsSerializeWithOptions, ejsSprintf, ejsStartsWithAsc, ejsSubstring, ejsToJSON, ejsToLower, ejsToMulti, ejsToString, ejsToUpper, ejsTruncateString
int ejsContainsAsc (Ejs *ejs, EjsString *sp, cchar *pat)
int ejsContainsChar (Ejs *ejs, EjsString *sp, int charPat)
int ejsContainsString (Ejs *ejs, EjsString *sp, EjsString *pat)
EjsString * ejsCreateBareString (Ejs *ejs, ssize len)

Create an empty string object.

This creates an uninitialized string object of the requrired size. Once initialized, the string must be "interned" via $ejsInternString
Parameters:
ejsEjs reference returned from ejsCreateVM
lenLength of space to reserve for future string data.
Returns:
A string object.
See Also:
EjsString, ejsAtoi, ejsCompareAsc, ejsCompareString, ejsCompareSubstring, ejsCompareWide, ejsContainsAsc, ejsContainsChar, ejsContainsString, ejsCreateString, ejsCreateStringFromAsc, ejsCreateStringFromBytes, ejsCreateStringFromConst, ejsCreateStringFromMulti, ejsDestroyIntern, ejsInternAsc, ejsInternMulti, ejsInternString, ejsInternWide, ejsJoinString, ejsJoinStrings, ejsSerialize, ejsSerializeWithOptions, ejsSprintf, ejsStartsWithAsc, ejsSubstring, ejsToJSON, ejsToLower, ejsToMulti, ejsToString, ejsToUpper, ejsTruncateString
EjsString * ejsCreateString (Ejs *ejs, wchar *value, ssize len)
EjsString * ejsCreateStringFromAsc (Ejs *ejs, cchar *value)
EjsString * ejsCreateStringFromBytes (Ejs *ejs, cchar *value, ssize len)
EjsString * ejsCreateStringFromConst (Ejs *ejs, struct EjsModule *mp, int index)
EjsString * ejsCreateStringFromMulti (Ejs *ejs, cchar *value, ssize len)
void ejsDestroyIntern (struct EjsIntern *intern)
EjsString * ejsInternAsc (struct Ejs *ejs, cchar *value, ssize len)

Intern a string object from an Ascii string.

Description:
A string is created using the ascii string as input.
Parameters:
ejsEjs reference returned from ejsCreateVM
valueAscii string buffer.
lenSize of the input value string.
Returns:
The internalized string object.
See Also:
EjsString, ejsAtoi, ejsCompareAsc, ejsCompareString, ejsCompareSubstring, ejsCompareWide, ejsContainsAsc, ejsContainsChar, ejsContainsString, ejsCreateBareString, ejsCreateString, ejsCreateStringFromAsc, ejsCreateStringFromBytes, ejsCreateStringFromConst, ejsCreateStringFromMulti, ejsDestroyIntern, ejsInternMulti, ejsInternString, ejsInternWide, ejsJoinString, ejsJoinStrings, ejsSerialize, ejsSerializeWithOptions, ejsSprintf, ejsStartsWithAsc, ejsSubstring, ejsToJSON, ejsToLower, ejsToMulti, ejsToString, ejsToUpper, ejsTruncateString
EjsString * ejsInternMulti (struct Ejs *ejs, cchar *value, ssize len)

Intern a string object from a UTF-8 string.

Description:
A string is created using the UTF-8 string as input.
Parameters:
ejsEjs reference returned from ejsCreateVM
valueUTF-8 string buffer.
lenSize of the input value string.
Returns:
The internalized string object.
See Also:
EjsString, ejsAtoi, ejsCompareAsc, ejsCompareString, ejsCompareSubstring, ejsCompareWide, ejsContainsAsc, ejsContainsChar, ejsContainsString, ejsCreateBareString, ejsCreateString, ejsCreateStringFromAsc, ejsCreateStringFromBytes, ejsCreateStringFromConst, ejsCreateStringFromMulti, ejsDestroyIntern, ejsInternAsc, ejsInternString, ejsInternWide, ejsJoinString, ejsJoinStrings, ejsSerialize, ejsSerializeWithOptions, ejsSprintf, ejsStartsWithAsc, ejsSubstring, ejsToJSON, ejsToLower, ejsToMulti, ejsToString, ejsToUpper, ejsTruncateString
EjsString * ejsInternString (EjsString *sp)

Intern a string object.

Description:
This stores the string in the internal string pool. This is required if the string was created via ejsCreateBareString. The ejsCreateString routine will intern the string automatcially.
Parameters:
spString object to intern.
Returns:
The internalized string object. NOTE: this may be different to the object passed in, if the string value was already present in the intern pool.
See Also:
EjsString, ejsAtoi, ejsCompareAsc, ejsCompareString, ejsCompareSubstring, ejsCompareWide, ejsContainsAsc, ejsContainsChar, ejsContainsString, ejsCreateBareString, ejsCreateString, ejsCreateStringFromAsc, ejsCreateStringFromBytes, ejsCreateStringFromConst, ejsCreateStringFromMulti, ejsDestroyIntern, ejsInternAsc, ejsInternMulti, ejsInternWide, ejsJoinString, ejsJoinStrings, ejsSerialize, ejsSerializeWithOptions, ejsSprintf, ejsStartsWithAsc, ejsSubstring, ejsToJSON, ejsToLower, ejsToMulti, ejsToString, ejsToUpper, ejsTruncateString
EjsString * ejsInternWide (struct Ejs *ejs, wchar *value, ssize len)

Intern a string object from a UTF-16 string.

Description:
A string is created using the UTF-16 string as input.
Parameters:
ejsEjs reference returned from ejsCreateVM
valueUTF-16 string buffer.
lenSize of the input value string.
Returns:
The internalized string object.
See Also:
EjsString, ejsAtoi, ejsCompareAsc, ejsCompareString, ejsCompareSubstring, ejsCompareWide, ejsContainsAsc, ejsContainsChar, ejsContainsString, ejsCreateBareString, ejsCreateString, ejsCreateStringFromAsc, ejsCreateStringFromBytes, ejsCreateStringFromConst, ejsCreateStringFromMulti, ejsDestroyIntern, ejsInternAsc, ejsInternMulti, ejsInternString, ejsJoinString, ejsJoinStrings, ejsSerialize, ejsSerializeWithOptions, ejsSprintf, ejsStartsWithAsc, ejsSubstring, ejsToJSON, ejsToLower, ejsToMulti, ejsToString, ejsToUpper, ejsTruncateString
EjsString * ejsJoinString (Ejs *ejs, EjsString *s1, EjsString *s2)
EjsString * ejsJoinStrings (Ejs *ejs, EjsString *src, ...)
EjsString * ejsSerialize (Ejs *ejs, EjsAny *obj, int flags)

Serialize a variable into JSON format.

Parameters:
ejsEjs reference returned from ejsCreateVM
objValue to cast.
flagsSerialization options. The supported options are:
  • EJS_JSON_SHOW_COMMAS - Always use commas after properties
  • EJS_JSON_SHOW_HIDDEN - Include hidden properties
  • EJS_JSON_SHOW_NOQUOTES - Omit quotes on properties if possible
  • EJS_JSON_SHOW_NAMESPACES - Include namespaces in property names
  • EJS_JSON_SHOW_NULLS - Include null properties
  • EJS_JSON_SHOW_REGEXP - Emit native regular expression literals
  • EJS_JSON_SHOW_PRETTY - Use human-readable multiline presentation
  • EJS_JSON_SHOW_SUBCLASSES - Include subclass properties
Returns:
A string object.
See Also:
EjsString, ejsAtoi, ejsCompareAsc, ejsCompareString, ejsCompareSubstring, ejsCompareWide, ejsContainsAsc, ejsContainsChar, ejsContainsString, ejsCreateBareString, ejsCreateString, ejsCreateStringFromAsc, ejsCreateStringFromBytes, ejsCreateStringFromConst, ejsCreateStringFromMulti, ejsDestroyIntern, ejsInternAsc, ejsInternMulti, ejsInternString, ejsInternWide, ejsJoinString, ejsJoinStrings, ejsSerializeWithOptions, ejsSprintf, ejsStartsWithAsc, ejsSubstring, ejsToJSON, ejsToLower, ejsToMulti, ejsToString, ejsToUpper, ejsTruncateString
EjsString * ejsSerializeWithOptions (Ejs *ejs, EjsAny *obj, EjsObj *options)

Serialize a variable into JSON format.

Parameters:
ejsEjs reference returned from ejsCreateVM
objValue to cast.
optionsSerialization options. The supported options are:
  • baseClasses - Include subclass properties
  • hidden - Include hidden properties
  • namespaces - Include namespaces in property names
  • pretty - Use human-readable multiline presentation
  • depth - Set a maximum depth to recurse in the object
  • replacer - Function that determines how object values are stringified for objects without a toJSON method. The replace has the following signature: function replacer(key: String, value: String): String
Returns:
A string object.
See Also:
EjsString, ejsAtoi, ejsCompareAsc, ejsCompareString, ejsCompareSubstring, ejsCompareWide, ejsContainsAsc, ejsContainsChar, ejsContainsString, ejsCreateBareString, ejsCreateString, ejsCreateStringFromAsc, ejsCreateStringFromBytes, ejsCreateStringFromConst, ejsCreateStringFromMulti, ejsDestroyIntern, ejsInternAsc, ejsInternMulti, ejsInternString, ejsInternWide, ejsJoinString, ejsJoinStrings, ejsSerialize, ejsSprintf, ejsStartsWithAsc, ejsSubstring, ejsToJSON, ejsToLower, ejsToMulti, ejsToString, ejsToUpper, ejsTruncateString
EjsString * ejsSprintf (Ejs *ejs, cchar *fmt, ...)
int ejsStartsWithAsc (Ejs *ejs, EjsString *sp, cchar *pat)
EjsString * ejsSubstring (Ejs *ejs, EjsString *src, ssize offset, ssize len)
EjsString * ejsToJSON (Ejs *ejs, EjsAny *obj, EjsObj *options)
EjsString * ejsToLower (Ejs *ejs, EjsString *sp)
char * ejsToMulti (Ejs *ejs, void *obj)
EjsString * ejsToString (Ejs *ejs, EjsAny *obj)
EjsString * ejsToUpper (Ejs *ejs, EjsString *sp)
EjsString * ejsTruncateString (Ejs *ejs, EjsString *src, ssize len)

EjsTimer

EjsTimer

Timer Class.

Description:
Timers manage the scheduling and execution of Ejscript functions. Timers run repeatedly until stopped by calling the stop method and are scheduled with a granularity of 1 millisecond.
See Also:
API Stability:
Internal.
Fields:
EjsArray *args Callback args.
EjsFunction *callback Callback function.
intdrift Timer event is allowed to drift if system conditions requrie.
Ejs *ejs Interp reference - needed for background timers.
MprEvent *event MPR event for the timer.
EjsObjobj Base object.
EjsFunction *onerror onerror function.
intperiod Time in msec between invocations.
intrepeat Timer repeatedly fires.

EjsType

EjsType

Type class.

Description:
Classes in Ejscript are represented by instances of an EjsType. Types are templates for creating instances of the given type, but they are also are runtime accessible objects. Types contain the static properties and methods for objects and store these in their object slots array. They store the instance properties in the type->instance object. EjsType inherits from EjsBlock, EjsObj and EjsObj.
See Also:
ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
API Stability:
Internal.
Fields:
uint__pad0__ Type is mutable (has changable state).
struct EjsType *baseType Base class.
uintcallsSuper Constructor calls super().
uintconfigured Type has been configured with native methods.
EjsFunctionconstructor Constructor function and type properties.
uintdynamicInstances Object instances may add properties.
intendClass Offset in mod file for end of class.
uintfinal Type is final.
uinthasBaseConstructors Base types has constructors.
uinthasBaseInitializers Base types have initializers.
uinthasConstructor Type has a constructor.
uinthasInitializer Type has static level initialization code.
uinthasInstanceVars Type has non-function instance vars (state).
uinthasMeta Type has meta methods.
uinthasScriptFunctions Block has non-native functions requiring namespaces.
EjsHelpershelpers Type helper methods.
MprList *implements List of implemented interfaces.
uintinitialized Static initializer has run.
ushortinstanceSize Size of instances in bytes.
uintisInterface Interface vs class.
uintisPot Instances are based on EjsPot.
MprManagermanager Manager callback.
struct EjsModule *module Module owning the type - stores the constant pool.
uintmutableInstances Instances are mutable.
MprMutex *mutex Optional locking for types that require it.
uintneedFixup Slots need fixup.
uintnumericIndicies Instances support direct numeric indicies.
ushortnumInherited Number of inherited prototype properties.
EjsPot *prototype Prototype for instances when using prototype inheritance (only).
EjsNameqname Qualified name of the type. Type name and namespace.
shortsid Slot index into service->immutable[].
void *typeData Type specific data.
uintvirtualSlots Properties are not stored in slots[].
int ejsBindAccess (Ejs *ejs, EjsAny *obj, int slotNum, void *getter, void *setter)

Bind a native C functions to method accessors.

Description:
Bind a native C function to an existing javascript accessor function. Method functions are typically created by compiling a script file of native method definitions into a mod file. When loaded, this mod file will create the method properties. This routine will then bind the specified C function to the method accessor.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objType containing the function property to bind.
slotNumSlot number of the method property.
getterNative C getter function to bind. Set to NULL if no getter.
setterNative C setter function to bind. Set to NULL if no setter.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsType, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
void ejsBindConstructor (Ejs *ejs, EjsType *type, void *constructor)

Bind a constructor.

Description:
Bind a native C function to a type as a constructor function.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
typeType to modify.
constructorNative C constructor function to bind.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsType, ejsBindAccess, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
int ejsBindFunction (Ejs *ejs, EjsAny *obj, int slotNum, void *fun)

Bind a native C function to a function property.

Description:
Bind a native C function to an existing javascript function. Functions are typically created by compiling a script file of native function definitions into a mod file. When loaded, this mod file will create the function properties. This routine will then bind the specified C function to the function property.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject containing the function property to bind.
slotNumSlot number of the method property.
funNative C function to bind.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
int ejsBindMethod (Ejs *ejs, EjsAny *obj, int slotNum, void *fn)

Bind a native C function to a method property.

Description:
Bind a native C function to an existing javascript method. Method functions are typically created by compiling a script file of native method definitions into a mod file. When loaded, this mod file will create the method properties. This routine will then bind the specified C function to the method property.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
objType containing the function property to bind.
slotNumSlot number of the method property.
fnNative C function to bind.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
EjsAny * ejsCast (Ejs *ejs, EjsAny *obj, void *name)

Cast the object to the given type name.

Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to examine.
nameTextual name of the type (Not void*). For example: ejsCast(ejs, obj, String).
Returns:
Casted object.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
EjsType * ejsConfigureType (Ejs *ejs, EjsType *type, struct EjsModule *up, EjsType *baseType, int numTypeProp, int numInstanceProp, int64 attributes)

Configure a type.

Description:
Called by loader to configure a native type based on the mod file information.
Parameters:
ejsEjs reference returned from ejsCreateVM
typeType to configure.
upReference to a module that will own the type. Set to null if not owned by any module.
baseTypeBase type for this type.
numTypePropNumber of type (class) properties for the type. These include static properties and methods.
numInstancePropNumber of instance properties.
attributesAttribute mask to modify how the type is initialized.
Returns:
The configured type.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
EjsType * ejsCreateArchetype (Ejs *ejs, struct EjsFunction *fun, EjsPot *prototype)

Create an Archetype.

Description:
Archetypes are used when functions are used as constructors.
Parameters:
ejsEjs reference returned from ejsCreateVM
funFunction object to use as a constructor.
prototypePrototype object. If set to null, a new prototype is created.
Returns:
A new type object.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
EjsType * ejsCreateCoreType (Ejs *ejs, EjsName qname, int size, int slotNum, int numTypeProp, void *manager, int64 attributes)

Create a core type object.

Description:
Create a new type object.
Parameters:
ejsEjs reference returned from ejsCreateVM
qnameQualified name to give the type. This name is referenced by the type and must be persistent. This name is not used to define the type as a global property.
sizeSize in bytes to reserve for the type.
slotNumGlobal slot number property index.
numTypePropNumber of type (class) properties for the type. These include static properties and methods.
managerMPR manager routine for garbage collection.
attributesAttribute mask to modify how the type is initialized.
Returns:
The created type.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
EjsObj * ejsCreatePrototype (Ejs *ejs, EjsType *type, int numProp)

Create a type prototype.

Description:
This creates a prototype object from which instances are crafted.
Parameters:
ejsEjs reference returned from ejsCreateVM
typeType object.
numPropNumber of instance properties in the prototype.
Returns:
The prototype object.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
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.

Description:
Create a new type object.
Parameters:
ejsEjs reference returned from ejsCreateVM
nameQualified name to give the type. This name is referenced by the type and must be persistent. This name is not used to define the type as a global property.
upReference to a module that will own the type. Set to null if not owned by any module.
baseTypeBase type for this type.
prototypePrototype object instance properties of this type.
sizeSize of instances. This is the size in bytes of an instance object.
slotNumUnique type ID for core types. For non-core types, set to -1.
numTypePropNumber of type (class) properties for the type. These include static properties and methods.
numInstancePropNumber of instance properties.
managerMPR manager routine for garbage collection.
attributesAttribute mask to modify how the type is initialized.
Returns:
The created type.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
int ejsDefineGlobalFunction (Ejs *ejs, EjsString *name, EjsProc fn)

Define a global function.

Description:
Define a global public function and bind it to the C native function. This is a simple one liner to define a public global function. The more typical paradigm to define functions is to create a script file of native method definitions and and compile it. This results in a mod file that can be loaded which will create the function/method definitions. Then use ejsBindMethod to associate a C function with a property.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
nameFunction name.
fnC function that implements the function.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
int ejsDefineInstanceProperty (Ejs *ejs, EjsType *type, int slotNum, EjsName name, EjsType *propType, int attributes, EjsAny *value)

Define an instance property.

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

Finalize a core type.

Description:
This sets the configured state for the type.
Parameters:
ejsEjs reference returned from ejsCreateVM
qnameQualified name of the type.
Returns:
The finalized type.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
EjsType * ejsFinalizeScriptType (Ejs *ejs, EjsName qname, int size, void *manager, int64 attributes)

Finalize a script type.

Description:
This finalizes the type and sets the configured state for the type.
Parameters:
ejsEjs reference returned from ejsCreateVM
qnameQualified name of the type.
sizeInstance size of the type.
managerManager function for garbage collection.
attributesType attributes.
Returns:
The configured type.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
EjsPot * ejsGetPrototype (Ejs *ejs, EjsAny *obj)

Get the prototype object for an object.

Parameters:
ejsInterpreter instance returned from ejsCreateVM
objObject to examine.
Returns:
Prototype object for the given object.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
EjsType * ejsGetType (Ejs *ejs, int slotNum)

Get a type.

Description:
Get the type installed at the given slot number. All core-types are installed a specific global slots. When Ejscript is built, these slots are converted into C program defines of the form: ES_TYPE where TYPE is the name of the type concerned. For example, you can get the String type object via:.
EjsGetType(ejs, ES_String).
Parameters:
ejsInterpreter instance returned from ejsCreateVM
slotNumSlot number of the type to retrieve. Use ES_TYPE defines.
Returns:
A type object if successful or zero if the type could not be found.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
EjsType * ejsGetTypeByName (Ejs *ejs, EjsName qname)

Get a type given its name.

Description:
Types are stored in the global object. This routine looks in the global object for the type property.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
qnameQualified name of the type.
Returns:
The type object.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
EjsString * ejsGetTypeName (struct Ejs *ejs, EjsAny *obj)
EjsString * ejsGetTypeOf (struct Ejs *ejs, EjsAny *obj)

TypeOf operator.

Description:
This finalizes the type and sets the configured state for the type.
Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to examine.
Returns:
String type name for the "typeOf" operator.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
bool ejsIs (Ejs *ejs, EjsAny *obj, void *name)

Test the type of an object.

Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to examine.
nameTextual name of the type (Not void*). For example: ejsIs(ejs, obj, Number).
Returns:
True if the object is of the tested type.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
bool ejsIsA (Ejs *ejs, EjsAny *target, EjsType *type)

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

Description:
Perform an "is a" test. This tests if a variable is a direct instance or subclass of a given base type.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
targetTarget object to test.
typeType to compare with the target.
Returns:
True if target is an instance of "type" or an instance of a subclass of "type".
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsDefined, ejsIsType, ejsIsTypeSubType
bool ejsIsDefined (Ejs *ejs, EjsAny *obj)

Test the object is not null and not undefined.

Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to examine.
Returns:
True if the object is of a defined type.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsType, ejsIsTypeSubType
bool ejsIsPrototype (Ejs *ejs, EjsAny *obj)

Determine if a variable is a prototype object.

Types store the template for instance properties in a prototype object
Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to test.
Returns:
True if the variable is a prototype object.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType
bool ejsIsType (Ejs *ejs, EjsAny *obj)
bool ejsIsTypeSubType (Ejs *ejs, EjsType *target, EjsType *baseType)

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

Description:
Test if a type subclasses a base type.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
targetTarget type to test.
baseTypeBase class to see if the target subclasses it.
Returns:
True if target is a "baseType" or a subclass of "baseType".
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType
int ejsRunProgram (Ejs *ejs, cchar *className, cchar *methodName)

Run a program.

Description:
Lookup the className and run the designated method. If methodName is null, then "main" is run. The method should be a static method of the class.
Parameters:
ejsInterpreter instance returned from ejsCreateVM
classNameClass name to search for methodName.
methodNameMethod to run. If set to NULL, then search for "main".
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsType, ejsBindAccess, ejsBindConstructor, ejsBindMethod, ejsCast, ejsConfigureType, ejsCreateArchetype, ejsCreateCoreType, ejsCreatePrototype, ejsCreateType, ejsDefineGlobalFunction, ejsDefineInstanceProperty, ejsFinalizeCoreType, ejsFinalizeScriptType, ejsGetPrototype, ejsGetType, ejsGetTypeByName, ejsIs, ejsIsA, ejsIsDefined, ejsIsType, ejsIsTypeSubType

EjsUri

EjsUri

Uri class.

Description:
The Uri class provides file path name services.
See Also:
EjsFile, ejsCreateUri, ejsCreateUriFromAsc, ejsCreateUriFromParts, ejsToUri
API Stability:
Internal.
Fields:
EjsObjobj Base object.
HttpUri *uri Decoded URI.
EjsUri * ejsCreateUri (Ejs *ejs, EjsString *uri)

Create a Uri object.

Description:
Create a URI object associated with the given URI string.
Parameters:
ejsEjs reference returned from ejsCreateVM
uriUri string to parse.
Returns:
A new Uri object.
See Also:
EjsFile, ejsCreateUriFromAsc, ejsCreateUriFromParts, ejsToUri
EjsUri * ejsCreateUriFromAsc (Ejs *ejs, cchar *uri)

Create a URI from an ascii path.

Parameters:
ejsEjs reference returned from ejsCreateVM
uriURI Ascii string.
Returns:
A new URI object.
See Also:
EjsFile, ejsCreateUri, ejsCreateUriFromParts, ejsToUri
EjsUri * ejsCreateUriFromParts (Ejs *ejs, cchar *scheme, cchar *host, int port, cchar *path, cchar *query, cchar *reference, int flags)
Description:
This call constructs a URI from the given parts. Various URI parts can be omitted by setting to null. The URI path is the only mandatory parameter.
Parameters:
ejsEjs reference returned from ejsCreateVM
schemeThe URI scheme. This is typically "http" or "https".
hostThe URI host name portion. This can be a textual host and domain name or it can be an IP address.
portThe URI port number. Set to zero to accept the default value for the selected scheme.
pathThe URI path to the requested document.
referenceURI reference with an HTML document. This is the URI component after the "#" in the URI path.
queryURI query component. This is the URI component after the "?" in the URI.
flagsSet to HTTP_COMPLETE_URI to complete the URI by supplying missing URI parts with default values.
Returns:
A new URI.
See Also:
EjsFile, ejsCreateUri, ejsCreateUriFromAsc, ejsToUri
EjsUri * ejsToUri (Ejs *ejs, EjsAny *obj)

Convert an object to a URI.

Description:
The object is first converted to a String and then to a URI.
Parameters:
ejsEjs reference returned from ejsCreateVM
objAny object.
Returns:
A new URI object.
See Also:
EjsFile, ejsCreateUri, ejsCreateUriFromAsc, ejsCreateUriFromParts

EjsVoid

EjsVoid

Void class.

Description:
The Void class provides the base class for the singleton "undefined" instance. This instance is stored in ejs->undefinedValue.
API Stability:
Evolving.
See Also:
ejsCreateUndefined
Fields:
EjsVoid * ejsCreateUndefined (Ejs *ejs)

Create the undefined object.

Description:
There is one undefined object in the system.
Parameters:
ejsEjs reference returned from ejsCreateVM
Returns:
The undefined object.
See Also:
EjsVoid

EjsWebSocket

EjsWebSocket

WebSocket Class.

Description:
Client side WebSocket support.
See Also:
ejsCreateWebSocket
API Stability:
Internal.
Fields:
char *certFile SSL certificate file.
intclosed Http is closed and "close" event has been issued.
HttpConn *conn Underlying HttpConn object.
Ejs *ejs Interp reference.
EjsObj *emitter Event emitter.
interror Http errored and "error" event has been issued.
intframes Preserve frames.
EjsPotpot Base pot.
char *protocol Protocol selected by the server.
char *protocols Set of supported protocols.
MprSsl *ssl SSL configuration.
char *uri Target URI.
EjsWebSocket * ejsCreateWebSocket (Ejs *ejs)

Create a new WebSocket object.

Parameters:
ejsEjs reference returned from ejsCreateVM
Returns:
A new WebSocket object.
See Also:
EjsWebSocket

EjsWorker

EjsWorker

Worker Class.

Description:
The Worker class provides the ability to create new interpreters in dedicated threads.
See Also:
EjsObj, ejsCreateWorker, ejsRemoveWorkers
API Stability:
Internal.
Fields:
intcomplete Worker has completed its work.
Ejs *ejs Interpreter.
EjsAny *event Current event object.
intgotMessage Worker has received a message.
intinside Running inside the worker.
char *name Optional worker name.
struct EjsWorker *pair Corresponding worker object in other thread.
EjsPotpot Property storage.
char *scriptFile Script or module to run.
EjsString *scriptLiteral Literal script string to run.
intstate Worker state.
EjsWorker * ejsCreateWorker (Ejs *ejs)

Create a worker.

Description:
This creates a bare worker object.
Parameters:
ejsEjs reference returned from ejsCreateVM
Returns:
A new worker object.
See Also:
EjsObj, ejsRemoveWorkers
void ejsRemoveWorkers (Ejs *ejs)

Remove workers before exiting.

Parameters:
ejsEjs reference returned from ejsCreateVM
See Also:
EjsObj, ejsCreateWorker

EjsXML

EjsXML

XML and XMLList class.

Description:
The XML class and API is based on ECMA-357 ECMAScript for XML (E4X). The XML class is a core class in the E4X specification; it provides the ability to load, parse and save XML documents.
See Also:
ejsAppendAttributeToXML, ejsAppendToXML, ejsCreateXML, ejsCreateXMLList, ejsGetXMLDescendants, ejsIsXML, ejsLoadXMLAsc, ejsLoadXMLString, ejsXMLToBuf
API Stability:
Internal.
Fields:
MprList *attributes Node attributes.
MprList *elements List elements or child nodes.
intkind Kind of XML node.
MprList *namespaces List of namespaces as Namespace objects.
EjsObjobj Base object.
struct EjsXML *parent Parent node reference (XML or XMLList).
EjsNameqname XML node name (e.g. tagName).
struct EjsXML *targetObject XML/XMLList object modified when items inserted into an empty list.
EjsNametargetProperty XML property modified when items inserted into an empty list.
EjsString *value Value of text|attribute|comment|pi.
int ejsAppendAttributeToXML (Ejs *ejs, EjsXML *parent, EjsXML *attribute)

Append an attribute.

Parameters:
ejsEjs reference returned from ejsCreateVM
parentXml node to receive the attribute.
attributeAttribute node to append.
Returns:
A new XML object.
See Also:
EjsXML, ejsAppendToXML, ejsCreateXML, ejsCreateXMLList, ejsGetXMLDescendants, ejsIsXML, ejsLoadXMLAsc, ejsLoadXMLString, ejsXMLToBuf
EjsXML * ejsAppendToXML (Ejs *ejs, EjsXML *dest, EjsXML *node)

Append a node.

Parameters:
ejsEjs reference returned from ejsCreateVM
destNode to receive the appended node.
nodeNode to append to dest.
Returns:
The dest node.
See Also:
EjsXML, ejsAppendAttributeToXML, ejsCreateXML, ejsCreateXMLList, ejsGetXMLDescendants, ejsIsXML, ejsLoadXMLAsc, ejsLoadXMLString, ejsXMLToBuf
EjsXML * ejsCreateXML (Ejs *ejs, int kind, EjsName name, EjsXML *parent, EjsString *value)

Create an XML node object.

Parameters:
ejsEjs reference returned from ejsCreateVM
kindXML node kind. Set to EJS_XML_LIST, EJS_XML_ELEMENT, EJS_XML_ATTRIBUTE, EJS_XML_TEXT, EJS_XML_COMMENT or EJS_XML_PROCESSING.
nameNode name. Only the EjsName.name field is used.
parentParent node.
valueNode value.
Returns:
A new XML object.
See Also:
EjsXML, ejsAppendAttributeToXML, ejsAppendToXML, ejsCreateXMLList, ejsGetXMLDescendants, ejsIsXML, ejsLoadXMLAsc, ejsLoadXMLString, ejsXMLToBuf
EjsXML * ejsCreateXMLList (Ejs *ejs, EjsXML *targetObject, EjsName targetProperty)

Create an XML list object.

Parameters:
ejsEjs reference returned from ejsCreateVM
targetObjectObject to set as the target object for the list.
targetPropertyProperty to set as the target property for the list.
Returns:
A new XML list object.
See Also:
EjsXML, ejsAppendAttributeToXML, ejsAppendToXML, ejsCreateXML, ejsGetXMLDescendants, ejsIsXML, ejsLoadXMLAsc, ejsLoadXMLString, ejsXMLToBuf
EjsXML * ejsGetXMLDescendants (Ejs *ejs, EjsXML *xml, EjsName qname)

Get the descendants of an XML node that match the given name.

Parameters:
ejsEjs reference returned from ejsCreateVM
xmlNode to examine.
qnameName to search for.
Returns:
An XML node with elements for the descendants.
See Also:
EjsXML, ejsAppendAttributeToXML, ejsAppendToXML, ejsCreateXML, ejsCreateXMLList, ejsIsXML, ejsLoadXMLAsc, ejsLoadXMLString, ejsXMLToBuf
bool ejsIsXML (Ejs *ejs, EjsAny *obj)

Determine if a variable is an XML object.

Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to test.
Returns:
True if the variable is an XML or XMLList object.
See Also:
EjsXML, ejsAppendAttributeToXML, ejsAppendToXML, ejsCreateXML, ejsCreateXMLList, ejsGetXMLDescendants, ejsLoadXMLAsc, ejsLoadXMLString, ejsXMLToBuf
void ejsLoadXMLAsc (Ejs *ejs, EjsXML *xml, cchar *xmlString)

Load an XML document from an Ascii string.

Parameters:
ejsEjs reference returned from ejsCreateVM
xmlXML node to hold the parsed XML data.
xmlStringString containing XML data to parse.
Returns:
A new XML object.
See Also:
EjsXML, ejsAppendAttributeToXML, ejsAppendToXML, ejsCreateXML, ejsCreateXMLList, ejsGetXMLDescendants, ejsIsXML, ejsLoadXMLString, ejsXMLToBuf
void ejsLoadXMLString (Ejs *ejs, EjsXML *xml, EjsString *xmlString)

Load an XML document.

Parameters:
ejsEjs reference returned from ejsCreateVM
xmlXML node to hold the parsed XML data.
xmlStringString containing XML data to parse.
See Also:
EjsXML, ejsAppendAttributeToXML, ejsAppendToXML, ejsCreateXML, ejsCreateXMLList, ejsGetXMLDescendants, ejsIsXML, ejsLoadXMLAsc, ejsXMLToBuf
EjsXML * ejsSetXMLElement (Ejs *ejs, EjsXML *xml, int index, EjsXML *node)

Set an indexed element to a value.

Parameters:
ejsEjs reference returned from ejsCreateVM
xmlXML node to receive the appended node.
indexElement index at which to set the node.
nodeNode to insert.
Returns:
The xml node.
See Also:
EjsXML, ejsAppendAttributeToXML, ejsAppendToXML, ejsCreateXML, ejsCreateXMLList, ejsGetXMLDescendants, ejsIsXML, ejsLoadXMLAsc, ejsLoadXMLString, ejsXMLToBuf
int ejsXMLToBuf (Ejs *ejs, MprBuf *buf, EjsXML *xml, int indentLevel)

Convert an xml node to string representation in a buffer.

Parameters:
ejsEjs reference returned from ejsCreateVM
bufBuffer to hold the output string.
xmlNode to examine.
indentLevelMaximum indent level.
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
EjsXML, ejsAppendAttributeToXML, ejsAppendToXML, ejsCreateXML, ejsCreateXMLList, ejsGetXMLDescendants, ejsIsXML, ejsLoadXMLAsc, ejsLoadXMLString

Functions

int EJS_MAKE_VERSION (int maj, int min, int patch)

Make an integer version number.

Parameters:
majMajor version number.
minMinor version number.
patchPatch version number.
Returns:
An integer version number combining major, minor and patch version numbers.
void ejsDestroyVM (Ejs *ejs)

Destroy an interpreter.

Parameters:
ejsInterpreter to destroy.
EjsArray * ejsGetPathFiles (Ejs *ejs, EjsPath *path, int argc, EjsAny **argv)

Get files below a path.

Description:
Expand wild cards in a path. Function used to implement Path.files().
Parameters:
ejsEjs reference returned from ejsCreateVM
pathPath to use as the base.
argcCount of args (set to 1).
argvArgs array. (Set to an array with a single element).
Returns:
Array of matching paths.
EjsString * ejsToLiteralString (Ejs *ejs, EjsObj *obj)

Convert a string to a literal string style representation.

Description:
The object is converted to a string and then is wrapped with quotes. Embedded quotes and backquotes are backquoted.
Parameters:
ejsEjs reference returned from ejsCreateVM
objObject to convert.
Returns:
A string representation of the object.
EjsType * EST (void *name)

Special type.

EjsAny * ESV (void *name)

Get immutable special value.

Parameters:
nameLiteral name.
Returns:
Special value.

Typedefs

typedef EjsObj*(* EjsProc)(Ejs *ejs, EjsAny *thisObj, int argc, struct EjsObj **argv).

Native Function signature.

Description:
This is the calling signature for C Functions.
Parameters:
ejsEjs reference returned from ejsCreateVM
thisObjReference to the "this" object. (The object containing the method).
argcNumber of arguments.
argvArray of arguments.
Returns:
Returns a result variable or NULL on errors and exceptions.
API Stability:
Evolving.
See Also:
EjsFunction, ejsBindFunction, ejsCloneFunction, ejsCloneFunction, ejsCreateActivation, ejsCreateBareFunction, ejsCreateFunction, ejsCreateFunction, ejsInitFunction, ejsIsFunction, ejsIsFunction, ejsIsInitializer, ejsIsNativeFunction, ejsRemoveConstructor, ejsRunFunction, ejsRunFunction, ejsRunFunctionBySlot, ejsRunFunctionBySlot, ejsRunInitializer, ejsRunInitializer
typedef int(* EjsNativeCallback)(Ejs *ejs).

Native module initialization callback.

Parameters:
ejsEjs reference returned from ejsCreateVM
Returns:
Zero if successful, otherwise a negative MPR error code.
See Also:
ejsCreateSearchPath, ejsLoadModule, ejsLoadModules, ejsSearchForModule, ejsSetSearchPath
EjsCode

Byte code.

Description:
This structure describes a sequence of byte code for a function. It also defines a set of execption handlers pertaining to this byte code.
Fields:
ucharbyteCode[ARRAY_FLEX] Byte code.
intcodeLen Byte code length.
EjsDebug *debug Source code debug information.
intdebugOffset Offset in mod file for debug info.
EjsEx **handlers Exception handlers.
intmagic Debug magic id.
struct EjsModule *module Module owning this function.
intnumHandlers Number of exception handlers.
intsizeHandlers Size of handlers array.
API Stability:
Internal.
EjsConstants

Constant pool for module files.

API Stability:
Internal.
Fields:
EjsString **index Interned string index.
intindexCount Number of constants used in index.
intindexSize Size of index in elements.
intlocked No more additions allowed.
char *pool Constant pool string data.
ssizepoolLength Length of used bytes in constant pool.
ssizepoolSize Size of constant pool storage in bytes.
MprHash *table Hash table for fast lookup when compiling.
EjsDebug

Debug record for module files.

API Stability:
Internal.
Fields:
EjsLinelines[ARRAY_FLEX] Debug lines.
intnumLines Number of entries in lines[].
ssizesize Size of lines[] in elements.
EjsEx

Exception Handler Record.

Description:
Each exception handler has an exception handler record.
Fields:
struct EjsType *catchType Type of error to catch.
uintflags Exception flags.
uinthandlerEnd Ptr to one past the end.
uinthandlerStart Ptr to start of catch/finally block.
uintnumBlocks Count of blocks opened before the try block.
uintnumStack Count of stack slots pushed before the try block.
uinttryEnd Ptr to one past the end.
uinttryStart Ptr to start of try block.
API Stability:
Internal.
EjsHash

Property hash linkage.

API Stability:
Internal.
Fields:
int *buckets Hash buckets and head of link chains.
intsize Size of hash.
EjsHelpers

Allocation and Type Helpers.

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

Interned string hash shared over all interpreters.

API Stability:
Internal.
Fields:
uint64accesses NUmber of accesses to string.
struct EjsString *buckets Hash buckets and references to link chains of strings (unicode).
intcount Count of entries.
uint64reuse Reuse counter.
intsize Size of hash.
EjsLine

Symbolic debugging storage for source code in module files.

API Stability:
Internal.
Fields:
intoffset Optional PC offsets of each line in function.
wchar *source Program source code. Format: path line: code.
EjsLookup

Lookup State.

Description:
Location information returned when looking up properties.
Fields:
intbind Whether to bind to this lookup.
uintinstanceProperty Property is an instance property.
struct EjsNamename Name and namespace used to find the property.
uintnthBase Property on Nth super type count from the object.
uintnthBlock Property on Nth block in the scope chain count from the end.
EjsAny *obj Final object / Type containing the variable.
EjsAny *originalObj Original object used for the search.
uintownerIsType Original object owning the property is a type.
EjsAny *ref Actual property reference.
intslotNum Final slot in obj containing the variable reference.
struct EjsTrait *trait Property trait describing the property.
EjsType *type Type containing property (if on a prototype obj).
uintuseThis Property accessible via "this.".
API Stability:
Internal.
EjsProperties

Object properties.

API Stability:
Internal.
Fields:
EjsHash *hash Hash buckets and head of link chains.
intsize Current size of slots[] in elements.
struct EjsSlotslots[ARRAY_FLEX] Vector of slots containing property references.
EjsService

Ejscript Service structure.

Description:
The Ejscript service manages the overall language runtime. It is the factory that creates interpreter instances via ejsCreateVM
Fields:
EjsHelpersblockHelpers Default EjsBlock helpers.
uintdontExit Prevent App.exit() from exiting.
MprSpin *dtoaSpin[2] Dtoa thread synchronization.
Http *http Http service.
EjsPot *immutable Immutable types and special values.
uintimmutableInitialized Immutable types are initialized.
EjsIntern *intern Interned Unicode string hash - shared over all interps.
uintlogging Using log.
MprMutex *mutex Multithread locking.
MprHash *nativeModules Set of loaded native modules.
EjsHelpersobjHelpers Default EjsObj helpers.
EjsHelperspotHelpers Default EjsPot helpers.
uintseqno Interp sequence numbers.
MprList *vmlist List of all VM interpreters.
API Stability:
Internal.
EjsSlot

Property slot structure.

API Stability:
Internal.
Fields:
inthashChain Next property in hash chain.
EjsNameqname Property name.
EjsAny *ref Property reference.
EjsTraittrait Property descriptor traits.
EjsState

VM Evaluation state.

API Stability:
Internal.
Fields:
struct EjsBlock *bp Current block pointer.
struct EjsFrame *fp Current Frame function pointer.
struct EjsNamespace *internal Current internal namespace.
uintpaused Garbage collection paused.
struct EjsState *prev Previous state.
EjsObj **stack Top of stack (points to the last element pushed).
EjsObj **stackBase Pointer to start of stack mem.
ssizestackSize Stack size.
EjsObj *t1 Temp one for GC.
EjsTrait

Property traits.

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

Xml tag state.

API Stability:
Internal.
Fields:
EjsObj *attributes List of attributes.
EjsObj *comments List of comments.
struct EjsXML *obj Current object.

© Embedthis Software, 2003-2015. All rights reserved.