From: <je...@us...> - 2008-06-30 23:56:52
|
Revision: 10617 http://swig.svn.sourceforge.net/swig/?rev=10617&view=rev Author: jezabek Date: 2008-06-30 16:56:51 -0700 (Mon, 30 Jun 2008) Log Message: ----------- Some support for opaque types (i.e. incomplete types) Modified Paths: -------------- branches/gsoc2008-jezabek/Lib/com/com.swg branches/gsoc2008-jezabek/Source/Modules/com.cxx Modified: branches/gsoc2008-jezabek/Lib/com/com.swg =================================================================== --- branches/gsoc2008-jezabek/Lib/com/com.swg 2008-06-30 23:41:27 UTC (rev 10616) +++ branches/gsoc2008-jezabek/Lib/com/com.swg 2008-06-30 23:56:51 UTC (rev 10617) @@ -184,6 +184,55 @@ char *guid_string; } SWIGClassDescription_t; +HRESULT SWIGSTDCALL _wrap_opaque_QueryInterface1(void *that, GUID *iid, void ** ppvObject) { + if (SWIGIsEqual(iid, &IID_ISWIGWrappedObject)) { + /* FIXME: This could be more elegant */ + SWIGAddRef1(that); + *ppvObject = (void *) ((void **)that + 1); + return S_OK; + } + + if (SWIGIsEqual(iid, &IID_IUnknown)) { + /* FIXME: This could be more elegant */ + SWIGAddRef1(that); + *ppvObject = that; + return S_OK; + } + + return E_NOINTERFACE; +} + +HRESULT SWIGSTDCALL _wrap_opaque_QueryInterface2(void *that, GUID *iid, void ** ppvObject) { + return _wrap_opaque_QueryInterface1((void *) ((void **) that - 1), iid, ppvObject); +} + +SWIG_funcptr _wrap_opaque_SWIGWrappedObject_vtable[] = { + (SWIG_funcptr) _wrap_opaque_QueryInterface2, + (SWIG_funcptr) SWIGAddRef2, + (SWIG_funcptr) SWIGRelease2, + (SWIG_funcptr) SWIGGetCPtr +}; + +SWIG_funcptr _wrap_opaque_vtable[] = { + (SWIG_funcptr) _wrap_opaque_QueryInterface1, + (SWIG_funcptr) SWIGAddRef1, + (SWIG_funcptr) SWIGRelease1, +}; + +void * SWIGSTDCALL SWIG_wrap_opaque(void *arg) { +#ifdef __cplusplus + SWIGWrappedObject *res = new SWIGWrappedObject; +#else + SWIGWrappedObject *res = (SWIGWrappedObject *) malloc(sizeof(SWIGWrappedObject)); +#endif + res->vtable = _wrap_opaque_vtable; + res->SWIGWrappedObject_vtable = _wrap_opaque_SWIGWrappedObject_vtable; + res->cPtr = arg; + res->cMemOwn = 0; + res->refCount = 0; + return (void *) res; +} + %} %insert("factory") %{ Modified: branches/gsoc2008-jezabek/Source/Modules/com.cxx =================================================================== --- branches/gsoc2008-jezabek/Source/Modules/com.cxx 2008-06-30 23:41:27 UTC (rev 10616) +++ branches/gsoc2008-jezabek/Source/Modules/com.cxx 2008-06-30 23:56:51 UTC (rev 10617) @@ -1103,9 +1103,14 @@ Clear(proxy_class_def); Clear(proxy_class_forward_def); + proxy_iid = new GUID; + generateGUID(proxy_iid); + Printv(proxy_class_forward_def, " interface $comclassname;\n", NIL); - Printv(proxy_class_def, " [\n object,\n local\n ]\n interface $comclassname {\n", + Printv(proxy_class_def, " [\n object,\n local,\n uuid(", NIL); + formatGUID(proxy_class_def, proxy_iid, false); + Printv(proxy_class_def, ")\n ]\n interface $comclassname {\n", typemapLookup("combody", type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), typemapLookup("comcode", type, WARN_NONE), " };\n\n", NIL); @@ -1115,8 +1120,12 @@ Replaceall(proxy_class_forward_def, "$module", module_class_name); Replaceall(proxy_class_def, "$module", module_class_name); + Printf(f_vtable_defs, "void * (SWIGSTDCALL * SWIG_wrap%s)(void *) = SWIG_wrap_opaque;\n", classname); + Printv(f_proxy_forward_defs, proxy_class_forward_def, NIL); Printv(f_proxy, proxy_class_def, NIL); + + delete proxy_iid; } /* ----------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |