home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / js / src / jsfun.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.8 KB  |  86 lines

  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 License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef jsfun_h___
  20. #define jsfun_h___
  21. /*
  22.  * JS function definitions.
  23.  */
  24. #include "jsprvtd.h"
  25. #include "jspubtd.h"
  26.  
  27. PR_BEGIN_EXTERN_C
  28.  
  29. struct JSFunction {
  30.     JSObject     *object;       /* back-pointer to GC'ed object header */
  31.     JSNative     call;          /* native method pointer or null */
  32.     uint8        nargs;         /* minimum number of actual arguments */
  33.     uint8        flags;         /* bound method and other flags, see jsapi.h */
  34.     uint16       nvars;         /* number of local variables */
  35.     JSAtom       *atom;         /* name for diagnostics and decompiling */
  36.     JSScript     *script;       /* interpreted bytecode descriptor or null */
  37. };
  38.  
  39. extern JSClass js_CallClass;
  40. extern JSClass js_ClosureClass;
  41. extern JSClass js_FunctionClass;
  42.  
  43. /*
  44.  * NB: jsapi.h and jsobj.h must be included before any call to this macro.
  45.  */
  46. #define JSVAL_IS_FUNCTION(v)                                                  \
  47.     (JSVAL_IS_OBJECT(v) && JSVAL_TO_OBJECT(v) &&                              \
  48.      JSVAL_TO_OBJECT(v)->map->clasp == &js_FunctionClass)
  49.  
  50. extern JSBool
  51. js_IsIdentifier(JSString *str);
  52.  
  53. extern JSObject *
  54. js_InitFunctionClass(JSContext *cx, JSObject *obj);
  55.  
  56. extern JSBool
  57. js_InitCallAndClosureClasses(JSContext *cx, JSObject *obj,
  58.                  JSObject *arrayProto);
  59.  
  60. extern JSFunction *
  61. js_NewFunction(JSContext *cx, JSNative call, uintN nargs, uintN flags,
  62.            JSObject *parent, JSAtom *atom);
  63.  
  64. extern JSFunction *
  65. js_DefineFunction(JSContext *cx, JSObject *obj, JSAtom *atom, JSNative call,
  66.           uintN nargs, uintN flags);
  67.  
  68. extern JSFunction *
  69. js_ValueToFunction(JSContext *cx, jsval v);
  70.  
  71. extern JSObject *
  72. js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent);
  73.  
  74. extern JSBool
  75. js_PutCallObject(JSContext *cx, JSStackFrame *fp);
  76.  
  77. extern JSBool
  78. js_GetCallVariable(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
  79.  
  80. extern JSBool
  81. js_SetCallVariable(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
  82.  
  83. PR_END_EXTERN_C
  84.  
  85. #endif /* jsfun_h___ */
  86.