1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
---|
2 | * |
---|
3 | * The contents of this file are subject to the Netscape Public |
---|
4 | * License Version 1.1 (the "License"); you may not use this file |
---|
5 | * except in compliance with the License. You may obtain a copy of |
---|
6 | * the License at http://www.mozilla.org/NPL/ |
---|
7 | * |
---|
8 | * Software distributed under the License is distributed on an "AS |
---|
9 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
---|
10 | * implied. See the License for the specific language governing |
---|
11 | * rights and limitations under the License. |
---|
12 | * |
---|
13 | * The Original Code is Mozilla Communicator client code, released |
---|
14 | * March 31, 1998. |
---|
15 | * |
---|
16 | * The Initial Developer of the Original Code is Netscape |
---|
17 | * Communications Corporation. Portions created by Netscape are |
---|
18 | * Copyright (C) 1998 Netscape Communications Corporation. All |
---|
19 | * Rights Reserved. |
---|
20 | * |
---|
21 | * Contributor(s): |
---|
22 | * |
---|
23 | * Alternatively, the contents of this file may be used under the |
---|
24 | * terms of the GNU Public License (the "GPL"), in which case the |
---|
25 | * provisions of the GPL are applicable instead of those above. |
---|
26 | * If you wish to allow use of your version of this file only |
---|
27 | * under the terms of the GPL and not to allow others to use your |
---|
28 | * version of this file under the NPL, indicate your decision by |
---|
29 | * deleting the provisions above and replace them with the notice |
---|
30 | * and other provisions required by the GPL. If you do not delete |
---|
31 | * the provisions above, a recipient may use your version of this |
---|
32 | * file under either the NPL or the GPL. |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef jsfun_h___ |
---|
36 | #define jsfun_h___ |
---|
37 | /* |
---|
38 | * JS function definitions. |
---|
39 | */ |
---|
40 | #include "jsprvtd.h" |
---|
41 | #include "jspubtd.h" |
---|
42 | |
---|
43 | JS_BEGIN_EXTERN_C |
---|
44 | |
---|
45 | struct JSFunction { |
---|
46 | jsrefcount nrefs; /* number of referencing objects */ |
---|
47 | JSObject *object; /* back-pointer to GC'ed object header */ |
---|
48 | JSNative native; /* native method pointer or null */ |
---|
49 | JSScript *script; /* interpreted bytecode descriptor or null */ |
---|
50 | uint16 nargs; /* minimum number of actual arguments */ |
---|
51 | uint16 extra; /* number of arg slots for local GC roots */ |
---|
52 | uint16 nvars; /* number of local variables */ |
---|
53 | uint8 flags; /* bound method and other flags, see jsapi.h */ |
---|
54 | uint8 spare; /* reserved for future use */ |
---|
55 | JSAtom *atom; /* name for diagnostics and decompiling */ |
---|
56 | JSClass *clasp; /* if non-null, constructor for this class */ |
---|
57 | }; |
---|
58 | |
---|
59 | extern JSClass js_ArgumentsClass; |
---|
60 | extern JSClass js_CallClass; |
---|
61 | |
---|
62 | /* JS_FRIEND_DATA so that JSVAL_IS_FUNCTION is callable from outside */ |
---|
63 | extern JS_FRIEND_DATA(JSClass) js_FunctionClass; |
---|
64 | |
---|
65 | /* |
---|
66 | * NB: jsapi.h and jsobj.h must be included before any call to this macro. |
---|
67 | */ |
---|
68 | #define JSVAL_IS_FUNCTION(cx, v) \ |
---|
69 | (JSVAL_IS_OBJECT(v) && JSVAL_TO_OBJECT(v) && \ |
---|
70 | OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(v)) == &js_FunctionClass) |
---|
71 | |
---|
72 | extern JSBool |
---|
73 | js_IsIdentifier(JSString *str); |
---|
74 | |
---|
75 | extern JSObject * |
---|
76 | js_InitFunctionClass(JSContext *cx, JSObject *obj); |
---|
77 | |
---|
78 | extern JSObject * |
---|
79 | js_InitArgumentsClass(JSContext *cx, JSObject *obj); |
---|
80 | |
---|
81 | extern JSObject * |
---|
82 | js_InitCallClass(JSContext *cx, JSObject *obj); |
---|
83 | |
---|
84 | extern JSFunction * |
---|
85 | js_NewFunction(JSContext *cx, JSObject *funobj, JSNative native, uintN nargs, |
---|
86 | uintN flags, JSObject *parent, JSAtom *atom); |
---|
87 | |
---|
88 | extern JSObject * |
---|
89 | js_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent); |
---|
90 | |
---|
91 | extern JSBool |
---|
92 | js_LinkFunctionObject(JSContext *cx, JSFunction *fun, JSObject *object); |
---|
93 | |
---|
94 | extern JSFunction * |
---|
95 | js_DefineFunction(JSContext *cx, JSObject *obj, JSAtom *atom, JSNative native, |
---|
96 | uintN nargs, uintN flags); |
---|
97 | |
---|
98 | extern JSFunction * |
---|
99 | js_ValueToFunction(JSContext *cx, jsval *vp, JSBool constructing); |
---|
100 | |
---|
101 | extern void |
---|
102 | js_ReportIsNotFunction(JSContext *cx, jsval *vp, JSBool constructing); |
---|
103 | |
---|
104 | extern JSObject * |
---|
105 | js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent); |
---|
106 | |
---|
107 | extern JSBool |
---|
108 | js_PutCallObject(JSContext *cx, JSStackFrame *fp); |
---|
109 | |
---|
110 | extern JSBool |
---|
111 | js_GetCallVariable(JSContext *cx, JSObject *obj, jsval id, jsval *vp); |
---|
112 | |
---|
113 | extern JSBool |
---|
114 | js_SetCallVariable(JSContext *cx, JSObject *obj, jsval id, jsval *vp); |
---|
115 | |
---|
116 | extern JSBool |
---|
117 | js_GetArgsValue(JSContext *cx, JSStackFrame *fp, jsval *vp); |
---|
118 | |
---|
119 | extern JSBool |
---|
120 | js_GetArgsProperty(JSContext *cx, JSStackFrame *fp, jsid id, |
---|
121 | JSObject **objp, jsval *vp); |
---|
122 | |
---|
123 | extern JSObject * |
---|
124 | js_GetArgsObject(JSContext *cx, JSStackFrame *fp); |
---|
125 | |
---|
126 | extern JSBool |
---|
127 | js_PutArgsObject(JSContext *cx, JSStackFrame *fp); |
---|
128 | |
---|
129 | extern JSBool |
---|
130 | js_XDRFunction(JSXDRState *xdr, JSObject **objp); |
---|
131 | |
---|
132 | JS_END_EXTERN_C |
---|
133 | |
---|
134 | #endif /* jsfun_h___ */ |
---|