From: Jason D. <Jas...@yo...> - 2009-01-09 00:46:27
|
Ok figured it out, was able to define a typemap using the example set forth in the std_string.i file. %typemap(out) myStringClass { ZVAL_STRINGL($result, (char *)static_cast<const char*>($1), $1.GetByteSize(), 1); } Works very well, swig is really fun! FYI is there a cross language string convertor macro in swig? So that I wouldn't have to qualify this typemap for just PHP? Jason D. Dictos Software Architect Yosemite Technologies, Inc. 7435 N. Ingram Ave Fresno, CA 93711 (559) 392-1875 (cell) (559) 449-8181 x146 (office) (559) 449-1188 (fax) From: Jason Dictos Sent: Thursday, January 08, 2009 4:17 PM To: 'swi...@li...' Subject: Preserving "const" in char * definition So we have a string class that allows users to cast it to a const char *, but won't allow a casting to char * for type safety reasons. One of our wrapped methods returns this string class, and I was able to bypass the use of typemaps by doing the following: %module myModule %{ //Forward declarations myStringClass myMethod(); %] //Swigify these methods const char *myMethod(); However, when swig parses the definition, it strips out the "const" portion, and thus I get a compilation error in my wrapper file. I suppose the best way to do this would be through a typemap, but I'm not quite sure how. Any ideas? Jason D. Dictos Software Architect Yosemite Technologies, Inc. 7435 N. Ingram Ave Fresno, CA 93711 (559) 392-1875 (cell) (559) 449-8181 x146 (office) (559) 449-1188 (fax) |