1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
/* -----------------------------------------------------------------------------
* const.i
*
* Typemaps for constants
* ----------------------------------------------------------------------------- */
%typemap(classconsttab) int,
unsigned int,
short,
unsigned short,
long,
unsigned long,
unsigned char,
signed char,
enum SWIGTYPE %{
zend_declare_class_constant_long(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, ($1_type)($value));
%}
%typemap(classconsttab) bool %{
zend_declare_class_constant_bool(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, ($1_type)($value));
%}
%typemap(classconsttab) float,
double %{
zend_declare_class_constant_double(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, $value);
%}
%typemap(classconsttab) char %{
{
char swig_char = $value;
zend_declare_class_constant_stringl(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, &swig_char, 1);
}
%}
%typemap(classconsttab) char *,
const char *,
char [],
const char [] %{
zend_declare_class_constant_string(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, $value);
%}
// This creates a zend_object to wrap the pointer, and we can't do that
// before the Zend runtime has been initialised so we delay it until
// RINIT. The downside is it then happens for every request.
%typemap(classconsttab,rinit=1) SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE [] %{
{
zval z;
ZVAL_UNDEF(&z);
SWIG_SetPointerZval(&z, (void*)($value), $1_descriptor, 0);
zval_copy_ctor(&z);
zend_declare_class_constant(SWIG_Php_ce_$class, "$const_name", sizeof("$const_name") - 1, &z);
}
%}
%typemap(classconsttab) SWIGTYPE (CLASS::*) ""
%typemap(consttab) int,
unsigned int,
short,
unsigned short,
long,
unsigned long,
unsigned char,
signed char,
enum SWIGTYPE
"SWIG_LONG_CONSTANT($symname, ($1_type)($value));";
%typemap(consttab) bool
"SWIG_BOOL_CONSTANT($symname, ($1_type)($value));";
%typemap(consttab) float,
double
"SWIG_DOUBLE_CONSTANT($symname, $value);";
%typemap(consttab) char
"SWIG_CHAR_CONSTANT($symname, $value);";
%typemap(consttab) char *,
const char *,
char [],
const char []
"SWIG_STRING_CONSTANT($symname, $value);";
// This creates a zend_object to wrap the pointer, and we can't do that
// before the Zend runtime has been initialised so we delay it until
// RINIT. The downside is it then happens for every request.
%typemap(consttab,rinit=1) SWIGTYPE *,
SWIGTYPE &,
SWIGTYPE &&,
SWIGTYPE [] {
zend_constant c;
ZVAL_UNDEF(&c.value);
SWIG_SetPointerZval(&c.value, (void*)($value), $1_descriptor, 0);
zval_copy_ctor(&c.value);
c.name = zend_string_init("$symname", sizeof("$symname") - 1, 0);
ZEND_CONSTANT_SET_FLAGS(&c, CONST_CS, module_number);
zend_register_constant(&c);
}
/* Handled as a global variable. */
%typemap(consttab) SWIGTYPE (CLASS::*) ""
|