Home | History | Annotate | Download | only in php
      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   zval *z_var;
     36   MAKE_STD_ZVAL(z_var);
     37   SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0);
     38   zend_constant c;
     39   c.value = *z_var;
     40   zval_copy_ctor(&c.value);
     41   size_t len = sizeof("$symname") - 1;
     42   c.name = zend_strndup("$symname", len);
     43   c.name_len = len+1;
     44   c.flags = CONST_CS | CONST_PERSISTENT;
     45   c.module_number = module_number;
     46   zend_register_constant( &c TSRMLS_CC );
     47 }
     48 
     49 /* Handled as a global variable. */
     50 %typemap(consttab) SWIGTYPE (CLASS::*) "";
     51