Tweak source whitespace to match SWIG conventions

This commit is contained in:
Olly Betts 2021-12-15 19:40:06 +13:00
commit 9ffa15b307
2 changed files with 68 additions and 69 deletions

View file

@ -153,6 +153,7 @@ INT_TYPEMAP(long long);
ZVAL_STRING($result, temp); ZVAL_STRING($result, temp);
} }
%} %}
INT_TYPEMAP(unsigned long long); INT_TYPEMAP(unsigned long long);
%typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT %typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT
{ {

View file

@ -139,7 +139,7 @@ static void print_creation_free_wrapper(Node *n) {
Printf(s, " zend_object_std_dtor(&obj->std);\n"); Printf(s, " zend_object_std_dtor(&obj->std);\n");
Printf(s, " if (obj->newobject)"); Printf(s, " if (obj->newobject)");
String * type = Getattr(n, "classtype"); String *type = Getattr(n, "classtype");
if (destructor_action) { if (destructor_action) {
Printv(s, Printv(s,
" {\n", " {\n",
@ -155,7 +155,7 @@ static void print_creation_free_wrapper(Node *n) {
} }
Printf(s, "/* Object Creation Method for class %s */\n",class_name); Printf(s, "/* Object Creation Method for class %s */\n",class_name);
Printf(s, "zend_object * %s_object_new(zend_class_entry *ce) {\n",class_name); Printf(s, "zend_object *%s_object_new(zend_class_entry *ce) {\n",class_name);
Printf(s, " swig_object_wrapper *obj = (swig_object_wrapper*)zend_object_alloc(sizeof(swig_object_wrapper), ce);\n"); Printf(s, " swig_object_wrapper *obj = (swig_object_wrapper*)zend_object_alloc(sizeof(swig_object_wrapper), ce);\n");
Printf(s, " zend_object_std_init(&obj->std, ce);\n"); Printf(s, " zend_object_std_init(&obj->std, ce);\n");
Printf(s, " object_properties_init(&obj->std, ce);\n"); Printf(s, " object_properties_init(&obj->std, ce);\n");
@ -178,7 +178,7 @@ static void SwigPHP_emit_pointer_type_registrations() {
Printf(s_wrappers, "static zend_object_handlers swig_ptr_object_handlers;\n\n"); Printf(s_wrappers, "static zend_object_handlers swig_ptr_object_handlers;\n\n");
Printf(s_wrappers, "/* Object Creation Method for pointer wrapping class */\n"); Printf(s_wrappers, "/* Object Creation Method for pointer wrapping class */\n");
Printf(s_wrappers, "static zend_object * swig_ptr_object_new(zend_class_entry *ce) {\n"); Printf(s_wrappers, "static zend_object *swig_ptr_object_new(zend_class_entry *ce) {\n");
Printf(s_wrappers, " swig_object_wrapper *obj = (swig_object_wrapper*)zend_object_alloc(sizeof(swig_object_wrapper), ce);\n"); Printf(s_wrappers, " swig_object_wrapper *obj = (swig_object_wrapper*)zend_object_alloc(sizeof(swig_object_wrapper), ce);\n");
Printf(s_wrappers, " zend_object_std_init(&obj->std, ce);\n"); Printf(s_wrappers, " zend_object_std_init(&obj->std, ce);\n");
Printf(s_wrappers, " object_properties_init(&obj->std, ce);\n"); Printf(s_wrappers, " object_properties_init(&obj->std, ce);\n");
@ -436,7 +436,7 @@ public:
/* start the init section */ /* start the init section */
{ {
String * s_init_old = s_init; String *s_init_old = s_init;
s_init = NewString("/* init section */\n"); s_init = NewString("/* init section */\n");
Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n", NIL); Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n", NIL);
Printf(s_init, " STANDARD_MODULE_HEADER,\n"); Printf(s_init, " STANDARD_MODULE_HEADER,\n");
@ -658,7 +658,7 @@ public:
skip_this = false; skip_this = false;
continue; continue;
} }
String* tmap_in_numinputs = Getattr(p, "tmap:in:numinputs"); String *tmap_in_numinputs = Getattr(p, "tmap:in:numinputs");
// tmap:in:numinputs is unset for varargs, which we don't count here. // tmap:in:numinputs is unset for varargs, which we don't count here.
if (!tmap_in_numinputs || Equal(tmap_in_numinputs, "0")) { if (!tmap_in_numinputs || Equal(tmap_in_numinputs, "0")) {
/* Ignored parameter */ /* Ignored parameter */
@ -676,7 +676,7 @@ public:
--num_arguments; --num_arguments;
--num_required; --num_required;
} }
String * arginfo_code; String *arginfo_code;
if (overflowed) { if (overflowed) {
// We overflowed the bitmap so just generate a unique name - this only // We overflowed the bitmap so just generate a unique name - this only
// happens for a function with more parameters than bits in a long // happens for a function with more parameters than bits in a long
@ -710,7 +710,7 @@ public:
skip_this = false; skip_this = false;
continue; continue;
} }
String* tmap_in_numinputs = Getattr(p, "tmap:in:numinputs"); String *tmap_in_numinputs = Getattr(p, "tmap:in:numinputs");
// tmap:in:numinputs is unset for varargs, which we don't count here. // tmap:in:numinputs is unset for varargs, which we don't count here.
if (!tmap_in_numinputs || Equal(tmap_in_numinputs, "0")) { if (!tmap_in_numinputs || Equal(tmap_in_numinputs, "0")) {
/* Ignored parameter */ /* Ignored parameter */
@ -721,7 +721,7 @@ public:
Printf(s_arginfo, "ZEND_END_ARG_INFO()\n"); Printf(s_arginfo, "ZEND_END_ARG_INFO()\n");
} }
String * s = cs_entry; String *s = cs_entry;
if (!s) s = s_entry; if (!s) s = s_entry;
if (cname && Cmp(Getattr(n, "storage"), "friend") != 0) { if (cname && Cmp(Getattr(n, "storage"), "friend") != 0) {
Printf(all_cs_entry, " PHP_ME(%s%s,%s,swig_arginfo_%s,%s)\n", prefix, cname, fname, arginfo_code, modes); Printf(all_cs_entry, " PHP_ME(%s%s,%s,swig_arginfo_%s,%s)\n", prefix, cname, fname, arginfo_code, modes);
@ -832,7 +832,7 @@ public:
bool is_class_wrapped(String *className) { bool is_class_wrapped(String *className) {
if (!className) if (!className)
return false; return false;
Node * n = symbolLookup(className); Node *n = symbolLookup(className);
return n && Getattr(n, "classtype") != NULL; return n && Getattr(n, "classtype") != NULL;
} }
@ -984,7 +984,6 @@ public:
} }
bool is_setter_method(Node *n) { bool is_setter_method(Node *n) {
const char *p = GetChar(n, "sym:name"); const char *p = GetChar(n, "sym:name");
if (strlen(p) > 4) { if (strlen(p) > 4) {
p += strlen(p) - 4; p += strlen(p) - 4;
@ -996,7 +995,6 @@ public:
} }
bool is_getter_method(Node *n) { bool is_getter_method(Node *n) {
const char *p = GetChar(n, "sym:name"); const char *p = GetChar(n, "sym:name");
if (strlen(p) > 4) { if (strlen(p) > 4) {
p += strlen(p) - 4; p += strlen(p) - 4;
@ -2018,7 +2016,7 @@ public:
/* wrap complex arguments to zvals */ /* wrap complex arguments to zvals */
Append(w->code, wrap_args); Append(w->code, wrap_args);
const char * funcname = GetChar(n, "sym:name"); const char *funcname = GetChar(n, "sym:name");
Append(w->code, "{\n"); Append(w->code, "{\n");
Append(w->code, "#if PHP_MAJOR_VERSION < 8\n"); Append(w->code, "#if PHP_MAJOR_VERSION < 8\n");
Printf(w->code, "zval swig_funcname;\n"); Printf(w->code, "zval swig_funcname;\n");