Annotation of sbbs/include/mozilla/js/jsfun.h, revision 1.1.1.2

1.1       root        1: /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
                      2:  *
                      3:  * ***** BEGIN LICENSE BLOCK *****
                      4:  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
                      5:  *
                      6:  * The contents of this file are subject to the Mozilla Public License Version
                      7:  * 1.1 (the "License"); you may not use this file except in compliance with
                      8:  * the License. You may obtain a copy of the License at
                      9:  * http://www.mozilla.org/MPL/
                     10:  *
                     11:  * Software distributed under the License is distributed on an "AS IS" basis,
                     12:  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
                     13:  * for the specific language governing rights and limitations under the
                     14:  * License.
                     15:  *
                     16:  * The Original Code is Mozilla Communicator client code, released
                     17:  * March 31, 1998.
                     18:  *
                     19:  * The Initial Developer of the Original Code is
                     20:  * Netscape Communications Corporation.
                     21:  * Portions created by the Initial Developer are Copyright (C) 1998
                     22:  * the Initial Developer. All Rights Reserved.
                     23:  *
                     24:  * Contributor(s):
                     25:  *
                     26:  * Alternatively, the contents of this file may be used under the terms of
                     27:  * either of the GNU General Public License Version 2 or later (the "GPL"),
                     28:  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
                     29:  * in which case the provisions of the GPL or the LGPL are applicable instead
                     30:  * of those above. If you wish to allow use of your version of this file only
                     31:  * under the terms of either the GPL or the LGPL, and not to allow others to
                     32:  * use your version of this file under the terms of the MPL, indicate your
                     33:  * decision by deleting the provisions above and replace them with the notice
                     34:  * and other provisions required by the GPL or the LGPL. If you do not delete
                     35:  * the provisions above, a recipient may use your version of this file under
                     36:  * the terms of any one of the MPL, the GPL or the LGPL.
                     37:  *
                     38:  * ***** END LICENSE BLOCK ***** */
                     39: 
                     40: #ifndef jsfun_h___
                     41: #define jsfun_h___
                     42: /*
                     43:  * JS function definitions.
                     44:  */
                     45: #include "jsprvtd.h"
                     46: #include "jspubtd.h"
                     47: 
                     48: JS_BEGIN_EXTERN_C
                     49: 
                     50: struct JSFunction {
                     51:     JSObject     *object;       /* back-pointer to GC'ed object header */
1.1.1.2 ! root       52:     uint16       nargs;         /* minimum number of actual arguments */
        !            53:     uint16       flags;         /* bound method and other flags, see jsapi.h */
1.1       root       54:     union {
1.1.1.2 ! root       55:         struct {
        !            56:             uint16   extra;     /* number of arg slots for local GC roots */
        !            57:             uint16   spare;     /* reserved for future use */
        !            58:             JSNative native;    /* native method pointer or null */
        !            59:         } n;
        !            60:         struct {
        !            61:             uint16   nvars;     /* number of local variables */
        !            62:             uint16   nregexps;  /* number of regular expressions literals */
        !            63:             JSScript *script;   /* interpreted bytecode descriptor or null */
        !            64:         } i;
1.1       root       65:     } u;
                     66:     JSAtom       *atom;         /* name for diagnostics and decompiling */
                     67:     JSClass      *clasp;        /* if non-null, constructor for this class */
                     68: };
                     69: 
1.1.1.2 ! root       70: #define JSFUN_INTERPRETED    0x8000 /* use u.i if set, u.n if unset */
        !            71: 
        !            72: #define FUN_INTERPRETED(fun) ((fun)->flags & JSFUN_INTERPRETED)
        !            73: #define FUN_NATIVE(fun)      (FUN_INTERPRETED(fun) ? NULL : (fun)->u.n.native)
        !            74: #define FUN_SCRIPT(fun)      (FUN_INTERPRETED(fun) ? (fun)->u.i.script : NULL)
1.1       root       75: 
                     76: extern JSClass js_ArgumentsClass;
                     77: extern JSClass js_CallClass;
                     78: 
1.1.1.2 ! root       79: /* JS_FRIEND_DATA so that VALUE_IS_FUNCTION is callable from the shell. */
1.1       root       80: extern JS_FRIEND_DATA(JSClass) js_FunctionClass;
                     81: 
                     82: /*
                     83:  * NB: jsapi.h and jsobj.h must be included before any call to this macro.
                     84:  */
