Change naming convention for wrapped ctors and dtor
Use Foo_{new,delete}() instead of {new,delete}_Foo() to ensure that all
methods of the class Foo start with the corresponding prefix.
This commit is contained in:
parent
b24665fa6a
commit
bda731cd8f
23 changed files with 95 additions and 87 deletions
|
|
@ -367,8 +367,8 @@ The generated functions make calls to class' constructors and destructors, respe
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="targetlang"><pre>
|
<div class="targetlang"><pre>
|
||||||
Circle * new_Circle(double r);
|
Circle * Circle_new(double r);
|
||||||
void delete_Circle(Circle * self);
|
void Circle_delete(Circle * self);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -397,9 +397,9 @@ Our application code could look like this:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="targetlang"><pre>
|
<div class="targetlang"><pre>
|
||||||
Circle *c = new_Circle(1.5);
|
Circle *c = Circle_new(1.5);
|
||||||
printf("radius: %f\narea: %f\n", Circle_radius_get(c), Circle_area(c));
|
printf("radius: %f\narea: %f\n", Circle_radius_get(c), Circle_area(c));
|
||||||
delete_Circle(c);
|
Circle_delete(c);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -482,18 +482,18 @@ What we would like to generate as a C interface of this function would be someth
|
||||||
// wrapper header file
|
// wrapper header file
|
||||||
typedef struct SwigObj_SomeClass SomeClass;
|
typedef struct SwigObj_SomeClass SomeClass;
|
||||||
|
|
||||||
SomeClass * new_SomeClass();
|
SomeClass * SomeClass_new();
|
||||||
|
|
||||||
void delete_SomeClass(SomeClass * carg1);
|
void SomeClass_delete(SomeClass * carg1);
|
||||||
|
|
||||||
SomeClass* someFunction(SomeIntTemplateClass* carg1, int carg2);
|
SomeClass* someFunction(SomeIntTemplateClass* carg1, int carg2);
|
||||||
|
|
||||||
|
|
||||||
typedef struct SwigObj_SomeIntTemplateClass SomeIntTemplateClass;
|
typedef struct SwigObj_SomeIntTemplateClass SomeIntTemplateClass;
|
||||||
|
|
||||||
SomeIntTemplateClass * new_SomeIntTemplateClass();
|
SomeIntTemplateClass * SomeIntTemplateClass_new();
|
||||||
|
|
||||||
void delete_SomeIntTemplateClass(SomeIntTemplateClass * carg1);
|
void SomeIntTemplateClass_delete(SomeIntTemplateClass * carg1);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H4>The Wrapper</H4>
|
<H4>The Wrapper</H4>
|
||||||
|
|
@ -616,18 +616,18 @@ above.
|
||||||
// wrapper header file
|
// wrapper header file
|
||||||
typedef struct SwigObj_SomeClass SomeClass;
|
typedef struct SwigObj_SomeClass SomeClass;
|
||||||
|
|
||||||
SomeClass * new_SomeClass();
|
SomeClass * SomeClass_new();
|
||||||
|
|
||||||
void delete_SomeClass(SomeClass * carg1);
|
void SomeClass_delete(SomeClass * carg1);
|
||||||
|
|
||||||
SomeClass* someFunction(SomeIntTemplateClass* carg1, int carg2);
|
SomeClass* someFunction(SomeIntTemplateClass* carg1, int carg2);
|
||||||
|
|
||||||
|
|
||||||
typedef struct SwigObj_SomeIntTemplateClass SomeIntTemplateClass;
|
typedef struct SwigObj_SomeIntTemplateClass SomeIntTemplateClass;
|
||||||
|
|
||||||
SomeIntTemplateClass * new_SomeIntTemplateClass();
|
SomeIntTemplateClass * SomeIntTemplateClass_new();
|
||||||
|
|
||||||
void delete_SomeIntTemplateClass(SomeIntTemplateClass * carg1);
|
void SomeIntTemplateClass_delete(SomeIntTemplateClass * carg1);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<H2><a name="C_exceptions"></a>36.5 Exception handling</H2>
|
<H2><a name="C_exceptions"></a>36.5 Exception handling</H2>
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
printf("Creating some objects:\n");
|
printf("Creating some objects:\n");
|
||||||
Circle* c = new_Circle(10);
|
Circle* c = Circle_new(10);
|
||||||
printf(" Created circle\n");
|
printf(" Created circle\n");
|
||||||
Square* s = new_Square(10);
|
Square* s = Square_new(10);
|
||||||
printf(" Created square\n");
|
printf(" Created square\n");
|
||||||
|
|
||||||
printf("\nA total of %d shapes were created\n", Shape_nshapes_get());
|
printf("\nA total of %d shapes were created\n", Shape_nshapes_get());
|
||||||
|
|
@ -33,8 +33,8 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
printf("\nGuess I'll clean up now\n");
|
printf("\nGuess I'll clean up now\n");
|
||||||
|
|
||||||
delete_Square(s);
|
Square_delete(s);
|
||||||
delete_Circle(c);
|
Circle_delete(c);
|
||||||
|
|
||||||
printf("%d shapes remain\n", Shape_nshapes_get());
|
printf("%d shapes remain\n", Shape_nshapes_get());
|
||||||
printf("Goodbye\n");
|
printf("Goodbye\n");
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include "example_wrap.h"
|
#include "example_wrap.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Test *t = new_Test();
|
Test *t = Test_new();
|
||||||
|
|
||||||
SWIG_try {
|
SWIG_try {
|
||||||
Test_unknown(t);
|
Test_unknown(t);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include "example_wrap.h"
|
#include "example_wrap.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Klass *klass = new_Klass();
|
Klass *klass = Klass_new();
|
||||||
Vint *vint = Klass_vi_get(klass);
|
Vint *vint = Klass_vi_get(klass);
|
||||||
VA *va = Klass_va_get(klass);
|
VA *va = Klass_va_get(klass);
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ int main() {
|
||||||
printf("\nVector of objects:\n");
|
printf("\nVector of objects:\n");
|
||||||
|
|
||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
A *a = new_A_std_string_i("hello", i);
|
A *a = A_new_std_string_i("hello", i);
|
||||||
VA_push_back(va, a);
|
VA_push_back(va, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ int main() {
|
||||||
printf("%s %d\n", A_name_get(a), A_value_get(a));
|
printf("%s %d\n", A_name_get(a), A_value_get(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_Klass(klass);
|
Klass_delete(klass);
|
||||||
|
|
||||||
SWIG_exit(0);
|
SWIG_exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
D *d = new_D();
|
D *d = D_new();
|
||||||
|
|
||||||
assert(D_do_x(d) == 1);
|
assert(D_do_x(d) == 1);
|
||||||
|
|
||||||
delete_D(d);
|
D_delete(d);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
Base *ba = new_Base();
|
Base *ba = Base_new();
|
||||||
Derived *d = new_Derived();
|
Derived *d = Derived_new();
|
||||||
Bottom *bo = new_Bottom();
|
Bottom *bo = Bottom_new();
|
||||||
|
|
||||||
assert(Base_PublicProtectedPublic1(ba) == 0);
|
assert(Base_PublicProtectedPublic1(ba) == 0);
|
||||||
assert(Base_PublicProtectedPublic2(ba) == 0);
|
assert(Base_PublicProtectedPublic2(ba) == 0);
|
||||||
|
|
@ -26,9 +26,9 @@ int main(int argc, const char *argv[]) {
|
||||||
assert(Bottom_WasProtected3(ba) == 0);
|
assert(Bottom_WasProtected3(ba) == 0);
|
||||||
assert(Bottom_WasProtected4(ba) == 0);
|
assert(Bottom_WasProtected4(ba) == 0);
|
||||||
|
|
||||||
delete_Base(ba);
|
Base_delete(ba);
|
||||||
delete_Derived(d);
|
Derived_delete(d);
|
||||||
delete_Bottom(bo);
|
Bottom_delete(bo);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
Engine *e = new_Engine();
|
Engine *e = Engine_new();
|
||||||
A *a = new_A();
|
A *a = A_new();
|
||||||
|
|
||||||
assert(AbstractBaseClass_write(a, e) == true);
|
assert(AbstractBaseClass_write(a, e) == true);
|
||||||
|
|
||||||
delete_A(a);
|
A_delete(a);
|
||||||
delete_Engine(e);
|
Engine_delete(e);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,17 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
B *b = new_B();
|
B *b = B_new();
|
||||||
D *d = new_D();
|
D *d = D_new();
|
||||||
E *e = new_E();
|
E *e = E_new();
|
||||||
|
|
||||||
assert(B_foo(b) == 0);
|
assert(B_foo(b) == 0);
|
||||||
assert(D_foo(d) == 0);
|
assert(D_foo(d) == 0);
|
||||||
assert(E_foo(e) == 0);
|
assert(E_foo(e) == 0);
|
||||||
|
|
||||||
delete_B(b);
|
B_delete(b);
|
||||||
delete_D(d);
|
D_delete(d);
|
||||||
delete_E(e);
|
E_delete(e);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
Foo *f = new_Foo();
|
Foo *f = Foo_new();
|
||||||
Foo *f2 = Foo_blah(f);
|
Foo *f2 = Foo_blah(f);
|
||||||
|
|
||||||
assert(f2 != 0);
|
assert(f2 != 0);
|
||||||
|
|
||||||
delete_Foo(f);
|
Foo_delete(f);
|
||||||
delete_Foo(f2);
|
Foo_delete(f2);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
Foo *f = new_Foo();
|
Foo *f = Foo_new();
|
||||||
|
|
||||||
assert(f != 0);
|
assert(f != 0);
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ int main(int argc, const char *argv[]) {
|
||||||
Foo_seq_set(f, 1);
|
Foo_seq_set(f, 1);
|
||||||
assert(Foo_seq_get(f) == 1);
|
assert(Foo_seq_get(f) == 1);
|
||||||
|
|
||||||
delete_Foo(f);
|
Foo_delete(f);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
#include "cast_operator/cast_operator_wrap.h"
|
#include "cast_operator/cast_operator_wrap.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
A *a = new_A();
|
A *a = A_new();
|
||||||
if (strcmp(A_tochar(a), "hi"))
|
if (strcmp(A_tochar(a), "hi"))
|
||||||
fprintf(stderr, "cast failed\n");
|
fprintf(stderr, "cast failed\n");
|
||||||
delete_A(a);
|
A_delete(a);
|
||||||
SWIG_exit(0);
|
SWIG_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
MyClass *mc = new_MyClass();
|
MyClass *mc = MyClass_new();
|
||||||
|
|
||||||
assert(MyClass_someMethod(mc) == 42);
|
assert(MyClass_someMethod(mc) == 42);
|
||||||
|
|
||||||
delete_MyClass(mc);
|
MyClass_delete(mc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
MyClass *mc;
|
MyClass *mc;
|
||||||
mc = new_MyClass();
|
mc = MyClass_new();
|
||||||
|
|
||||||
delete_MyClass(mc);
|
MyClass_delete(mc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
MyClass *mc = new_MyClass();
|
MyClass *mc = MyClass_new();
|
||||||
|
|
||||||
assert(MyClass_myPubInt_get(mc) == 42);
|
assert(MyClass_myPubInt_get(mc) == 42);
|
||||||
MyClass_myPubInt_set(mc, 4711);
|
MyClass_myPubInt_set(mc, 4711);
|
||||||
assert(MyClass_myPubInt_get(mc) == 4711);
|
assert(MyClass_myPubInt_get(mc) == 4711);
|
||||||
|
|
||||||
delete_MyClass(mc);
|
MyClass_delete(mc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,15 @@ int main(int argc, const char *argv[])
|
||||||
MyClass *mc;
|
MyClass *mc;
|
||||||
MySecondClass *mc2;
|
MySecondClass *mc2;
|
||||||
|
|
||||||
mc2 = new_MySecondClass();
|
mc2 = MySecondClass_new();
|
||||||
mc = new_MyClass();
|
mc = MyClass_new();
|
||||||
|
|
||||||
assert(MySecondClass_myPubClassInstance_get(mc2));
|
assert(MySecondClass_myPubClassInstance_get(mc2));
|
||||||
MySecondClass_myPubClassInstance_set(mc2, mc);
|
MySecondClass_myPubClassInstance_set(mc2, mc);
|
||||||
assert(MySecondClass_myPubClassInstance_get(mc2));
|
assert(MySecondClass_myPubClassInstance_get(mc2));
|
||||||
|
|
||||||
delete_MyClass(mc);
|
MyClass_delete(mc);
|
||||||
delete_MySecondClass(mc2);
|
MySecondClass_delete(mc2);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
BaseClass *bc = new_BaseClass();
|
BaseClass *bc = BaseClass_new();
|
||||||
NonMethodOverwritingClass *noc = new_NonMethodOverwritingClass();
|
NonMethodOverwritingClass *noc = NonMethodOverwritingClass_new();
|
||||||
MethodOverwritingClass *oc = new_MethodOverwritingClass();
|
MethodOverwritingClass *oc = MethodOverwritingClass_new();
|
||||||
BaseClass *inherited_bc = (BaseClass*)new_MethodOverwritingClass();
|
BaseClass *inherited_bc = (BaseClass*)MethodOverwritingClass_new();
|
||||||
|
|
||||||
assert(BaseClass_myInt(bc) == 0xba53);
|
assert(BaseClass_myInt(bc) == 0xba53);
|
||||||
assert(NonMethodOverwritingClass_myInt(noc) == 0xba53);
|
assert(NonMethodOverwritingClass_myInt(noc) == 0xba53);
|
||||||
|
|
@ -15,10 +15,10 @@ int main()
|
||||||
assert(BaseClass_myInt((BaseClass*)oc) == 0xa173123d);
|
assert(BaseClass_myInt((BaseClass*)oc) == 0xa173123d);
|
||||||
assert(BaseClass_myInt(inherited_bc) == 0xa173123d);
|
assert(BaseClass_myInt(inherited_bc) == 0xa173123d);
|
||||||
|
|
||||||
delete_BaseClass(bc);
|
BaseClass_delete(bc);
|
||||||
delete_NonMethodOverwritingClass(noc);
|
NonMethodOverwritingClass_delete(noc);
|
||||||
delete_MethodOverwritingClass(oc);
|
MethodOverwritingClass_delete(oc);
|
||||||
delete_BaseClass(inherited_bc);
|
BaseClass_delete(inherited_bc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
myNamespace_MyClass *mc;
|
myNamespace_MyClass *mc;
|
||||||
mc = new_myNamespace_MyClass();
|
mc = myNamespace_MyClass_new();
|
||||||
|
|
||||||
delete_myNamespace_MyClass(mc);
|
myNamespace_MyClass_delete(mc);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
Foo *f = new_Foo(5);
|
Foo *f = Foo_new(5);
|
||||||
|
|
||||||
// test global static variables
|
// test global static variables
|
||||||
// TODO: Implement or document as not available
|
// TODO: Implement or document as not available
|
||||||
|
|
@ -36,7 +36,7 @@ int main(int argc, const char *argv[]) {
|
||||||
// because of unclear implementation details
|
// because of unclear implementation details
|
||||||
//assert(c_init_ref != 0);
|
//assert(c_init_ref != 0);
|
||||||
|
|
||||||
Bar *b = new_Bar();
|
Bar *b = Bar_new();
|
||||||
|
|
||||||
// check default value set by constructor
|
// check default value set by constructor
|
||||||
assert(Bar_cint_get(b) == 3);
|
assert(Bar_cint_get(b) == 3);
|
||||||
|
|
@ -55,9 +55,9 @@ int main(int argc, const char *argv[]) {
|
||||||
Foo_num_set(Bar_fref_get(b), 1);
|
Foo_num_set(Bar_fref_get(b), 1);
|
||||||
assert(Foo_num_get(Bar_fref_get(b)) == 1);
|
assert(Foo_num_get(Bar_fref_get(b)) == 1);
|
||||||
// create new Bar instance and check static member value
|
// create new Bar instance and check static member value
|
||||||
Bar *b2 = new_Bar();
|
Bar *b2 = Bar_new();
|
||||||
assert(Foo_num_get(Bar_fref_get(b2)) == 1);
|
assert(Foo_num_get(Bar_fref_get(b2)) == 1);
|
||||||
delete_Bar(b2);
|
Bar_delete(b2);
|
||||||
b2 = 0;
|
b2 = 0;
|
||||||
|
|
||||||
// Try to set a pointer
|
// Try to set a pointer
|
||||||
|
|
@ -68,7 +68,7 @@ int main(int argc, const char *argv[]) {
|
||||||
|
|
||||||
Foo *f2 = Bar_testFoo(b, 2, f);
|
Foo *f2 = Bar_testFoo(b, 2, f);
|
||||||
assert(Foo_num_get(f2) == 11);
|
assert(Foo_num_get(f2) == 11);
|
||||||
delete_Foo(f2);
|
Foo_delete(f2);
|
||||||
f2 = 0;
|
f2 = 0;
|
||||||
|
|
||||||
// test static variables
|
// test static variables
|
||||||
|
|
@ -93,16 +93,16 @@ int main(int argc, const char *argv[]) {
|
||||||
assert(test_func_ptr(f, 2) == -14);
|
assert(test_func_ptr(f, 2) == -14);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete_Bar(b);
|
Bar_delete(b);
|
||||||
delete_Foo(f);
|
Foo_delete(f);
|
||||||
|
|
||||||
Fl_Window *w = new_Fl_Window();
|
Fl_Window *w = Fl_Window_new();
|
||||||
// Test whether macro worked for code extension
|
// Test whether macro worked for code extension
|
||||||
// and test optional function parameters
|
// and test optional function parameters
|
||||||
Fl_Window_show(w);
|
Fl_Window_show(w);
|
||||||
Fl_Window_show_pv(w, 0);
|
Fl_Window_show_pv(w, 0);
|
||||||
Fl_Window_show_pv_pv(w, 0, 0);
|
Fl_Window_show_pv_pv(w, 0, 0);
|
||||||
delete_Fl_Window(w);
|
Fl_Window_delete(w);
|
||||||
w = 0;
|
w = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
#include "cpp_basic_template_class/cpp_basic_template_class_wrap.h"
|
#include "cpp_basic_template_class/cpp_basic_template_class_wrap.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
MyTemplateClass_Int *ci = new_MyTemplateClass_Int();
|
MyTemplateClass_Int *ci = MyTemplateClass_Int_new();
|
||||||
|
|
||||||
MyTemplateClass_Int_someMemberVariable_set(ci, 42);
|
MyTemplateClass_Int_someMemberVariable_set(ci, 42);
|
||||||
assert(MyTemplateClass_Int_someMemberVariable_get(ci) == 42);
|
assert(MyTemplateClass_Int_someMemberVariable_get(ci) == 42);
|
||||||
|
|
||||||
delete_MyTemplateClass_Int(ci);
|
MyTemplateClass_Int_delete(ci);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ int main(int argc, const char *argv[]) {
|
||||||
int e = ENUM_ONE, *p;
|
int e = ENUM_ONE, *p;
|
||||||
|
|
||||||
// check the constructor's default value
|
// check the constructor's default value
|
||||||
StructWithEnums *s = new_StructWithEnums();
|
StructWithEnums *s = StructWithEnums_new();
|
||||||
assert(StructWithEnums_some_enum_get(s) == ENUM_ONE);
|
assert(StructWithEnums_some_enum_get(s) == ENUM_ONE);
|
||||||
|
|
||||||
// check setter
|
// check setter
|
||||||
|
|
@ -43,9 +43,9 @@ int main(int argc, const char *argv[]) {
|
||||||
p = StructWithEnums_enum_test8(s);
|
p = StructWithEnums_enum_test8(s);
|
||||||
assert(*p == ENUM_TWO);
|
assert(*p == ENUM_TWO);
|
||||||
|
|
||||||
delete_StructWithEnums(s);
|
StructWithEnums_delete(s);
|
||||||
|
|
||||||
Foo *f = new_Foo();
|
Foo *f = Foo_new();
|
||||||
|
|
||||||
// check the constructor's default value
|
// check the constructor's default value
|
||||||
assert(Foo_hola_get(f) == Foo_Hello);
|
assert(Foo_hola_get(f) == Foo_Hello);
|
||||||
|
|
@ -53,7 +53,7 @@ int main(int argc, const char *argv[]) {
|
||||||
Foo_hola_set(f, Foo_Hi);
|
Foo_hola_set(f, Foo_Hi);
|
||||||
assert(Foo_hola_get(f) == Foo_Hi);
|
assert(Foo_hola_get(f) == Foo_Hi);
|
||||||
|
|
||||||
delete_Foo(f);
|
Foo_delete(f);
|
||||||
|
|
||||||
//check C enum
|
//check C enum
|
||||||
hi = Hi;
|
hi = Hi;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include "exception_order/exception_order_wrap.h"
|
#include "exception_order/exception_order_wrap.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
A* a = new_A();
|
A* a = A_new();
|
||||||
|
|
||||||
SWIG_try {
|
SWIG_try {
|
||||||
A_foo(a);
|
A_foo(a);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
int main() {
|
int main() {
|
||||||
Op_sanity_check();
|
Op_sanity_check();
|
||||||
|
|
||||||
Op *op1 = new_Op_i(1), *op2 = new_Op_i(2), *op3 = copy_Op(op1);
|
Op *op1 = Op_new_i(1), *op2 = Op_new_i(2), *op3 = Op_copy(op1);
|
||||||
|
|
||||||
assert(Op_NotEqual(op1, op2), "neq failed");
|
assert(Op_NotEqual(op1, op2), "neq failed");
|
||||||
Op_PlusPlusPrefix(op3);
|
Op_PlusPlusPrefix(op3);
|
||||||
|
|
@ -18,8 +18,8 @@ int main() {
|
||||||
assert(3 == *Op_IndexInto(op3, Op_IndexIntoConst(op2, Op_Functor(op1))), "[] or () failed");
|
assert(3 == *Op_IndexInto(op3, Op_IndexIntoConst(op2, Op_Functor(op1))), "[] or () failed");
|
||||||
assert(5 == Op_Functor_i(op3, 2), "f(x) failed");
|
assert(5 == Op_Functor_i(op3, 2), "f(x) failed");
|
||||||
|
|
||||||
delete_Op(op1);
|
Op_delete(op1);
|
||||||
delete_Op(op2);
|
Op_delete(op2);
|
||||||
delete_Op(op3);
|
Op_delete(op3);
|
||||||
SWIG_exit(0);
|
SWIG_exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,14 @@ public:
|
||||||
SWIG_typemap_lang("c");
|
SWIG_typemap_lang("c");
|
||||||
SWIG_config_file("c.swg");
|
SWIG_config_file("c.swg");
|
||||||
|
|
||||||
|
// The default naming convention is to use new_Foo(), copy_Foo() and delete_Foo() for the default/copy ctor and dtor of the class Foo, but we prefer to
|
||||||
|
// start all Foo methods with the same prefix, so change this. Notice that new/delete are chosen to ensure that we avoid conflicts with the existing class
|
||||||
|
// methods, more natural create/destroy, for example, could result in errors if the class already had a method with the same name, but this is impossible
|
||||||
|
// for the chosen names as they're keywords in C++ ("copy" is still a problem but we'll just have to live with it).
|
||||||
|
Swig_name_register("construct", "%n%c_new");
|
||||||
|
Swig_name_register("copy", "%n%c_copy");
|
||||||
|
Swig_name_register("destroy", "%n%c_delete");
|
||||||
|
|
||||||
allow_overloading();
|
allow_overloading();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue