PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/php/const.i

#
Swig | 53 lines | 38 code | 6 blank | 9 comment | 0 complexity | 267970412650ef03160950ada9f0402e MD5 | raw file
 1/* -----------------------------------------------------------------------------
 2 * const.i
 3 *
 4 * Typemaps for constants
 5 * ----------------------------------------------------------------------------- */
 6
 7%typemap(consttab) int,
 8                   unsigned int,
 9                   short,
10                   unsigned short,
11                   long,
12                   unsigned long,
13                   unsigned char,
14                   signed char,
15                   bool,
16                   enum SWIGTYPE
17  "SWIG_LONG_CONSTANT($symname, $value);";
18
19%typemap(consttab) float,
20                   double
21  "SWIG_DOUBLE_CONSTANT($symname, $value);";
22
23%typemap(consttab) char
24  "SWIG_CHAR_CONSTANT($symname, $value);";
25
26%typemap(consttab) char *,
27                   const char *,
28                   char [],
29                   const char []
30  "SWIG_STRING_CONSTANT($symname, $value);";
31
32%typemap(consttab) SWIGTYPE *,
33                   SWIGTYPE &,
34                   SWIGTYPE [] {
35  /* This actually registers it as a global variable and constant.  I don't
36   * like it, but I can't figure out the zend_constant code... */
37  zval *z_var;
38  MAKE_STD_ZVAL(z_var);
39  SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0);
40  /* zend_hash_add(&EG(symbol_table), "$1", sizeof("$1"), (void *)&z_var,sizeof(zval *), NULL); */
41  zend_constant c;
42  c.value = *z_var;
43  zval_copy_ctor(&c.value);
44  size_t len = sizeof("$1") - 1;
45  c.name = zend_strndup("$1", len);
46  c.name_len = len+1;
47  c.flags = CONST_CS | CONST_PERSISTENT;
48  c.module_number = module_number;
49  zend_register_constant( &c TSRMLS_CC );
50}
51
52/* Handled as a global variable. */
53%typemap(consttab) SWIGTYPE (CLASS::*) "";