Fix member pointers on 64 bit platforms
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10073 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a66071a8c7
commit
3acd5c2d94
2 changed files with 78 additions and 21 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
Version 1.3.32 (in progress)
|
Version 1.3.32 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
10/29/2007: wsfulton
|
||||||
|
[C#] Fix member pointers on 64 bit platforms.
|
||||||
|
|
||||||
10/28/2007: olly
|
10/28/2007: olly
|
||||||
[lua] Fix swig_lua_class instances to be static to allow multiple
|
[lua] Fix swig_lua_class instances to be static to allow multiple
|
||||||
SWIG wrappers to be compiled into the same executable statically.
|
SWIG wrappers to be compiled into the same executable statically.
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,54 @@
|
||||||
* The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */
|
* The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */
|
||||||
|
|
||||||
/* fragments */
|
/* fragments */
|
||||||
%fragment("int64_t", "header") {
|
%fragment("SWIG_PackData", "header") {
|
||||||
%#if defined(_MSC_VER)
|
/*
|
||||||
typedef __int64 int64_t;
|
Pack binary data into a string
|
||||||
%#else
|
*/
|
||||||
%#include <stdint.h>
|
/*SWIGRUNTIME*/ char *
|
||||||
%#endif
|
SWIG_PackData(char *c, void *ptr, size_t sz) {
|
||||||
|
static const char hex[17] = "0123456789abcdef";
|
||||||
|
register const unsigned char *u = (unsigned char *) ptr;
|
||||||
|
register const unsigned char *eu = u + sz;
|
||||||
|
for (; u != eu; ++u) {
|
||||||
|
register unsigned char uu = *u;
|
||||||
|
*(c++) = hex[(uu & 0xf0) >> 4];
|
||||||
|
*(c++) = hex[uu & 0xf];
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
%fragment("SWIG_UnPackData", "header") {
|
||||||
|
/*
|
||||||
|
Unpack binary data from a string
|
||||||
|
*/
|
||||||
|
/*SWIGRUNTIME*/ const char *
|
||||||
|
SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
|
register unsigned char *u = (unsigned char *) ptr;
|
||||||
|
register const unsigned char *eu = u + sz;
|
||||||
|
for (; u != eu; ++u) {
|
||||||
|
register char d = *(c++);
|
||||||
|
register unsigned char uu;
|
||||||
|
if ((d >= '0') && (d <= '9'))
|
||||||
|
uu = ((d - '0') << 4);
|
||||||
|
else if ((d >= 'a') && (d <= 'f'))
|
||||||
|
uu = ((d - ('a'-10)) << 4);
|
||||||
|
else
|
||||||
|
return (char *) 0;
|
||||||
|
d = *(c++);
|
||||||
|
if ((d >= '0') && (d <= '9'))
|
||||||
|
uu |= (d - '0');
|
||||||
|
else if ((d >= 'a') && (d <= 'f'))
|
||||||
|
uu |= (d - ('a'-10));
|
||||||
|
else
|
||||||
|
return (char *) 0;
|
||||||
|
*u = uu;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Primitive types */
|
/* Primitive types */
|
||||||
|
|
@ -94,8 +136,8 @@ typedef __int64 int64_t;
|
||||||
%typemap(cstype) SWIGTYPE & "$csclassname"
|
%typemap(cstype) SWIGTYPE & "$csclassname"
|
||||||
|
|
||||||
/* pointer to a class member */
|
/* pointer to a class member */
|
||||||
%typemap(ctype, fragment="int64_t") SWIGTYPE (CLASS::*) "int64_t"
|
%typemap(ctype) SWIGTYPE (CLASS::*) "char *"
|
||||||
%typemap(imtype) SWIGTYPE (CLASS::*) "ulong"
|
%typemap(imtype) SWIGTYPE (CLASS::*) "string"
|
||||||
%typemap(cstype) SWIGTYPE (CLASS::*) "$csclassname"
|
%typemap(cstype) SWIGTYPE (CLASS::*) "$csclassname"
|
||||||
|
|
||||||
/* The following are the in and out typemaps. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */
|
/* The following are the in and out typemaps. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */
|
||||||
|
|
@ -350,20 +392,32 @@ typedef __int64 int64_t;
|
||||||
|
|
||||||
/* Generic pointers and references */
|
/* Generic pointers and references */
|
||||||
%typemap(in) SWIGTYPE * %{ $1 = ($1_ltype)$input; %}
|
%typemap(in) SWIGTYPE * %{ $1 = ($1_ltype)$input; %}
|
||||||
%typemap(in) SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %}
|
%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{
|
||||||
|
void *voidptr = &$1;
|
||||||
|
SWIG_UnpackData($input, voidptr, sizeof($1));
|
||||||
|
%}
|
||||||
%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
|
%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
|
||||||
if(!$1) {
|
if(!$1) {
|
||||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
|
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
|
||||||
return $null;
|
return $null;
|
||||||
} %}
|
} %}
|
||||||
%typemap(out) SWIGTYPE * %{ $result = (void *)$1; %}
|
%typemap(out) SWIGTYPE * %{ $result = (void *)$1; %}
|
||||||
%typemap(out) SWIGTYPE (CLASS::*) %{ *($&1_ltype)&$result = $1; %}
|
%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{
|
||||||
|
char buf[128];
|
||||||
|
char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
|
||||||
|
*data = '\0';
|
||||||
|
$result = SWIG_csharp_string_callback(buf);
|
||||||
|
%}
|
||||||
%typemap(out) SWIGTYPE & %{ $result = (void *)$1; %}
|
%typemap(out) SWIGTYPE & %{ $result = (void *)$1; %}
|
||||||
|
|
||||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *, SWIGTYPE (CLASS::*)
|
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
|
||||||
%{ $result = ($1_ltype)$input; %}
|
%{ $result = ($1_ltype)$input; %}
|
||||||
%typemap(directorin) SWIGTYPE *, SWIGTYPE (CLASS::*)
|
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
|
||||||
|
%{ $result = ($1_ltype)$input; %}
|
||||||
|
|
||||||
|
%typemap(directorin) SWIGTYPE *
|
||||||
|
%{ $input = (void *) $1; %}
|
||||||
|
%typemap(directorin) SWIGTYPE (CLASS::*)
|
||||||
%{ $input = (void *) $1; %}
|
%{ $input = (void *) $1; %}
|
||||||
|
|
||||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
|
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
|
||||||
|
|
@ -607,8 +661,8 @@ typedef __int64 int64_t;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) {
|
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) {
|
||||||
ulong cMemberPtr = $imcall;
|
string cMemberPtr = $imcall;
|
||||||
$csclassname ret = (cMemberPtr == 0) ? null : new $csclassname(cMemberPtr, $owner);$excode
|
$csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -724,8 +778,8 @@ typedef __int64 int64_t;
|
||||||
|
|
||||||
%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE (CLASS::*) %{
|
%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE (CLASS::*) %{
|
||||||
get {
|
get {
|
||||||
ulong cMemberPtr = $imcall;
|
string cMemberPtr = $imcall;
|
||||||
$csclassname ret = (cMemberPtr == 0) ? null : new $csclassname(cMemberPtr, $owner);$excode
|
$csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode
|
||||||
return ret;
|
return ret;
|
||||||
} %}
|
} %}
|
||||||
|
|
||||||
|
|
@ -803,17 +857,17 @@ typedef __int64 int64_t;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%typemap(csbody) SWIGTYPE (CLASS::*) %{
|
%typemap(csbody) SWIGTYPE (CLASS::*) %{
|
||||||
private ulong swigCMemberPtr;
|
private string swigCMemberPtr;
|
||||||
|
|
||||||
internal $csclassname(ulong cMemberPtr, bool futureUse) {
|
internal $csclassname(string cMemberPtr, bool futureUse) {
|
||||||
swigCMemberPtr = cMemberPtr;
|
swigCMemberPtr = cMemberPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $csclassname() {
|
protected $csclassname() {
|
||||||
swigCMemberPtr = 0;
|
swigCMemberPtr = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ulong getCMemberPtr($csclassname obj) {
|
internal static string getCMemberPtr($csclassname obj) {
|
||||||
return obj.swigCMemberPtr;
|
return obj.swigCMemberPtr;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue