From: <ash...@us...> - 2009-08-16 05:18:39
|
Revision: 11587 http://swig.svn.sourceforge.net/swig/?rev=11587&view=rev Author: ashishs99 Date: 2009-08-16 05:18:33 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Some fixes. Modified Paths: -------------- branches/gsoc2009-ashishs99/Lib/objc/objc.swg branches/gsoc2009-ashishs99/Lib/objc/objchead.swg Modified: branches/gsoc2009-ashishs99/Lib/objc/objc.swg =================================================================== --- branches/gsoc2009-ashishs99/Lib/objc/objc.swg 2009-08-16 05:17:37 UTC (rev 11586) +++ branches/gsoc2009-ashishs99/Lib/objc/objc.swg 2009-08-16 05:18:33 UTC (rev 11587) @@ -60,11 +60,11 @@ // Pointer, references and arrays %typemap(in) char *, char *& -%{ $1 = [$input cStringUsingEncoding: NSStringEncodingConversionAllowLossy]; %} //TBD +%{ $1 = [$input cStringUsingEncoding: [NSString defaultCStringEncoding]]; %} %typemap(in) char[ANY] -%{ $1 = [$input cStringUsingEncoding: NSStringEncodingConversionAllowLossy]; %} //TBD +%{ $1 = [$input cStringUsingEncoding: [NSString defaultCStringEncoding]]; %} %typemap(in) char[] -%{ $1 = [$input cStringUsingEncoding: NSStringEncodingConversionAllowLossy]; %} //TBD +%{ $1 = [$input cStringUsingEncoding: [NSString defaultCStringEncoding]]; %} %typemap(in) SWIGTYPE * %{ $1 = ($1_ltype)$input; %} @@ -166,8 +166,7 @@ /* Following are the "objcout" typemaps for Objective-C++ to Objective-C to conversions */ // Primitive types -%typemap(objcout) bool, const bool &, - char, const char &, +%typemap(objcout) char, const char &, signed char, const signed char &, unsigned char, const unsigned char &, short, const short &, @@ -184,6 +183,12 @@ $1_ltype ret = $imcall; return ret; } + +%typemap(objcout) bool, const bool & { + BOOL ret = $imcall; + return ret; + +} // Pointers, references and arrays %typemap(objcout) char *, char *&, char[ANY], char[] { @@ -237,6 +242,7 @@ %typemap(objcinterface) SWIGTYPE %{ { void *swigCPtr; + BOOL swigCMemOwn; } - (void*)getCptr; - (id)initWithCptr: (void*) cptr; @@ -376,17 +382,86 @@ [super dealloc]; } -/* Objective-C specific directives */ -#define %objcconst(flag) %feature("objc:const","flag") -#define %objcconstvalue(value) %feature("objc:constvalue",value) -#define %objcenum(wrapapproach) %feature("objc:enum","wrapapproach") -#define %objcmethodmodifiers %feature("objc:methodmodifiers") -#define %objcnothrowexception %feature("except") -#define %objcattributes %feature("objc:attributes") -/* Exception handling */ +/* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions + * that cannot be overloaded in Objective-C as more than one C++ type maps to a single Objective-C type */ + +%typecheck(SWIG_TYPECHECK_BOOL) /* Objective-C boolean */ + BOOL, + bool, + const bool & + "" + +%typecheck(SWIG_TYPECHECK_CHAR) /* Objective-C char */ + char, + const char & + "" + +%typecheck(SWIG_TYPECHECK_INT8) /* Objective-C byte */ + signed char, + const signed char & + "" + +%typecheck(SWIG_TYPECHECK_INT16) /* Objective-C short */ + unsigned char, + short, + const unsigned char &, + const short & + "" + +%typecheck(SWIG_TYPECHECK_INT32) /* Objective-C int */ + unsigned short, + int, + long, + const unsigned short &, + const int &, + const long & + "" + +%typecheck(SWIG_TYPECHECK_INT64) /* Objective-C long */ + unsigned int, + unsigned long, + long long, + const unsigned int &, + const unsigned long &, + const long long & + "" + +%typecheck(SWIG_TYPECHECK_INT128) /* Objective-C BigInteger */ + unsigned long long, + const unsigned long long & + "" + +%typecheck(SWIG_TYPECHECK_FLOAT) /* Objective-C float */ + float, + const float & + "" + +%typecheck(SWIG_TYPECHECK_DOUBLE) /* Objective-C double */ + double, + const double & + "" + +%typecheck(SWIG_TYPECHECK_STRING) /* Objective-C String */ + char *, + char *&, + char[ANY], + char [] + "" + +%typecheck(SWIG_TYPECHECK_POINTER) /* Default */ + SWIGTYPE, + SWIGTYPE *, + SWIGTYPE &, + SWIGTYPE [], + SWIGTYPE (CLASS::*) + "" + + +// Exception handling + %typemap(throws) int, long, short, @@ -403,6 +478,20 @@ %typemap(throws) char * %{ NString* aFormat = [NSString stringWithString:@"%s"]; [NSException raise:@"$1_type exception" format: aFormat, $1] %} + + +// Objective-C specific directives +#define %objcconst(flag) %feature("objc:const","flag") +#define %objcconstvalue(value) %feature("objc:constvalue",value) +#define %objcenum(wrapapproach) %feature("objc:enum","wrapapproach") +#define %objcmethodmodifiers %feature("objc:methodmodifiers") +#define %objcnothrowexception %feature("except") +#define %objcattributes %feature("objc:attributes") + +/* Some ANSI C typemaps */ + +%apply unsigned long { size_t }; +%apply const unsigned long & { const size_t & }; // Default enum handling %include <enums.swg> Modified: branches/gsoc2009-ashishs99/Lib/objc/objchead.swg =================================================================== --- branches/gsoc2009-ashishs99/Lib/objc/objchead.swg 2009-08-16 05:17:37 UTC (rev 11586) +++ branches/gsoc2009-ashishs99/Lib/objc/objchead.swg 2009-08-16 05:18:33 UTC (rev 11587) @@ -8,7 +8,13 @@ * ----------------------------------------------------------------------------- */ %insert(runtime) %{ +#import <Foundation/Foundation.h> #include <stdlib.h> #include <string.h> %} +%insert(runtime) %{ +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) { /*throw exception*/ return nullreturn; } else +%} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |