pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:1:
/* -*- c -*- || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
||
$Id: builtin.cmod,v 1.259 2010/06/22 09:24:35 mast Exp $
+
||
$Id$
*/ #include "global.h" #include "interpret.h" #include "svalue.h" #include "pike_macros.h" #include "object.h" #include "program.h" #include "array.h" #include "pike_error.h"
pike.git/src/builtin.cmod:4354:
pop_stack(); } } /*! @endclass */ /*! @endmodule */
-
static struct object *
SqlNULL
_
object
;
+
static struct object *
val
_
module
;
-
/*
Proxy
function needed for dynamic linkage on WIN32. */
-
PMOD_EXPORT struct object *
get_
sql
_
null
(
void
)
+
static
void
get_
val
_
module
()
{
-
return
SqlNULL
_object;
+
assert
(!val
_
module);
+
push_constant_text ("Val");
+
APPLY_MASTER ("resolv", 1);
+
if (Pike_sp[-1].type != T_OBJECT)
+
Pike_error ("\"Val\" didn't resolve to a module
object
.\n")
;
+
val_module = (--Pike_sp)->u.object;
}
-
+
/* Always do the lookup in the Val module dynamically to allow the
+
* values to be replaced. */
+
#define GET_VAL(NAME) \
+
PMOD_EXPORT struct object *PIKE_CONCAT (get_val_, NAME) (void) \
+
{ \
+
struct svalue index, res; \
+
if (!val_module) get_val_module(); \
+
index.type = T_STRING; \
+
MAKE_CONST_STRING (index.u.string, TOSTR (NAME)); \
+
object_index_no_free (&res, val_module, 0, &index); \
+
if (res.type != T_OBJECT) \
+
Pike_error ("\"Val." TOSTR (NAME) "\" didn't resolve to an object.\n"); \
+
return res.u.object; \
+
}
+
+
GET_VAL (true)
+
GET_VAL (false)
+
GET_VAL (null)
+
+
/* Kludge needed for the static null objects in the oracle module. It
+
* ought to be fixed to use dynamic lookup of them instead. */
+
PMOD_EXPORT struct program *get_sql_null_prog(void)
+
{
+
return SqlNull_program;
+
}
+
void init_builtin(void) { init_pike_list_node_blocks(); INIT
-
-
add_object_constant("SqlNULL",
-
SqlNULL_object = clone_object(SqlNull_program, 0), 0);
+
} void exit_builtin(void) {
-
if (
SqlNULL
_
object
) free_object(
SqlNULL
_
object
);
+
if (
val
_
module
) free_object
(
val
_
module
);
EXIT #ifndef DO_PIKE_CLEANUP /* This is performed by exit_builtin_modules() at a later point * in this case, so that the pike_list_node's are valid at cleanup * time, thus avoiding "got invalid pointer" fatals at exit. */ free_all_pike_list_node_blocks(); #endif #ifndef USE_SETENV if (env_allocs) free_mapping (env_allocs); #endif }