3 * @brief Primary Embedded Javascript (ECMAScript) header.
4 * @overview This Embedded Javascript (EJS) header defines the
5 * public API. This API should only be used by those directly
6 * using EJS without using Embedded Server Pages (ESP). ESP
7 * wraps all relevant APIs to expose a single consistent API.
9 * This API requires the mpr/var.h facilities to create and
10 * manage objects and properties.
12 /********************************* Copyright **********************************/
16 * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
17 * Portions Copyright (c) GoAhead Software, 1995-2000. All Rights Reserved.
19 * This software is distributed under commercial and open source licenses.
20 * You may use the GPL open source license described below or you may acquire
21 * a commercial license from Mbedthis Software. You agree to be fully bound
22 * by the terms of either license. Consult the LICENSE.TXT distributed with
23 * this software for full details.
25 * This software is open source; you can redistribute it and/or modify it
26 * under the terms of the GNU General Public License as published by the
27 * Free Software Foundation; either version 2 of the License, or (at your
28 * option) any later version. See the GNU General Public License for more
29 * details at: http://www.mbedthis.com/downloads/gplLicense.html
31 * This program is distributed WITHOUT ANY WARRANTY; without even the
32 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
34 * This GPL license does NOT permit incorporating this software into
35 * proprietary programs. If you are unable to comply with the GPL, you must
36 * acquire a commercial license to use this software. Commercial licenses
37 * for this software and support services are available from Mbedthis
38 * Software at http://www.mbedthis.com
42 /********************************** Includes **********************************/
54 /********************************* Prototypes *********************************/
56 typedef MprVarHandle EjsId;
57 typedef MprVarHandle EjsHandle;
60 * Multithreaded lock routines
62 typedef void (*EjsLock)(void *lockData);
63 typedef void (*EjsUnlock)(void *lockData);
65 /********************************* Prototypes *********************************/
69 extern int ejsOpen(EjsLock lock, EjsUnlock unlock, void *lockData);
70 extern void ejsClose(void);
71 extern EjsId ejsOpenEngine(EjsHandle primaryHandle, EjsHandle altHandle);
72 extern void ejsCloseEngine(EjsId eid);
75 * Evaluation functions
77 extern int ejsEvalFile(EjsId eid, char *path, MprVar *result, char **emsg);
78 extern int ejsEvalScript(EjsId eid, char *script, MprVar *result,
80 extern int ejsRunFunction(int eid, MprVar *obj, const char *functionName,
84 * Composite variable get / set routines. Can also use the MPR property
85 * routines on an object variable.
87 extern MprVar ejsCreateObj(const char *name, int hashSize);
88 extern MprVar ejsCreateArray(const char *name, int hashSize);
89 extern bool ejsDestroyVar(MprVar *obj);
90 extern int ejsCopyVar(EjsId eid, const char *var, MprVar *value,
92 extern int ejsReadVar(EjsId eid, const char *var, MprVar *value);
93 extern int ejsWriteVar(EjsId eid, const char *var, MprVar *value);
94 extern int ejsWriteVarValue(EjsId eid, const char *var, MprVar value);
95 extern int ejsDeleteVar(EjsId eid, const char *var);
97 extern MprVar *ejsGetLocalObject(EjsId eid);
98 extern MprVar *ejsGetGlobalObject(EjsId eid);
103 extern void ejsDefineFunction(EjsId eid, const char *functionName,
104 char *args, char *body);
105 extern void ejsDefineCFunction(EjsId eid, const char *functionName,
106 MprCFunction fn, void *thisPtr, int flags);
107 extern void ejsDefineStringCFunction(EjsId eid, const char *functionName,
108 MprStringCFunction fn, void *thisPtr, int flags);
109 extern void *ejsGetThisPtr(EjsId eid);
110 extern MprVar *ejsGetReturnValue(EjsId eid);
111 extern int ejsGetLineNumber(EjsId eid);
112 extern int ejsParseArgs(int argc, char **argv, char *fmt, ...);
113 extern void ejsSetErrorMsg(EjsId eid, const char* fmt, ...)
114 PRINTF_ATTRIBUTE(2,3);
115 extern void ejsSetReturnValue(EjsId eid, MprVar value);
116 extern void ejsSetReturnString(EjsId eid, const char *str);
123 /*****************************************************************************/
131 * vim600: sw=4 ts=4 fdm=marker