php: Trim trailing whitespace from PHP typemaps
This commit is contained in:
parent
c882f39e3c
commit
3fba8e7daa
6 changed files with 35 additions and 39 deletions
|
|
@ -3,41 +3,41 @@
|
||||||
you have:
|
you have:
|
||||||
|
|
||||||
---- geometry.h --------
|
---- geometry.h --------
|
||||||
struct Geometry {
|
struct Geometry {
|
||||||
enum GeomType{
|
enum GeomType{
|
||||||
POINT,
|
POINT,
|
||||||
CIRCLE
|
CIRCLE
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~Geometry() {}
|
virtual ~Geometry() {}
|
||||||
virtual int draw() = 0;
|
virtual int draw() = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Factory method for all the Geometry objects
|
// Factory method for all the Geometry objects
|
||||||
//
|
//
|
||||||
static Geometry *create(GeomType i);
|
static Geometry *create(GeomType i);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Point : Geometry {
|
struct Point : Geometry {
|
||||||
int draw() { return 1; }
|
int draw() { return 1; }
|
||||||
double width() { return 1.0; }
|
double width() { return 1.0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Circle : Geometry {
|
struct Circle : Geometry {
|
||||||
int draw() { return 2; }
|
int draw() { return 2; }
|
||||||
double radius() { return 1.5; }
|
double radius() { return 1.5; }
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Factory method for all the Geometry objects
|
// Factory method for all the Geometry objects
|
||||||
//
|
//
|
||||||
Geometry *Geometry::create(GeomType type) {
|
Geometry *Geometry::create(GeomType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case POINT: return new Point();
|
case POINT: return new Point();
|
||||||
case CIRCLE: return new Circle();
|
case CIRCLE: return new Circle();
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
---- geometry.h --------
|
---- geometry.h --------
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -57,16 +57,16 @@
|
||||||
|
|
||||||
NOTES: remember to fully qualify all the type names and don't
|
NOTES: remember to fully qualify all the type names and don't
|
||||||
use %factory inside a namespace declaration, ie, instead of
|
use %factory inside a namespace declaration, ie, instead of
|
||||||
|
|
||||||
namespace Foo {
|
namespace Foo {
|
||||||
%factory(Geometry *Geometry::create, Point, Circle);
|
%factory(Geometry *Geometry::create, Point, Circle);
|
||||||
}
|
}
|
||||||
|
|
||||||
use
|
use
|
||||||
|
|
||||||
%factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle);
|
%factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* for loop for macro with one argument */
|
/* for loop for macro with one argument */
|
||||||
|
|
@ -90,13 +90,13 @@
|
||||||
/* for loop for macro with two arguments */
|
/* for loop for macro with two arguments */
|
||||||
%define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef
|
%define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef
|
||||||
|
|
||||||
%define %_factory_dispatch(Type)
|
%define %_factory_dispatch(Type)
|
||||||
if (!dcast) {
|
if (!dcast) {
|
||||||
Type *dobj = dynamic_cast<Type *>($1);
|
Type *dobj = dynamic_cast<Type *>($1);
|
||||||
if (dobj) {
|
if (dobj) {
|
||||||
dcast = 1;
|
dcast = 1;
|
||||||
SWIG_SetPointerZval(return_value, SWIG_as_voidptr(dobj),$descriptor(Type *), $owner);
|
SWIG_SetPointerZval(return_value, SWIG_as_voidptr(dobj),$descriptor(Type *), $owner);
|
||||||
}
|
}
|
||||||
}%enddef
|
}%enddef
|
||||||
|
|
||||||
%define %factory(Method,Types...)
|
%define %factory(Method,Types...)
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ SWIG_ConvertResourceData(void * p, const char *type_name, swig_type_info *ty) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! type_name) {
|
if (! type_name) {
|
||||||
/* can't convert p to ptr type ty if we don't know what type p is */
|
/* can't convert p to ptr type ty if we don't know what type p is */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -237,7 +237,7 @@ static swig_module_info *SWIG_Php_GetModule() {
|
||||||
if (Z_TYPE_P(pointer) == IS_LONG) {
|
if (Z_TYPE_P(pointer) == IS_LONG) {
|
||||||
return (swig_module_info *) pointer->value.lval;
|
return (swig_module_info *) pointer->value.lval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,3 @@
|
||||||
%include <std/std_except.i>
|
%include <std/std_except.i>
|
||||||
|
|
||||||
%apply size_t { std::size_t };
|
%apply size_t { std::size_t };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ namespace std {
|
||||||
|
|
||||||
map();
|
map();
|
||||||
map(const map& other);
|
map(const map& other);
|
||||||
|
|
||||||
unsigned int size() const;
|
unsigned int size() const;
|
||||||
void clear();
|
void clear();
|
||||||
%extend {
|
%extend {
|
||||||
|
|
|
||||||
|
|
@ -112,5 +112,3 @@ namespace std {
|
||||||
%define specialize_std_vector(T)
|
%define specialize_std_vector(T)
|
||||||
#warning "specialize_std_vector - specialization for type T no longer needed"
|
#warning "specialize_std_vector - specialization for type T no longer needed"
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,3 @@
|
||||||
%include <std_vector.i>
|
%include <std_vector.i>
|
||||||
%include <std_map.i>
|
%include <std_map.i>
|
||||||
%include <std_pair.i>
|
%include <std_pair.i>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue