source: trunk/third/mozilla/js/src/jsfun.h @ 18860

Revision 18860, 4.5 KB checked in by rbasch, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18859, which included commits to RCS files with non-trunk default branches.
Line 
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
43JS_BEGIN_EXTERN_C
44
45struct 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
59extern JSClass js_ArgumentsClass;
60extern JSClass js_CallClass;
61
62/* JS_FRIEND_DATA so that JSVAL_IS_FUNCTION is callable from outside */
63extern 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
72extern JSBool
73js_IsIdentifier(JSString *str);
74
75extern JSObject *
76js_InitFunctionClass(JSContext *cx, JSObject *obj);
77
78extern JSObject *
79js_InitArgumentsClass(JSContext *cx, JSObject *obj);
80
81extern JSObject *
82js_InitCallClass(JSContext *cx, JSObject *obj);
83
84extern JSFunction *
85js_NewFunction(JSContext *cx, JSObject *funobj, JSNative native, uintN nargs,
86               uintN flags, JSObject *parent, JSAtom *atom);
87
88extern JSObject *
89js_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent);
90
91extern JSBool
92js_LinkFunctionObject(JSContext *cx, JSFunction *fun, JSObject *object);
93
94extern JSFunction *
95js_DefineFunction(JSContext *cx, JSObject *obj, JSAtom *atom, JSNative native,
96                  uintN nargs, uintN flags);
97
98extern JSFunction *
99js_ValueToFunction(JSContext *cx, jsval *vp, JSBool constructing);
100
101extern void
102js_ReportIsNotFunction(JSContext *cx, jsval *vp, JSBool constructing);
103
104extern JSObject *
105js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent);
106
107extern JSBool
108js_PutCallObject(JSContext *cx, JSStackFrame *fp);
109
110extern JSBool
111js_GetCallVariable(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
112
113extern JSBool
114js_SetCallVariable(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
115
116extern JSBool
117js_GetArgsValue(JSContext *cx, JSStackFrame *fp, jsval *vp);
118
119extern JSBool
120js_GetArgsProperty(JSContext *cx, JSStackFrame *fp, jsid id,
121                   JSObject **objp, jsval *vp);
122
123extern JSObject *
124js_GetArgsObject(JSContext *cx, JSStackFrame *fp);
125
126extern JSBool
127js_PutArgsObject(JSContext *cx, JSStackFrame *fp);
128
129extern JSBool
130js_XDRFunction(JSXDRState *xdr, JSObject **objp);
131
132JS_END_EXTERN_C
133
134#endif /* jsfun_h___ */
Note: See TracBrowser for help on using the repository browser.