summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2021-12-15 19:40:06 +1300
committerOlly Betts <olly@survex.com>2021-12-15 19:40:06 +1300
commit9ffa15b3075dc2cf79e9425de0c8653680317e69 (patch)
tree0e944d90d7d1d90e0a81e7e704cf42d9fee7199e
parent6ef820acf919885701d8e623e074ea00d13be979 (diff)
downloadswig-9ffa15b3075dc2cf79e9425de0c8653680317e69.tar.gz
Tweak source whitespace to match SWIG conventions
-rw-r--r--Lib/php/typemaps.i1
-rw-r--r--Source/Modules/php.cxx136
2 files changed, 68 insertions, 69 deletions
diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i
index 94b351113..3cfa3f0f7 100644
--- a/Lib/php/typemaps.i
+++ b/Lib/php/typemaps.i
@@ -153,6 +153,7 @@ INT_TYPEMAP(long long);
ZVAL_STRING($result, temp);
}
%}
+
INT_TYPEMAP(unsigned long long);
%typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT
{
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index cf5876aca..732f1ce61 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * This file is part of SWIG, which is licensed as a whole under version 3
+ * This file is part of SWIG, which is licensed as a whole under version 3
* (or any later version) of the GNU General Public License. Some additional
* terms also apply to certain portions of SWIG. The full details of the SWIG
* license and copyrights can be found in the LICENSE and COPYRIGHT files
@@ -139,7 +139,7 @@ static void print_creation_free_wrapper(Node *n) {
Printf(s, " zend_object_std_dtor(&obj->std);\n");
Printf(s, " if (obj->newobject)");
- String * type = Getattr(n, "classtype");
+ String *type = Getattr(n, "classtype");
if (destructor_action) {
Printv(s,
" {\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, "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, " zend_object_std_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, "/* 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, " zend_object_std_init(&obj->std, ce);\n");
Printf(s_wrappers, " object_properties_init(&obj->std, ce);\n");
@@ -436,7 +436,7 @@ public:
/* start the init section */
{
- String * s_init_old = s_init;
+ String *s_init_old = s_init;
s_init = NewString("/* init section */\n");
Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n", NIL);
Printf(s_init, " STANDARD_MODULE_HEADER,\n");
@@ -639,9 +639,9 @@ public:
(Cmp(fname, "__construct") != 0);
} else {
if (overload) {
- Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", fname);
+ Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", fname);
} else {
- Printf(f_h, "PHP_FUNCTION(%s);\n", fname);
+ Printf(f_h, "PHP_FUNCTION(%s);\n", fname);
}
}
// We want to only emit each different arginfo once, as that reduces the
@@ -656,9 +656,9 @@ public:
for (Parm *p = l; p; p = Getattr(p, "tmap:in:next")) {
if (skip_this) {
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.
if (!tmap_in_numinputs || Equal(tmap_in_numinputs, "0")) {
/* Ignored parameter */
@@ -676,7 +676,7 @@ public:
--num_arguments;
--num_required;
}
- String * arginfo_code;
+ String *arginfo_code;
if (overflowed) {
// We overflowed the bitmap so just generate a unique name - this only
// happens for a function with more parameters than bits in a long
@@ -710,7 +710,7 @@ public:
skip_this = false;
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.
if (!tmap_in_numinputs || Equal(tmap_in_numinputs, "0")) {
/* Ignored parameter */
@@ -721,7 +721,7 @@ public:
Printf(s_arginfo, "ZEND_END_ARG_INFO()\n");
}
- String * s = cs_entry;
+ String *s = cs_entry;
if (!s) s = s_entry;
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);
@@ -770,10 +770,10 @@ public:
if (constructor) {
// Renamed constructor - turn into static factory method
if (Cmp(class_name, Getattr(n, "constructorHandler:sym:name")) != 0) {
- constructorRenameOverload = true;
- wname = Copy(Getattr(n, "constructorHandler:sym:name"));
+ constructorRenameOverload = true;
+ wname = Copy(Getattr(n, "constructorHandler:sym:name"));
} else {
- wname = NewString("__construct");
+ wname = NewString("__construct");
}
} else if (class_name) {
wname = Getattr(n, "wrapper:method:name");
@@ -784,7 +784,7 @@ public:
if (constructor) {
modes = NewString("ZEND_ACC_PUBLIC | ZEND_ACC_CTOR");
if (constructorRenameOverload) {
- Append(modes, " | ZEND_ACC_STATIC");
+ Append(modes, " | ZEND_ACC_STATIC");
}
} else if (wrapperType == staticmemberfn || Cmp(Getattr(n, "storage"), "static") == 0) {
modes = NewString("ZEND_ACC_PUBLIC | ZEND_ACC_STATIC");
@@ -832,7 +832,7 @@ public:
bool is_class_wrapped(String *className) {
if (!className)
return false;
- Node * n = symbolLookup(className);
+ Node *n = symbolLookup(className);
return n && Getattr(n, "classtype") != NULL;
}
@@ -984,27 +984,25 @@ public:
}
bool is_setter_method(Node *n) {
-
const char *p = GetChar(n, "sym:name");
- if (strlen(p) > 4) {
- p += strlen(p) - 4;
- if (strcmp(p, "_set") == 0) {
- return true;
- }
+ if (strlen(p) > 4) {
+ p += strlen(p) - 4;
+ if (strcmp(p, "_set") == 0) {
+ return true;
}
- return false;
+ }
+ return false;
}
bool is_getter_method(Node *n) {
-
const char *p = GetChar(n, "sym:name");
- if (strlen(p) > 4) {
- p += strlen(p) - 4;
- if (strcmp(p, "_get") == 0) {
- return true;
- }
+ if (strlen(p) > 4) {
+ p += strlen(p) - 4;
+ if (strcmp(p, "_get") == 0) {
+ return true;
}
- return false;
+ }
+ return false;
}
virtual int functionWrapper(Node *n) {
@@ -1037,7 +1035,7 @@ public:
if (constructor) {
Append(modes, " | ZEND_ACC_CTOR");
- }
+ }
if (wrapperType == staticmemberfn || Cmp(Getattr(n, "storage"), "static") == 0) {
Append(modes, " | ZEND_ACC_STATIC");
}
@@ -1058,9 +1056,9 @@ public:
} else if (wrapperType == membervar) {
wname = Copy(Getattr(n, "membervariableHandler:sym:name"));
if (is_setter_method(n)) {
- Append(wname, "_set");
+ Append(wname, "_set");
} else if (is_getter_method(n)) {
- Append(wname, "_get");
+ Append(wname, "_get");
}
} else if (wrapperType == memberfn) {
wname = Getattr(n, "memberfunctionHandler:sym:name");
@@ -1069,28 +1067,28 @@ public:
wname = Getattr(n, "staticmembervariableHandler:sym:name");
/* We get called twice for getter and setter methods. But to maintain
- compatibility, Shape::nshapes() is being used for both setter and
- getter methods. So using static_setter and static_getter variables
- to generate half of the code each time.
+ compatibility, Shape::nshapes() is being used for both setter and
+ getter methods. So using static_setter and static_getter variables
+ to generate half of the code each time.
*/
static_setter = is_setter_method(n);
if (is_getter_method(n)) {
- // This is to overcome types that can't be set and hence no setter.
- if (Cmp(Getattr(n, "feature:immutable"), "1") != 0)
- static_getter = true;
+ // This is to overcome types that can't be set and hence no setter.
+ if (Cmp(Getattr(n, "feature:immutable"), "1") != 0)
+ static_getter = true;
}
} else if (wrapperType == staticmemberfn) {
wname = Getattr(n, "staticmemberfunctionHandler:sym:name");
} else {
if (class_name) {
- if (Cmp(Getattr(n, "storage"), "friend") == 0 && Cmp(Getattr(n, "view"), "globalfunctionHandler") == 0) {
- wname = iname;
- } else {
- wname = Getattr(n, "destructorHandler:sym:name");
- }
+ if (Cmp(Getattr(n, "storage"), "friend") == 0 && Cmp(Getattr(n, "view"), "globalfunctionHandler") == 0) {
+ wname = iname;
+ } else {
+ wname = Getattr(n, "destructorHandler:sym:name");
+ }
} else {
- wname = iname;
+ wname = iname;
}
}
@@ -1114,9 +1112,9 @@ public:
if (!overloaded) {
if (!static_getter) {
- if (class_name && Cmp(Getattr(n, "storage"), "friend") != 0) {
- Printv(f->def, "PHP_METHOD(", prefix, class_name, ",", wname, ") {\n", NIL);
- } else {
+ if (class_name && Cmp(Getattr(n, "storage"), "friend") != 0) {
+ Printv(f->def, "PHP_METHOD(", prefix, class_name, ",", wname, ") {\n", NIL);
+ } else {
if (wrap_nonclass_global) {
Printv(f->def, "PHP_METHOD(", fake_class_name(), ",", wname, ") {\n",
" PHP_FN(", wname, ")(INTERNAL_FUNCTION_PARAM_PASSTHRU);\n",
@@ -1126,7 +1124,7 @@ public:
if (wrap_nonclass_fake_class) {
Printv(f->def, "PHP_FUNCTION(", wname, ") {\n", NIL);
}
- }
+ }
}
} else {
Printv(f->def, "ZEND_NAMED_FUNCTION(", overloadwname, ") {\n", NIL);
@@ -1181,9 +1179,9 @@ public:
Printf(f->code, "\tWRONG_PARAM_COUNT;\n\n");
} else if (static_setter || static_getter) {
if (num_arguments == 0) {
- Printf(f->code, "if(ZEND_NUM_ARGS() == 0) {\n");
+ Printf(f->code, "if(ZEND_NUM_ARGS() == 0) {\n");
} else {
- Printf(f->code, "if(ZEND_NUM_ARGS() == %d && zend_get_parameters_array_ex(%d, args) == SUCCESS) {\n", num_arguments, num_arguments);
+ Printf(f->code, "if(ZEND_NUM_ARGS() == %d && zend_get_parameters_array_ex(%d, args) == SUCCESS) {\n", num_arguments, num_arguments);
}
} else {
if (num_arguments == 0) {
@@ -1392,24 +1390,24 @@ public:
{
tm = Swig_typemap_lookup("consttab", n, name, 0);
Replaceall(tm, "$value", value);
- if (Getattr(n, "tmap:consttab:rinit")) {
- Printf(r_init, "%s\n", tm);
- } else {
- Printf(s_cinit, "%s\n", tm);
- }
+ if (Getattr(n, "tmap:consttab:rinit")) {
+ Printf(r_init, "%s\n", tm);
+ } else {
+ Printf(s_cinit, "%s\n", tm);
+ }
}
{
- tm = Swig_typemap_lookup("classconsttab", n, name, 0);
+ tm = Swig_typemap_lookup("classconsttab", n, name, 0);
- Replaceall(tm, "$class", fake_class_name());
- Replaceall(tm, "$const_name", iname);
+ Replaceall(tm, "$class", fake_class_name());
+ Replaceall(tm, "$const_name", iname);
Replaceall(tm, "$value", value);
- if (Getattr(n, "tmap:classconsttab:rinit")) {
- Printf(r_init, "%s\n", tm);
- } else {
- Printf(s_cinit, "%s\n", tm);
- }
+ if (Getattr(n, "tmap:classconsttab:rinit")) {
+ Printf(r_init, "%s\n", tm);
+ } else {
+ Printf(s_cinit, "%s\n", tm);
+ }
}
} else {
tm = Swig_typemap_lookup("classconsttab", n, name, 0);
@@ -1417,9 +1415,9 @@ public:
Replaceall(tm, "$const_name", wrapping_member_constant);
Replaceall(tm, "$value", value);
if (Getattr(n, "tmap:classconsttab:rinit")) {
- Printf(r_init, "%s\n", tm);
+ Printf(r_init, "%s\n", tm);
} else {
- Printf(s_cinit, "%s\n", tm);
+ Printf(s_cinit, "%s\n", tm);
}
}
@@ -1915,7 +1913,7 @@ public:
Append(w->def, " {");
Append(declaration, ";\n");
- /* declare method return value
+ /* declare method return value
* if the return value is a reference or const reference, a specialized typemap must
* handle it, including declaration of c_result ($result).
*/
@@ -2018,7 +2016,7 @@ public:
/* wrap complex arguments to zvals */
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, "#if PHP_MAJOR_VERSION < 8\n");
Printf(w->code, "zval swig_funcname;\n");