cb22561995-10-11Fredrik Hübinette (Hubbe) /*\
06983f1996-09-22Fredrik Hübinette (Hubbe) ||| This file a part of Pike, and is copyright by Fredrik Hubinette ||| Pike is distributed as GPL (General Public License)
cb22561995-10-11Fredrik Hübinette (Hubbe) ||| See the files COPYING and DISCLAIMER for more information. \*/
24ddc71998-03-28Henrik Grubbström (Grubba)  /*
c39e432001-08-02Fredrik Hübinette (Hubbe)  * $Id: constants.h,v 1.19 2001/08/02 22:24:54 hubbe Exp $
24ddc71998-03-28Henrik Grubbström (Grubba)  */
5267b71995-08-09Fredrik Hübinette (Hubbe) #ifndef ADD_EFUN_H #define ADD_EFUN_H #include "svalue.h" #include "hashtable.h"
cb22561995-10-11Fredrik Hübinette (Hubbe) #include "las.h" /* For OPT_SIDE_EFFECT etc. */
45ee5d1999-02-10Fredrik Hübinette (Hubbe) #include "block_alloc_h.h"
5267b71995-08-09Fredrik Hübinette (Hubbe) 
7bd0ea1996-02-19Fredrik Hübinette (Hubbe) typedef int (*docode_fun)(node *n);
6930181996-02-25Fredrik Hübinette (Hubbe) typedef node *(*optimize_fun)(node *n);
5267b71995-08-09Fredrik Hübinette (Hubbe) 
c39e432001-08-02Fredrik Hübinette (Hubbe) #define CALLABLE_DYNAMIC 1
5267b71995-08-09Fredrik Hübinette (Hubbe) struct callable {
45637c2001-04-07Fredrik Hübinette (Hubbe)  PIKE_MEMORY_OBJECT_MEMBERS;
5267b71995-08-09Fredrik Hübinette (Hubbe)  c_fun function;
d68a072001-02-20Henrik Grubbström (Grubba)  struct pike_type *type;
06983f1996-09-22Fredrik Hübinette (Hubbe)  struct pike_string *name;
c39e432001-08-02Fredrik Hübinette (Hubbe)  INT16 flags; /* OPT_* */ INT16 internal_flags;
044c621999-04-14Fredrik Hübinette (Hubbe) #ifdef PIKE_DEBUG INT8 may_return_void;
d9a93b2001-07-01Fredrik Hübinette (Hubbe)  long compiles; long runs;
044c621999-04-14Fredrik Hübinette (Hubbe) #endif
7bd0ea1996-02-19Fredrik Hübinette (Hubbe)  optimize_fun optimize; docode_fun docode;
45ee5d1999-02-10Fredrik Hübinette (Hubbe)  struct callable *next;
5267b71995-08-09Fredrik Hübinette (Hubbe) }; /* Prototypes begin here */
4ee9222000-12-13Fredrik Hübinette (Hubbe) PMOD_EXPORT struct mapping *get_builtin_constants(void);
06983f1996-09-22Fredrik Hübinette (Hubbe) void low_add_efun(struct pike_string *name, struct svalue *fun);
cecf511997-02-06Fredrik Hübinette (Hubbe) void low_add_constant(char *name, struct svalue *fun);
4ee9222000-12-13Fredrik Hübinette (Hubbe) PMOD_EXPORT void add_global_program(char *name, struct program *p);
45ee5d1999-02-10Fredrik Hübinette (Hubbe) BLOCK_ALLOC(callable,128)
4ee9222000-12-13Fredrik Hübinette (Hubbe) PMOD_EXPORT struct callable *low_make_callable(c_fun fun,
45ee5d1999-02-10Fredrik Hübinette (Hubbe)  struct pike_string *name,
d68a072001-02-20Henrik Grubbström (Grubba)  struct pike_type *type,
45ee5d1999-02-10Fredrik Hübinette (Hubbe)  INT16 flags, optimize_fun optimize, docode_fun docode);
4ee9222000-12-13Fredrik Hübinette (Hubbe) PMOD_EXPORT struct callable *make_callable(c_fun fun,
7bd0ea1996-02-19Fredrik Hübinette (Hubbe)  char *name, char *type, INT16 flags, optimize_fun optimize, docode_fun docode);
4ee9222000-12-13Fredrik Hübinette (Hubbe) PMOD_EXPORT struct callable *add_efun2(char *name,
4d7b181999-12-07Fredrik Hübinette (Hubbe)  c_fun fun, char *type, INT16 flags, optimize_fun optimize, docode_fun docode);
4ee9222000-12-13Fredrik Hübinette (Hubbe) PMOD_EXPORT struct callable *add_efun(char *name, c_fun fun, char *type, INT16 flags); PMOD_EXPORT struct callable *quick_add_efun(char *name, ptrdiff_t name_length, c_fun fun, char *type, ptrdiff_t type_length, INT16 flags, optimize_fun optimize, docode_fun docode);
be478c1997-08-30Henrik Grubbström (Grubba) void cleanup_added_efuns(void);
5267b71995-08-09Fredrik Hübinette (Hubbe) /* Prototypes end here */
45ee5d1999-02-10Fredrik Hübinette (Hubbe)  #include "pike_macros.h" #define ADD_EFUN(NAME,FUN,TYPE,FLAGS) \ quick_add_efun(NAME,CONSTANT_STRLEN(NAME),FUN,TYPE,CONSTANT_STRLEN(TYPE),FLAGS,0,0) #define ADD_EFUN2(NAME,FUN,TYPE,FLAGS,OPTIMIZE,DOCODE) \ quick_add_efun(NAME,CONSTANT_STRLEN(NAME),FUN,TYPE,CONSTANT_STRLEN(TYPE),FLAGS,OPTIMIZE,DOCODE)
91aab41999-12-13Martin Stjernholm  #define ADD_EFUN_DTYPE(NAME,FUN,DTYPE,FLAGS) do { \ DTYPE_START; \ {DTYPE} \ { \ struct pike_string *_t; \ DTYPE_END(_t); \ quick_add_efun(NAME,CONSTANT_STRLEN(NAME),FUN,_t->str,_t->len,FLAGS,0,0); \ free_string(_t); \ } \ } while (0)
5267b71995-08-09Fredrik Hübinette (Hubbe) #endif