1.1.1.2 ! root       85: #define VALUE_IS_FUNCTION(cx, v)                                              \
        !            86:     (!JSVAL_IS_PRIMITIVE(v) &&                                                \
1.1       root       87:      OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(v)) == &js_FunctionClass)
                     88: 
                     89: extern JSBool
                     90: js_fun_toString(JSContext *cx, JSObject *obj, uint32 indent,
                     91:                 uintN argc, jsval *argv, jsval *rval);
                     92: 
                     93: extern JSBool
                     94: js_IsIdentifier(JSString *str);
                     95: 
                     96: extern JSObject *
                     97: js_InitFunctionClass(JSContext *cx, JSObject *obj);
                     98: 
                     99: extern JSObject *
                    100: js_InitArgumentsClass(JSContext *cx, JSObject *obj);
                    101: 
                    102: extern JSObject *
                    103: js_InitCallClass(JSContext *cx, JSObject *obj);
                    104: 
                    105: extern JSFunction *
                    106: js_NewFunction(JSContext *cx, JSObject *funobj, JSNative native, uintN nargs,
1.1.1.2 ! root      107:                uintN flags, JSObject *parent, JSAtom *atom);
1.1       root      108: 
                    109: extern JSObject *
                    110: js_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent);
                    111: 
                    112: extern JSBool
                    113: js_LinkFunctionObject(JSContext *cx, JSFunction *fun, JSObject *object);
                    114: 
                    115: extern JSFunction *
                    116: js_DefineFunction(JSContext *cx, JSObject *obj, JSAtom *atom, JSNative native,
1.1.1.2 ! root      117:                   uintN nargs, uintN flags);
1.1       root      118: 
                    119: /*
                    120:  * Flags for js_ValueToFunction and js_ReportIsNotFunction.  We depend on the
                    121:  * fact that JSINVOKE_CONSTRUCT (aka JSFRAME_CONSTRUCTING) is 1, and test that
                    122:  * with #if/#error in jsfun.c.
                    123:  */
                    124: #define JSV2F_CONSTRUCT         JSINVOKE_CONSTRUCT
1.1.1.2 ! root      125: #define JSV2F_ITERATOR          JSINVOKE_ITERATOR
        !           126: #define JSV2F_SEARCH_STACK      0x10000
1.1       root      127: 
                    128: extern JSFunction *
                    129: js_ValueToFunction(JSContext *cx, jsval *vp, uintN flags);
                    130: 
1.1.1.2 ! root      131: extern JSObject *
        !           132: js_ValueToFunctionObject(JSContext *cx, jsval *vp, uintN flags);
        !           133: 
        !           134: extern JSObject *
        !           135: js_ValueToCallableObject(JSContext *cx, jsval *vp, uintN flags);
        !           136: 
1.1       root      137: extern void
                    138: js_ReportIsNotFunction(JSContext *cx, jsval *vp, uintN flags);
                    139: 
                    140: extern JSObject *
                    141: js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent);
                    142: 
                    143: extern JSBool
                    144: js_PutCallObject(JSContext *cx, JSStackFrame *fp);
                    145: 
                    146: extern JSBool
                    147: js_GetCallVariable(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
                    148: 
                    149: extern JSBool
                    150: js_SetCallVariable(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
                    151: 
                    152: extern JSBool
                    153: js_GetArgsValue(JSContext *cx, JSStackFrame *fp, jsval *vp);
                    154: 
                    155: extern JSBool
                    156: js_GetArgsProperty(JSContext *cx, JSStackFrame *fp, jsid id,
                    157:                    JSObject **objp, jsval *vp);
                    158: 
                    159: extern JSObject *
                    160: js_GetArgsObject(JSContext *cx, JSStackFrame *fp);
                    161: 
                    162: extern JSBool
                    163: js_PutArgsObject(JSContext *cx, JSStackFrame *fp);
                    164: 
                    165: extern JSBool
                    166: js_XDRFunction(JSXDRState *xdr, JSObject **objp);
                    167: 
                    168: JS_END_EXTERN_C
                    169: 
                    170: #endif /* jsfun_h___ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.