summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Jezabek <jezabek@poczta.onet.pl>2008-08-18 12:36:35 +0000
committerJan Jezabek <jezabek@poczta.onet.pl>2008-08-18 12:36:35 +0000
commit271e7f9169c601f9886e2cccac2b24bc16ee68d7 (patch)
tree113b2b9bad0685173b753dff41b22d6315bd6d27
parent78a550dfe9611068226b84adac9c7b25ba7eb36b (diff)
downloadswig-271e7f9169c601f9886e2cccac2b24bc16ee68d7.tar.gz
Added constover run-test. Fixed object creation using the class factory.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-jezabek@10784 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Examples/test-suite/com/constover_runme.vbs42
-rw-r--r--Lib/com/com.swg2
-rw-r--r--Source/Modules/com.cxx18
3 files changed, 58 insertions, 4 deletions
diff --git a/Examples/test-suite/com/constover_runme.vbs b/Examples/test-suite/com/constover_runme.vbs
new file mode 100644
index 000000000..72fd31612
--- /dev/null
+++ b/Examples/test-suite/com/constover_runme.vbs
@@ -0,0 +1,42 @@
+Dim constover, p, f
+
+Set constover = CreateObject("constover.constover")
+
+p = constover.test("test")
+If p <> "test" Then
+ WScript.Echo "test failed!"
+ WScript.Quit 1
+End If
+
+p = constover.test_pconst("test")
+If p <> "test_pconst" Then
+ WScript.Echo "test_pconst failed!"
+ WScript.Quit 1
+End If
+
+Set f = CreateObject("constover.Foo")
+
+p = f.test("test")
+If p <> "test" Then
+ WScript.Echo "member-test failed!"
+ WScript.Quit 1
+End If
+
+p = f.test_pconst("test")
+If p <> "test_pconst" Then
+ WScript.Echo "member-test_pconst failed!"
+ WScript.Quit 1
+End If
+
+p = f.test_constm("test")
+If p <> "test_constmethod" Then
+ WScript.Echo "member-test_constm failed!"
+ WScript.Quit 1
+End If
+
+p = f.test_pconstm("test")
+If p <> "test_pconstmethod" Then
+ WScript.Echo "member-test_pconstm failed!"
+ WScript.Quit 1
+End If
+
diff --git a/Lib/com/com.swg b/Lib/com/com.swg
index 471aa52eb..e68daf31f 100644
--- a/Lib/com/com.swg
+++ b/Lib/com/com.swg
@@ -546,7 +546,7 @@ HRESULT SWIGSTDCALL SWIGClassFactoryCreateInstance(SWIGClassFactory *factory, SW
return CLASS_E_NOAGGREGATION;
/* Create the instance */
- obj = (SWIGWrappedObject *) ((void* (SWIGSTDCALL *)(void *)) factory->newInstance)(NULL);
+ obj = (SWIGWrappedObject *) ((void* (SWIGSTDCALL *)()) factory->newInstance)();
if (obj == NULL) {
return E_OUTOFMEMORY;
diff --git a/Source/Modules/com.cxx b/Source/Modules/com.cxx
index 02abaec6f..be525ae70 100644
--- a/Source/Modules/com.cxx
+++ b/Source/Modules/com.cxx
@@ -432,7 +432,7 @@ public:
Printf(module_class_vtable_code, "extern SWIG_funcptr _wrap%s_vtable[];\n\n", module_class_name);
Printf(module_class_vtable_code,
- "void * SWIGSTDCALL _wrap_new_%s(void *SWIG_ignored) {\n"
+ "void * SWIGSTDCALL _wrap_new_%s() {\n"
" return _wrap_new_staticclass(_wrap%s_vtable, &IID_I%s);\n"
"};\n\n",
module_class_name, module_class_name, module_class_name);
@@ -999,7 +999,8 @@ public:
constructor_flag = false;
static_flag = false;
- if (Getattr(n, "default_constructor")) {
+ if (Getattr(n, "default_constructor") ||
+ checkAttribute(n, "access", "public") && !Getattr(n, "parms")) {
default_ctor_wname = Copy(Getattr(n, "wrap:name"));
}
@@ -1677,12 +1678,23 @@ public:
Printv(proxy_class_vtable_code, "\n};\n\n", NIL);
+ String *classtype = Getattr(n, "classtype");
+
if (!Getattr(n, "abstract") && default_ctor_wname != NULL) {
+ Printf(proxy_class_vtable_code, "%s* SWIGSTDCALL SWIG_new_%s() {\n"
+ "#ifdef __cplusplus\n"
+ " return (%s *) SWIG_wrap%s((void *) new %s(), 1);\n"
+ "#else\n"
+ " return (%s *) SWIG_wrap%s((void *) malloc(sizeof(%s)), 1);\n"
+ "#endif\n"
+ "}\n\n", classtype, proxy_class_name, classtype, proxy_class_name,
+ classtype, classtype, proxy_class_name, classtype, classtype);
+
Printf(proxy_class_vtable_code, "GUID CLSID_%s = ", proxy_class_name);
formatGUID(proxy_class_vtable_code, proxy_clsid, true);
Printf(proxy_class_vtable_code, ";\n\n");
- Printf(clsid_list, " { (SWIG_funcptr) %s, &CLSID_%s, _T(\"{", default_ctor_wname, proxy_class_name);
+ Printf(clsid_list, " { (SWIG_funcptr) SWIG_new_%s, &CLSID_%s, _T(\"{", proxy_class_name, proxy_class_name);
formatGUID(clsid_list, proxy_clsid, false);
Printf(clsid_list, "}\"), _T(\"%s.%s\"), 1 },\n", namespce, proxy_class_name);
}