Main Page | Class List | Directories | File List | Class Members | File Members

constants.h

Go to the documentation of this file.
00001 /*
00002 || This file is part of Pike. For copyright information see COPYRIGHT.
00003 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
00004 || for more information.
00005 || $Id: constants.h,v 1.34 2005/04/08 16:54:41 grubba Exp $
00006 */
00007 
00008 #ifndef ADD_EFUN_H
00009 #define ADD_EFUN_H
00010 
00011 #include "svalue.h"
00012 #include "hashtable.h"
00013 #include "las.h" /* For OPT_SIDE_EFFECT etc. */
00014 #include "block_alloc_h.h"
00015 
00016 typedef int (*docode_fun)(node *n);
00017 typedef node *(*optimize_fun)(node *n);
00018 
00019 #define CALLABLE_DYNAMIC 1
00020 
00021 struct callable
00022 {
00023   PIKE_MEMORY_OBJECT_MEMBERS;
00024   c_fun function;
00025   struct pike_type *type;
00026   struct pike_string *name;
00027   struct program *prog;
00028   INT16 flags; /* OPT_* */
00029   INT16 internal_flags;
00030 #ifdef PIKE_DEBUG
00031   INT8 may_return_void;
00032   long compiles;
00033   long runs;
00034   struct callable *prev;
00035 #endif
00036   optimize_fun optimize;
00037   docode_fun docode;
00038   struct callable *next;
00039 };
00040 
00041 #ifdef PIKE_DEBUG
00042 /* We have a double-linked list in debug mode for identification
00043  * purposes. */
00044 extern struct callable *first_callable;
00045 #endif
00046 
00047 /* Prototypes begin here */
00048 PMOD_EXPORT struct mapping *get_builtin_constants(void);
00049 void low_add_efun(struct pike_string *name, struct svalue *fun);
00050 void low_add_constant(const char *name, struct svalue *fun);
00051 void add_pike_string_constant(const char *name, const char *str, int len);
00052 PMOD_EXPORT void add_global_program(const char *name, struct program *p);
00053 BLOCK_ALLOC_FILL_PAGES(callable,2);
00054 PMOD_EXPORT struct callable *low_make_callable(c_fun fun,
00055                                    struct pike_string *name,
00056                                    struct pike_type *type,
00057                                    int flags,
00058                                    optimize_fun optimize,
00059                                    docode_fun docode);
00060 PMOD_EXPORT struct callable *make_callable(c_fun fun,
00061                                const char *name,
00062                                const char *type,
00063                                int flags,
00064                                optimize_fun optimize,
00065                                docode_fun docode);
00066 PMOD_EXPORT struct callable *add_efun2(const char *name,
00067                             c_fun fun,
00068                             const char *type,
00069                             int flags,
00070                             optimize_fun optimize,
00071                             docode_fun docode);
00072 PMOD_EXPORT struct callable *add_efun(const char *name, c_fun fun, const char *type, int flags);
00073 PMOD_EXPORT struct callable *quick_add_efun(const char *name, ptrdiff_t name_length,
00074                                             c_fun fun,
00075                                             const char *type, ptrdiff_t type_length,
00076                                             int flags,
00077                                             optimize_fun optimize,
00078                                             docode_fun docode);
00079 void init_builtin_constants(void);
00080 void exit_builtin_constants(void);
00081 /* Prototypes end here */
00082 
00083 
00084 #include "pike_macros.h"
00085 
00086 #define ADD_EFUN2(NAME,FUN,TYPE,OPT_FLAGS,OPTIMIZE,DOCODE) \
00087     quick_add_efun(NAME,CONSTANT_STRLEN(NAME),FUN, \
00088                    TYPE,CONSTANT_STRLEN(TYPE),OPT_FLAGS,OPTIMIZE,DOCODE)
00089 
00090 #define ADD_EFUN(NAME,FUN,TYPE,OPT_FLAGS) \
00091     ADD_EFUN2(NAME,FUN,TYPE,OPT_FLAGS,0,0)
00092 
00093 #define ADD_EFUN_DTYPE(NAME,FUN,DTYPE,FLAGS) do {                               \
00094   DTYPE_START;                                                                  \
00095   {DTYPE}                                                                       \
00096   {                                                                             \
00097     struct pike_string *_t;                                                     \
00098     DTYPE_END(_t);                                                              \
00099     quick_add_efun(NAME,CONSTANT_STRLEN(NAME),FUN,_t->str,_t->len,FLAGS,0,0);   \
00100     free_string(_t);                                                            \
00101   }                                                                             \
00102 } while (0)
00103 
00104 #endif

Generated on Fri Jul 22 23:44:24 2005 for Pike by  doxygen 1.3.9.1