[ruby] check whether object is of RTypedData using RTYPEDDATA_P.
This commit is contained in:
parent
207d9591f9
commit
ff9e9f9f98
4 changed files with 30 additions and 2 deletions
|
|
@ -26,6 +26,7 @@ CPP_TEST_CASES = \
|
|||
ruby_keywords \
|
||||
ruby_minherit_shared_ptr \
|
||||
ruby_naming \
|
||||
ruby_rdata \
|
||||
ruby_track_objects \
|
||||
ruby_track_objects_directors \
|
||||
std_containers \
|
||||
|
|
|
|||
7
Examples/test-suite/ruby/ruby_rdata_runme.rb
Normal file
7
Examples/test-suite/ruby/ruby_rdata_runme.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
require 'swig_assert'
|
||||
require 'ruby_rdata'
|
||||
|
||||
include Ruby_rdata
|
||||
|
||||
swig_assert_equal_simple(1, take_proc_or_cpp_obj_and_ret_1(Proc.new{}))
|
||||
swig_assert_equal_simple(1, take_proc_or_cpp_obj_and_ret_1(C.new))
|
||||
20
Examples/test-suite/ruby_rdata.i
Normal file
20
Examples/test-suite/ruby_rdata.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%module ruby_rdata
|
||||
|
||||
%{
|
||||
|
||||
class C {};
|
||||
|
||||
int take_proc_or_cpp_obj_and_ret_1(VALUE obj) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int take_proc_or_cpp_obj_and_ret_1(class C) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
class C {};
|
||||
|
||||
int take_proc_or_cpp_obj_and_ret_1(VALUE);
|
||||
int take_proc_or_cpp_obj_and_ret_1(C);
|
||||
|
|
@ -247,7 +247,7 @@ typedef struct {
|
|||
SWIGRUNTIME swig_ruby_owntype
|
||||
SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) {
|
||||
swig_ruby_owntype oldown = {0, 0};
|
||||
if (TYPE(obj) == T_DATA) {
|
||||
if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) {
|
||||
oldown.datafree = RDATA(obj)->dfree;
|
||||
RDATA(obj)->dfree = own.datafree;
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
|
|||
*ptr = 0;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
} else {
|
||||
if (TYPE(obj) != T_DATA) {
|
||||
if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
Data_Get_Struct(obj, void, vptr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue