Nombas > SE:ISDK DevSpace > Tips > Migrating From Mozilla


Migrating From Mozilla

ScriptEase equivalents of the Mozilla JS API

Frequently those coming to the ScriptEase:ISDK for Embedded JavaScript have previously been using the Mozilla SpiderMonkey or Rhino source. For any number of reasons (performance, memory footprint, platform support, thread needs, long-term rapid technical support, extra functionality, etc...) the time has come to move to Nombas' ScriptEase API. This page provides a starting point for making the migration from the Mozilla API to ScriptEase.

The Mozilla API in the following table is taken from the SpiderMonkey JavaScript 1.5 Reference, and the accompanying reference manuals at that site. We welcome any further help with this table. Note that this is a reference only for converting from Mozilla to ScriptEase API, and does not contain the information for going the other direction; i.e., the ScriptEase API functions that have no Mozilla counterpart are not in this table. In the following table "N/A" means that the function is not applicable for ScriptEase (i.e. it is not necessary in the SE way of doing things), "-" means that there is no equivalent ScriptEase function. The Rhino API is not listed here because the API's are so similar between the C and Java versions. Note also that this chart is for the 4.4 ScriptEase API; significant simplification of the API is expected with the 5.0 relase (due end-of-summer 2001). Mozilla JS_xxxUCxxx function are not listed here because they are the same as the ascii versions, and ScriptEase provides ASCII, Unicode, or MBCS versions of all of the API.

Mozilla API ScriptEase API Comments
DOUBLE_TO_JSVAL jsePutNumber “jsenumber” is a double by default, but may be any type NYI
INT_FITS_IN_JSVAL N/A SE has one internal number type. All ints will fit into that type.
JSCLASS_HAS_PRIVATE True all SE objects have jseGetObjectData and jseSetObjectData
JSCLASS_NEW_ENUMERATE - SE does not provide an enumarate callback in the 4.0 API
JSClass jseObjectCallbacks, JSE_LIBOBJECT, & jseAddLibrary SE API objects act as a “class” the same as script-language objects, with jseObjectCallbacks and jseAddLibrary to assist in common situations
JSConstDoubleSpec jsePutNumber, JSE_VARNUMBER
JSErrorReport jseLibErrorPrintf, jseAtErrorFunc, & jseErrorMessageFunc
JSFunctionSpec jseCreateWrapperFunction, jseMemberWrapperFunction, jseFunctionDescription and related macros (JSE_LIBOBJECT, JSE_LIBMETHOD, etc…)
JSObjectOps jseObjectCallbacks
JSPROP_INDEX N/A SE indices are encoded internally in bit patterns, externally as indices or strongs
JSPrincipals jseSecurityGuard? see Security Manager chapter in SE manual
JSPropertySpec jseGetXXX(), jsePutXXX(), or jseAddLibrary()
JSVAL_FALSE jsePutBoolean, jseGetBoolean
JSVAL_IS_BOOLEAN jseGetType() == jseTypeBoolean
JSVAL_IS_DOUBLE jseGetType() == jseTypeNumber
JSVAL_IS_NULL jseGetType() == jseTypeNull
JSVAL_IS_NUMBER jseGetType() == jseTypeNumber
JSVAL_IS_OBJECT jseGetType() == jseTypeObject
JSVAL_IS_PRIMITIVE jseGetType() != jseTypeObject
JSVAL_IS_STRING jseGetType() == jseTypeString
JSVAL_IS_VOID jseGetType() == jseTypeUndfined
JSVAL_NULL N/A SE variables jseTypeNull
JSVAL_TO_BOOLEAN jseGetBoolean()
JSVAL_TO_DOUBLE jseGetNumber()
JSVAL_TO_GCTHING N/A All SE APIVars are free for GC when their reference is dropped with jseDestroyVariable
JSVAL_TO_INT jseGetLong()
JSVAL_TO_PRIVATE jseLibraryData()
JSVAL_TRUE jsePutBoolean(True)
JSVAL_VOID jseCreateVariable( jseTypeUndefined )
JS_AddNamedRoot N/A All SE APIVars are free for GC when their reference is dropped with jseDestroyVariable
JS_AddRoot N/A see above
JS_BeginRequest N/A SE engine is thread-safe, see jseCreateFiber for sharing objects between contexts
JS_CallFunction jseCallFunction()
JS_CallFunctionName jseCallFunction()
JS_CallFunctionValue jseCallFunction()
JS_CheckAccess N/A access determined by attributes of function (jseImplicitParents)
JS_ClearContextThread N/A SE Engine is always threadsafe
JS_ClearScope - convert to type NULL, remove each member, or re-create blank object
JS_CloneFunctionObject - see srcmisc/seobjfun.c for similar helper functions
JS_CompareStrings jsecharCompare( jseGetString(), jseGetString(), ...)
JS_CompileFile jseCreateCodeTokenBuffer
JS_CompileFunction N/A call Function constructor, as implemented in srclib/ecma/seobject.c
JS_CompileFunctionForPrincipals N/A see above, and Security Manager
JS_CompileScript jseCreateCodeTokenBuffer
JS_CompileScriptForPrincipals jseCreateCodeTokenBuffer
JS_ConstructObject jseCallFunctionEx( …, JSE_FUNC_CONSTRUCT … ) also see srcmisc/seobjfun.c for jseConstructObject() helper function
JS_ContextIterator -
JS_ConvertArguments N/A arguments may be converted automatically when pulled from the stack, as in JSE_FUNC_VAR_NEED, jseCreateConvertedVariable, or jseGetXXX helpers in srcmisc/seobfun.c
JS_ConvertStub N/A
JS_ConvertValue jseCreateConvertedVariable
JS_DecompileFunction N/A call Funcion.toSource
JS_DecompileFunctionBody -
JS_DecompileScript -
JS_DefineConstDoubles JSE_VARNUMBER Used in jseAddLibrary
JS_DefineElement jseMemberXXX(), then jsePutXXX()
JS_DefineFunction jseCreateWrapperFunction, jseMemberWrapperFunction, or jseAddLibrary
JS_DefineFunctions jseAddLibrary
JS_DefineObject jseMember( …, jseTypeObject ) also see jseAddLibrary
JS_DefineProperties jseMember( … ) also see jseAddLibrary
JS_DefineProperty jseMember( … )
JS_DefinePropertyWithTinyId N/A see jseInternalizeString() for faster access to property names in callbacks
JS_DeleteElement jseDeleteMember()
JS_DeleteElement2 jseDeleteMember()
JS_DeleteProperty jseDeleteMember()
JS_DeleteProperty2 jseDeleteMember()
JS_DestroyContext jseTerminateExternalLink
JS_DestroyIdArray N/A
JS_DestroyRuntime jseTerminateEngine
JS_DestroyScript jseDestroyCodeTokenBuffer
JS_DumpNamedRoots N/A all API variables used by the application are GC’ed when the application calls jseDestroyVariable()
JS_EndRequest N/A see JSE_BeginRequest
JS_Enumerate jseGetNextMember
JS_EnumerateStub N/A
JS_EvaluateScript jseInterpret() also see jseInterpInit(), jseInterpExec, and jseInterpTerm()
JS_EvaluateScriptForPrincipals N/A see Security Manager
JS_ExecuteScript jseInterpret() jseInterpret takes raw text, file information, or bytecodes from jseCreateCodeTokenBuffer
JS_FinalizeStub N/A use NULL to indicate no delete callback
JS_GC jseGarbageCollect
JS_GetArrayLength jseGetArrayLength()
JS_GetClass jseGetObjectCallbacks() a class object as defined by the API implements inherited behavior through _prototype same as script objects
JS_GetConstructor jseGetFunction(… CONSTRUCT_PROPERTY )
JS_GetContextPrivate jseGetLinkData()
JS_GetContextThread N/A
JS_GetElement jseGetMember
JS_GetEmptyStringValue N/A jseCreateVarieble or jseMember with jseTypeString will create an empty string
JS_GetFunctionName jseCurrentFunctionName
JS_GetFunctionObject jseGetObjectData() or jseLibraryData() All functions are objects, so have jseGetObjectData() but may also have jseLibraryData
JS_GetGlobalObject jseGlobalObject
JS_GetImplementationVersion jseInitializeEngine returns version information
JS_GetInstancePrivate jseGetObjectData()
JS_GetNaNValue jseNaN
JS_GetNegativeInfinityValue jseNegInfinity
JS_GetParent jseGetMember( … PARENT_PROPERTY … )
JS_GetPositiveInfinityValue jseInfinity
JS_GetPrivate jseGetObjectData()
JS_GetProperty jseGetMember()
JS_GetPropertyAttributes jseGetAttributes()
JS_GetPrototype jseGetMember(… PROTOTYPE_PROPERTY … ) Will always return something, since all object inherit from Function or Object
JS_GetRuntime N/A
JS_GetScopeChain -
JS_GetStringBytes jseGetString()
JS_GetStringChars jseGetString()
JS_GetStringLength jseGetString( … &length ) or jseGetArrayLength()
JS_GetTypeName -
JS_GetVersion -
JS_HasArrayLength jseGetMember( … LENGTH_PROPERY )
JS_IdToValue N/A
JS_InitClass jseAddLibrary() “classes” built with API are same as classes in the script language; jseAddLibrary() is for convenience
JS_InitStandardClasses LoadLibrary_All() options in JSEOPT.H will determine what objects are initialized
JS_InstanceOf jseInstanceof() helper function in srcmisc/seobjfun.c
JS_InternString jseInternalizeString used only for property names
JS_IsArrayObject jseInstanceof( … Array …) helper function in srcmisc/seobjfun.h
JS_IsConstructing N/A
JS_IsRunning N/A
JS_Lock N/A SE engine is threadsafe
JS_LookupElement jseGetMember() or jseGetIndexMember()
JS_LookupProperty jseGetMember() or jseGetIndexMember()
JS_MaybeGC jseGarbageCollect() jseGarbageCollect() always collects
JS_NewArrayObject use jseConstructObject( … Array … ) or jseSetAttributes( jseEcmaArray ) SE API does not have a single call to populate all of the array. Use jseIndexMember() and jsePutXXX()
JS_NewContext jseInitializeExternalLink or jseCreateFiber
JS_NewDouble jseCreateVariable(…jseTypeNumber…), jsePutNumber()
JS_NewDoubleValue jseCreateVariable(…jseTypeNumber…), jsePutNumber()
JS_NewFunction jseCreateWrapperFunction or jseMemberWrapperFunction
JS_NewIdArray N/A
JS_NewNumberValue jseCreateVariable(…jseTypeNumber…), jsePutNumber()
JS_NewObject jseCreateVariable( … jseTypeObject … ) also see jseAddLibrary, jseConstructObject, and JSClass description (above) for more methods
JS_NewScriptObject -
JS_NewString jsePutString()
JS_NewStringCopyN jsePutStringLength()
JS_NewStringCopyZ jsePutString()
JS_PropertyStub N/A
JS_RemoveRoot jseDestroyVariable() GC locks are created automatically when any jseVariable is return via API
JS_ReportError jseLibErrorPrintf
JS_ReportOutOfMemory jseLibErrorPrintf use MEMORY_EXCEPTION
JS_ResolveStub N/A
JS_ResumeRequest N/A see jseResumeFiber for jseCreateFiber()
JS_SetArrayLength jseSetArrayLength
JS_SetBranchCallback jseMayIContinue freqeuency set by JSE_INFREQUENT_COUNT
JS_SetContextPrivate jseInitializeExternalLink or jseCreateFiber
JS_SetContextThread N/A use jseCreateFiber for coopertive contexts, all other jseContexts are thread-safe
JS_SetElement jseMember(), jsePutXXX()
JS_SetErrorReporter jseInitializeExternalLink and jseGetLinkData see jseAtErrorFunc and jseErrorMessageFunc
JS_SetGCCallback -
JS_SetGlobalObject jseSetGlobalObject
JS_SetParent jseMember( … PARENT_PROPERTY … )
JS_SetPrivate jseSetObjectData
JS_SetProperty jseGetMember(), jsePutXXX()
JS_SetPropertyAttributes jseSetAttributes()
JS_SetPrototype jseMember( PROTOYPE_PROPERTY ), jseAssign()
JS_SetVersion -
JS_SuspendRequest N/A all contexts are thread-safe, us jseMayIContinue, jseInterpExec, or jseSuspendFiber to relinquish control
JS_TypeOfValue jseGetType
JS_Unlock N/A
JS_ValueToBoolean jseCreateConvertedVariable( jseToBoolean )
JS_ValueToECMAInt32 jseCreateConvertedVariable( jseToInt32 )
JS_ValueToECMAUint32 jseCreateConvertedVariable( jseToUint32 )
JS_ValueToFunction - functions are objects, but objects may not be functions; see jseGetFunction and jseIsFunction
JS_ValueToId N/A
JS_ValueToInt32 jseCreateConvertedVariable( jseToInt32 )
JS_ValueToNumber jseCreateConvertedVariable( jseToNumber )
JS_ValueToObject jseCreateConvertedVariable( jseToObject )
JS_ValueToString jseCreateConvertedVariable( jseToString )
JS_ValueToUint16 jseCreateConvertedVariable( jseToUint16 )
JS_free jseMustFree
JS_malloc jseMalloc
JS_realloc jseReMalloc
JS_strdup StrCpyMalloc
STRING_TO_JSVAL jsePutString()



Home | Scripting | Products | Purchase | Download | Support | Company

Copyright ©2001, Nombas, Inc. All Rights Reserved.
Questions? Visit