Additional fixes for Ruby 1.8 compatibility.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4688 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
3acd792de3
commit
7cfddcffc7
3 changed files with 34 additions and 19 deletions
|
|
@ -390,7 +390,7 @@ typedef unsigned long VALUE;
|
||||||
|
|
||||||
%typemap(in) (char *STRING, int LENGTH) {
|
%typemap(in) (char *STRING, int LENGTH) {
|
||||||
$1 = ($1_ltype) StringValuePtr($input);
|
$1 = ($1_ltype) StringValuePtr($input);
|
||||||
$2 = ($2_ltype) RSTRING($input)->len;
|
$2 = ($2_ltype) StringValueLen($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some ANSI C typemaps */
|
/* Some ANSI C typemaps */
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,6 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Ruby 1.8 deprecates STR2CSTR() in favor of StringValuePtr() */
|
|
||||||
#ifndef StringValuePtr
|
|
||||||
#define StringValuePtr(x) STR2CSTR((x))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Need to be very careful about how these macros are defined, especially
|
* Need to be very careful about how these macros are defined, especially
|
||||||
* when compiling C++ code or C code with an ANSI C compiler.
|
* when compiling C++ code or C code with an ANSI C compiler.
|
||||||
|
|
@ -80,3 +75,28 @@ typedef struct {
|
||||||
void (*mark)(void *);
|
void (*mark)(void *);
|
||||||
void (*destroy)(void *);
|
void (*destroy)(void *);
|
||||||
} swig_class;
|
} swig_class;
|
||||||
|
|
||||||
|
/* Don't use for expressions have side effect */
|
||||||
|
#ifndef RB_STRING_VALUE
|
||||||
|
#define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s)))
|
||||||
|
#endif
|
||||||
|
#ifndef StringValue
|
||||||
|
#define StringValue(s) RB_STRING_VALUE(s)
|
||||||
|
#endif
|
||||||
|
#ifndef StringValuePtr
|
||||||
|
#define StringValuePtr(s) RSTRING(RB_STRING_VALUE(s))->ptr
|
||||||
|
#endif
|
||||||
|
#ifndef StringValueLen
|
||||||
|
#define StringValueLen(s) RSTRING(RB_STRING_VALUE(s))->len
|
||||||
|
#endif
|
||||||
|
#ifndef SafeStringValue
|
||||||
|
#define SafeStringValue(v) do {\
|
||||||
|
StringValue(v);\
|
||||||
|
rb_check_safe_str(v);\
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_RB_DEFINE_ALLOC_FUNC
|
||||||
|
#define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF(klass), "new")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -458,8 +458,8 @@ public:
|
||||||
|
|
||||||
void create_command(Node *n, const String_or_char *iname) {
|
void create_command(Node *n, const String_or_char *iname) {
|
||||||
|
|
||||||
|
String *alloc_func_name = Swig_name_wrapper(iname);
|
||||||
String *wname = Swig_name_wrapper(iname);
|
String *wname = Swig_name_wrapper(iname);
|
||||||
String *wname2 = Swig_name_wrapper(iname);
|
|
||||||
if (CPlusPlus) {
|
if (CPlusPlus) {
|
||||||
Insert(wname,0,"VALUEFUNC(");
|
Insert(wname,0,"VALUEFUNC(");
|
||||||
Append(wname,")");
|
Append(wname,")");
|
||||||
|
|
@ -479,13 +479,11 @@ public:
|
||||||
iname, "\", ", wname, ", -1);\n", NIL);
|
iname, "\", ", wname, ", -1);\n", NIL);
|
||||||
break;
|
break;
|
||||||
case CONSTRUCTOR_ALLOCATE:
|
case CONSTRUCTOR_ALLOCATE:
|
||||||
Printv(s, "#ifdef HAVE_RB_DEFINE_ALLOC_FUNC\n", NIL);
|
Printf(s, "#ifdef HAVE_RB_DEFINE_ALLOC_FUNC\n");
|
||||||
Printv(s, tab4, "rb_define_alloc_func(", klass->vname,
|
Printv(s, tab4, "rb_define_alloc_func(", klass->vname, ", ", alloc_func_name, ");\n", NIL);
|
||||||
", ", wname2, ");\n", NIL);
|
Printf(s, "#else\n");
|
||||||
Printv(s, "#else\n", NIL);
|
Printv(s, tab4, "rb_define_singleton_method(", klass->vname, ", \"new\", ", wname, ", -1);\n", NIL);
|
||||||
Printv(s, tab4, "rb_define_singleton_method(", klass->vname,
|
Printf(s, "#endif\n");
|
||||||
", \"new\", ", wname, ", -1);\n", NIL);
|
|
||||||
Printv(s, "#endif\n", NIL);
|
|
||||||
Replaceall(klass->init,"$allocator", s);
|
Replaceall(klass->init,"$allocator", s);
|
||||||
break;
|
break;
|
||||||
case CONSTRUCTOR_INITIALIZE:
|
case CONSTRUCTOR_INITIALIZE:
|
||||||
|
|
@ -516,7 +514,7 @@ public:
|
||||||
Delete(temp);
|
Delete(temp);
|
||||||
Delete(s);
|
Delete(s);
|
||||||
Delete(wname);
|
Delete(wname);
|
||||||
Delete(wname2);
|
Delete(alloc_func_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
|
|
@ -1342,10 +1340,7 @@ public:
|
||||||
Printv(f_header, klass->header,NIL);
|
Printv(f_header, klass->header,NIL);
|
||||||
|
|
||||||
String *s = NewString("");
|
String *s = NewString("");
|
||||||
Printv(s, "#ifndef HAVE_RB_DEFINE_ALLOC_FUNC\n", NIL);
|
Printv(s, tab4, "rb_undef_alloc_func(", klass->vname, ");\n", NIL);
|
||||||
Printv(s, tab4, "rb_undef_method(CLASS_OF(", klass->vname,
|
|
||||||
"), \"new\");\n", NIL);
|
|
||||||
Printv(s, "#endif\n", NIL);
|
|
||||||
Replaceall(klass->init,"$allocator", s);
|
Replaceall(klass->init,"$allocator", s);
|
||||||
Replaceall(klass->init,"$initializer", "");
|
Replaceall(klass->init,"$initializer", "");
|
||||||
Replaceall(klass->init,"$super", "rb_cObject");
|
Replaceall(klass->init,"$super", "rb_cObject");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue