modify test-suite (barring python atm) to not rely on the -I path to find the input .i file - removes the new warning 125 and sets up the test-suite for testing with ccache. This change required the use of -outcurrentdir and moving the .i files from the language subdirectories to the directory above along with some .i file name changes.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10949 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
53f786e5a6
commit
db83e51441
61 changed files with 390 additions and 709 deletions
|
|
@ -10,7 +10,6 @@ top_srcdir = @top_srcdir@
|
|||
top_builddir = @top_builddir@
|
||||
|
||||
CPP_TEST_CASES = \
|
||||
keywords \
|
||||
li_cdata \
|
||||
li_cstring \
|
||||
li_factory \
|
||||
|
|
@ -20,11 +19,14 @@ CPP_TEST_CASES = \
|
|||
li_std_queue \
|
||||
li_std_set \
|
||||
li_std_stack \
|
||||
naming \
|
||||
primitive_types \
|
||||
std_containers \
|
||||
track_objects \
|
||||
track_objects_directors
|
||||
ruby_keywords \
|
||||
ruby_naming \
|
||||
ruby_track_objects \
|
||||
ruby_track_objects_directors \
|
||||
std_containers
|
||||
# ruby_li_std_speed
|
||||
# stl_new
|
||||
|
||||
C_TEST_CASES += \
|
||||
li_cdata \
|
||||
|
|
@ -39,7 +41,7 @@ SWIGOPT += -w801 -noautorename -features autodoc=4
|
|||
# Rules for the different types of tests
|
||||
|
||||
# make sure -autorename is true for the naming test
|
||||
naming.cpptest: SWIGOPT = -autorename
|
||||
ruby_naming.cpptest: SWIGOPT += -autorename
|
||||
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
%module keywords
|
||||
|
||||
// fix up conflicts with C++ keywords
|
||||
%rename("and") Keywords::and_;
|
||||
%rename("break") Keywords::break_;
|
||||
%rename("case") Keywords::case_;
|
||||
%rename("class") Keywords::class_;
|
||||
%rename("defined?") Keywords::defined_;
|
||||
%rename("do") Keywords::do_;
|
||||
%rename("else") Keywords::else_;
|
||||
%rename("false") Keywords::false_;
|
||||
%rename("for") Keywords::for_;
|
||||
%rename("if") Keywords::if_;
|
||||
%rename("not") Keywords::not_;
|
||||
%rename("return") Keywords::return_;
|
||||
%rename("or") Keywords::or_;
|
||||
%rename("true") Keywords::true_;
|
||||
%rename("while") Keywords::while_;
|
||||
|
||||
|
||||
%inline %{
|
||||
|
||||
class Keywords {
|
||||
public:
|
||||
Keywords() {}
|
||||
|
||||
const char* alias() { return "alias"; }
|
||||
const char* and_() { return "and"; }
|
||||
const char* begin() { return "begin"; }
|
||||
const char* break_() { return "break"; }
|
||||
const char* case_() { return "case"; }
|
||||
const char* class_() { return "class"; }
|
||||
const char* def() { return "def"; }
|
||||
const char* defined_() { return "defined?"; }
|
||||
const char* do_() { return "do"; }
|
||||
const char* else_() { return "else"; }
|
||||
const char* elsif() { return "elsif"; }
|
||||
const char* end() { return "end"; }
|
||||
const char* ensure() { return "ensure"; }
|
||||
const char* false_() { return "false"; }
|
||||
const char* for_() { return "for"; }
|
||||
const char* if_() { return "if"; }
|
||||
const char* in() { return "in"; }
|
||||
const char* module() { return "module"; }
|
||||
const char* next() { return "next"; }
|
||||
const char* nil() { return "nil"; }
|
||||
const char* not_() { return "not"; }
|
||||
const char* or_() { return "or"; }
|
||||
const char* redo() { return "redo"; }
|
||||
const char* rescue() { return "rescue"; }
|
||||
const char* retry() { return "retry"; }
|
||||
const char* return_() { return "return"; }
|
||||
const char* self() { return "self"; }
|
||||
const char* super() { return "super"; }
|
||||
const char* then() { return "then"; }
|
||||
const char* true_() { return "true"; }
|
||||
const char* undef() { return "undef"; }
|
||||
const char* under() { return "under"; }
|
||||
const char* unless() { return "unless"; }
|
||||
const char* until() { return "until"; }
|
||||
const char* when() { return "when"; }
|
||||
const char* while_() { return "while"; }
|
||||
const char* yield() { return "yield"; }
|
||||
};
|
||||
%}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
%module li_std_functors
|
||||
|
||||
%include <std_vector.i>
|
||||
%include <std_deque.i>
|
||||
%include <std_list.i>
|
||||
%include <std_set.i>
|
||||
%include <std_map.i>
|
||||
%include <std_functors.i>
|
||||
|
||||
%template(Vector ) std::vector <swig::LANGUAGE_OBJ>;
|
||||
%template(Deque ) std::deque <swig::LANGUAGE_OBJ>;
|
||||
%template(List ) std::list <swig::LANGUAGE_OBJ>;
|
||||
|
||||
%template(Set ) std::set <swig::LANGUAGE_OBJ,
|
||||
swig::BinaryPredicate<> >;
|
||||
%template(Map ) std::map <swig::LANGUAGE_OBJ,swig::LANGUAGE_OBJ,
|
||||
swig::BinaryPredicate<> >;
|
||||
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
%module li_std_pair_lang_object
|
||||
|
||||
%include <std_pair.i>
|
||||
|
||||
namespace std {
|
||||
%template(ValuePair) pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >;
|
||||
}
|
||||
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/**
|
||||
* @file std_queue.i
|
||||
* @author gga
|
||||
* @date Sun May 6 01:52:44 2007
|
||||
*
|
||||
* @brief test of std::queue
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
%module li_std_queue
|
||||
|
||||
%include std_queue.i
|
||||
|
||||
|
||||
%template( IntQueue ) std::queue< int >;
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/**
|
||||
* @file li_std_speed.i
|
||||
* @author gga
|
||||
* @date Fri May 18 18:03:15 2007
|
||||
*
|
||||
* @brief A speed test of the ruby stl
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
%module li_std_speed
|
||||
|
||||
%include <std_list.i>
|
||||
%include <std_vector.i>
|
||||
%include <std_deque.i>
|
||||
%include <std_set.i>
|
||||
|
||||
%template(RbList) std::list<swig::GC_VALUE>;
|
||||
%template(RbVector) std::vector<swig::GC_VALUE>;
|
||||
%template(RbDeque) std::deque<swig::GC_VALUE>;
|
||||
%template(RbSet) std::set<swig::GC_VALUE>;
|
||||
|
||||
%template(RbFloatList) std::list<float>;
|
||||
%template(RbFloatVector) std::vector<float>;
|
||||
%template(RbFloatDeque) std::deque<float>;
|
||||
%template(RbFloatSet) std::set<float>;
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/**
|
||||
* @file std_stack.i
|
||||
* @author gga
|
||||
* @date Sun May 6 01:52:44 2007
|
||||
*
|
||||
* @brief test of std::stack
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
%module li_std_stack
|
||||
|
||||
%include std_stack.i
|
||||
|
||||
|
||||
%template( IntStack ) std::stack< int >;
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
%module naming
|
||||
|
||||
%predicate predicateMethod();
|
||||
%bang bangMethod();
|
||||
|
||||
/* This gets mapped to a constant */
|
||||
%constant int constant1 = 1;
|
||||
|
||||
/* This gets mapped to a constant */
|
||||
#define constant2 2
|
||||
|
||||
%immutable TestConstants::constant8;
|
||||
|
||||
%inline %{
|
||||
|
||||
/* ============ Test Constants Names ============== */
|
||||
|
||||
/* This gets mapped to a constant */
|
||||
#define constant3 3
|
||||
|
||||
/* These are all singleton methods */
|
||||
const int constant4[2] = {10, 20};
|
||||
const int constant5 = 5;
|
||||
static const int constant6 = 6;
|
||||
|
||||
|
||||
class TestConstants {
|
||||
public:
|
||||
TestConstants() : constant7(7) {}
|
||||
|
||||
/* This gets mapped to a method */
|
||||
const int constant7;
|
||||
|
||||
/* This gets mapped to a singleton method, but this is not legal C++ */
|
||||
static const int constant8;
|
||||
|
||||
/* This gets mapped to a method, but this it not legal C++ */
|
||||
/*const int constant9 = 9;*/
|
||||
|
||||
/* This gets mapped to a constant */
|
||||
static const int constant10 = 10;
|
||||
};
|
||||
|
||||
const int TestConstants::constant8 = 8;
|
||||
|
||||
const TestConstants * constant11[5];
|
||||
|
||||
|
||||
/* ============ Test Enum ============== */
|
||||
typedef enum {Red, Green, Blue} Colors;
|
||||
|
||||
|
||||
/* ============ Test Method Names ============== */
|
||||
class my_class {
|
||||
public:
|
||||
int methodOne()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MethodTwo()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int Method_THREE()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
int Method44_4()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
bool predicateMethod()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bangMethod()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int begin()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int end()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
%}
|
||||
|
||||
%inline
|
||||
{
|
||||
template <class _Type>
|
||||
struct A
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
%template(A_i) A<int>;
|
||||
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
require 'swig_assert'
|
||||
|
||||
require 'keywords'
|
||||
require 'ruby_keywords'
|
||||
|
||||
kw = Keywords::Keywords.new
|
||||
kw = Ruby_keywords::Keywords.new
|
||||
|
||||
if kw.alias != 'alias' then
|
||||
raise RuntimeError, 'Keyword method did not work: alias'
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
require 'benchmark'
|
||||
require 'mathn'
|
||||
require 'li_std_speed'
|
||||
include Li_std_speed
|
||||
require 'ruby_li_std_speed'
|
||||
include Ruby_li_std_speed
|
||||
|
||||
|
||||
def benchmark(f, phigh, sequences)
|
||||
|
|
@ -9,86 +9,86 @@
|
|||
|
||||
require 'swig_assert'
|
||||
|
||||
require 'naming'
|
||||
require 'ruby_naming'
|
||||
|
||||
# Check class names
|
||||
if not Naming
|
||||
raise RuntimeError, 'Invalid module name for Naming'
|
||||
if not Ruby_naming
|
||||
raise RuntimeError, 'Invalid module name for Ruby_naming'
|
||||
end
|
||||
|
||||
if not Naming::MyClass
|
||||
if not Ruby_naming::MyClass
|
||||
raise RuntimeError, 'Invalid class name for MyClass'
|
||||
end
|
||||
|
||||
|
||||
# Check constant names / values
|
||||
if Naming::CONSTANT1 != 1
|
||||
if Ruby_naming::CONSTANT1 != 1
|
||||
raise RuntimeError, "Incorrect value for CONSTANT1"
|
||||
end
|
||||
|
||||
if Naming::CONSTANT2 != 2
|
||||
if Ruby_naming::CONSTANT2 != 2
|
||||
raise RuntimeError, "Incorrect value for CONSTANT2"
|
||||
end
|
||||
|
||||
# Check constant names / values
|
||||
if Naming::CONSTANT3 != 3
|
||||
if Ruby_naming::CONSTANT3 != 3
|
||||
raise RuntimeError, "Incorrect value for CONSTANT3"
|
||||
end
|
||||
|
||||
if not Naming::methods.include?("constant4")
|
||||
if not Ruby_naming::methods.include?("constant4")
|
||||
raise RuntimeError, "Incorrect mapping for constant4"
|
||||
end
|
||||
|
||||
if not Naming::methods.include?("constant5")
|
||||
if not Ruby_naming::methods.include?("constant5")
|
||||
raise RuntimeError, "Incorrect mapping for constant5"
|
||||
end
|
||||
|
||||
if not Naming::methods.include?("constant6")
|
||||
if not Ruby_naming::methods.include?("constant6")
|
||||
raise RuntimeError, "Incorrect mapping for constant6"
|
||||
end
|
||||
|
||||
if not Naming::TestConstants.instance_methods.include?("constant7")
|
||||
if not Ruby_naming::TestConstants.instance_methods.include?("constant7")
|
||||
raise RuntimeError, "Incorrect mapping for constant7"
|
||||
end
|
||||
|
||||
if not Naming::TestConstants.methods.include?("constant8")
|
||||
if not Ruby_naming::TestConstants.methods.include?("constant8")
|
||||
raise RuntimeError, "Incorrect mapping for constant8"
|
||||
end
|
||||
|
||||
# There is no constant9 because it is illegal C++
|
||||
#if not Naming::TestConstants.instance_methods.include?("constant9")
|
||||
#if not Ruby_naming::TestConstants.instance_methods.include?("constant9")
|
||||
# raise RuntimeError, "Incorrect mapping for constant9"
|
||||
#end
|
||||
|
||||
if Naming::TestConstants::CONSTANT10 != 10
|
||||
if Ruby_naming::TestConstants::CONSTANT10 != 10
|
||||
raise RuntimeError, "Incorrect value for CONSTANT10"
|
||||
end
|
||||
|
||||
if not Naming::methods.include?("constant11")
|
||||
if not Ruby_naming::methods.include?("constant11")
|
||||
raise RuntimeError, "Incorrect mapping for constant11"
|
||||
end
|
||||
|
||||
|
||||
# Check enums
|
||||
if Naming::constants.include?("Color")
|
||||
if Ruby_naming::constants.include?("Color")
|
||||
raise RuntimeError, "Color enum should not be exposed to Ruby"
|
||||
end
|
||||
|
||||
if Naming::Red != 0
|
||||
if Ruby_naming::Red != 0
|
||||
raise RuntimeError, "Incorrect value for enum RED"
|
||||
end
|
||||
|
||||
if Naming::Green != 1
|
||||
if Ruby_naming::Green != 1
|
||||
raise RuntimeError, "Incorrect value for enum GREEN"
|
||||
end
|
||||
|
||||
if Naming::Blue != 2
|
||||
if Ruby_naming::Blue != 2
|
||||
raise RuntimeError, "Incorrect value for enum BLUE"
|
||||
end
|
||||
|
||||
|
||||
# Check method names
|
||||
my_class = Naming::MyClass.new()
|
||||
my_class = Ruby_naming::MyClass.new()
|
||||
|
||||
if my_class.method_one != 1
|
||||
raise RuntimeError, "Incorrect value for method_one"
|
||||
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
require 'swig_assert'
|
||||
|
||||
require 'track_objects_directors'
|
||||
require 'ruby_track_objects_directors'
|
||||
|
||||
class MyFoo < Track_objects_directors::Foo
|
||||
class MyFoo < Ruby_track_objects_directors::Foo
|
||||
def ping
|
||||
"MyFoo::ping()"
|
||||
end
|
||||
|
|
@ -22,12 +22,12 @@ a = MyFoo.new
|
|||
raise RuntimeError if a.ping != "MyFoo::ping()"
|
||||
raise RuntimeError if a.pong != "Foo::pong();MyFoo::ping()"
|
||||
|
||||
b = Track_objects_directors::Foo.new
|
||||
b = Ruby_track_objects_directors::Foo.new
|
||||
|
||||
raise RuntimeError if b.ping != "Foo::ping()"
|
||||
raise RuntimeError if b.pong != "Foo::pong();Foo::ping()"
|
||||
|
||||
container = Track_objects_directors::Container.new
|
||||
container = Ruby_track_objects_directors::Container.new
|
||||
foo = MyFoo.new
|
||||
container.set_foo(foo)
|
||||
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
require 'swig_assert'
|
||||
|
||||
require 'track_objects'
|
||||
require 'ruby_track_objects'
|
||||
|
||||
def test_same_ruby_object(foo1, foo2)
|
||||
if not foo1.equal?(foo2)
|
||||
|
|
@ -23,12 +23,12 @@ def test_same_cpp_object(foo1, foo2)
|
|||
end
|
||||
end
|
||||
|
||||
bar = Track_objects::Bar.new
|
||||
foo1 = Track_objects::Foo.new()
|
||||
bar = Ruby_track_objects::Bar.new
|
||||
foo1 = Ruby_track_objects::Foo.new()
|
||||
bar.set_unowned_foo(foo1)
|
||||
|
||||
# test_simple_identity
|
||||
foo2 = Track_objects::Foo.new()
|
||||
foo2 = Ruby_track_objects::Foo.new()
|
||||
foo3 = foo2
|
||||
|
||||
test_same_ruby_object(foo2, foo3)
|
||||
|
|
@ -48,8 +48,8 @@ test_same_ruby_object(foo5, foo6)
|
|||
test_same_cpp_object(foo5, foo6)
|
||||
|
||||
# test_new_foo_identity
|
||||
foo7 = Track_objects::Bar.get_new_foo()
|
||||
foo8 = Track_objects::Bar.get_new_foo()
|
||||
foo7 = Ruby_track_objects::Bar.get_new_foo()
|
||||
foo8 = Ruby_track_objects::Bar.get_new_foo()
|
||||
|
||||
if foo7.equal?(foo8)
|
||||
raise "Ruby objects should be different."
|
||||
|
|
@ -60,7 +60,7 @@ if foo7.cpp_equal(foo8)
|
|||
end
|
||||
|
||||
# test_set_owned_identity
|
||||
foo9 = Track_objects::Foo.new
|
||||
foo9 = Ruby_track_objects::Foo.new
|
||||
bar.set_owned_foo(foo9)
|
||||
foo10 = bar.get_owned_foo()
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ test_same_cpp_object(foo9, foo10)
|
|||
|
||||
# test_set_owned_identity2
|
||||
begin
|
||||
foo11 = Track_objects::Foo.new
|
||||
foo11 = Ruby_track_objects::Foo.new
|
||||
bar.set_owned_foo(foo11)
|
||||
foo11 = nil
|
||||
end
|
||||
|
|
@ -90,20 +90,20 @@ test_same_ruby_object(foo13, foo14)
|
|||
test_same_cpp_object(foo13, foo14)
|
||||
|
||||
# Now create the factory
|
||||
factory = Track_objects::Factory.new
|
||||
factory = Ruby_track_objects::Factory.new
|
||||
|
||||
# Create itemA which is really an itemB
|
||||
itemA = factory.createItem
|
||||
|
||||
# Check class
|
||||
if itemA.class != Track_objects::ItemA
|
||||
if itemA.class != Ruby_track_objects::ItemA
|
||||
raise RuntimeError, 'Item should have an ItemA class'
|
||||
end
|
||||
|
||||
# Now downcast
|
||||
itemB = Track_objects.downcast(itemA)
|
||||
itemB = Ruby_track_objects.downcast(itemA)
|
||||
|
||||
if itemB.class != Track_objects::ItemB
|
||||
if itemB.class != Ruby_track_objects::ItemB
|
||||
raise RuntimeError, 'Item should have an ItemB class'
|
||||
end
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
%module stl_new
|
||||
|
||||
%include <std_vector.i>
|
||||
%include <std_deque.i>
|
||||
%include <std_list.i>
|
||||
%include <std_set.i>
|
||||
%include <std_map.i>
|
||||
|
||||
%template(Vector ) std::vector <swig::LANGUAGE_OBJ>;
|
||||
%template(Deque ) std::deque <swig::LANGUAGE_OBJ>;
|
||||
%template(List ) std::list <swig::LANGUAGE_OBJ>;
|
||||
|
||||
%template(Set ) std::set <swig::LANGUAGE_OBJ,
|
||||
swig::BinaryPredicate<> >;
|
||||
%template(Map ) std::map <swig::LANGUAGE_OBJ,swig::LANGUAGE_OBJ,
|
||||
swig::BinaryPredicate<> >;
|
||||
|
||||
|
||||
// %inline %{
|
||||
// namespace swig {
|
||||
// void nth_element(swig::Iterator_T< _Iter>& first,
|
||||
// swig::Iterator_T< _Iter>& nth,
|
||||
// swig::Iterator_T< _Iter>& last,
|
||||
// const swig::BinaryPredicate<>& comp = swig::BinaryPredicate<>())
|
||||
// {
|
||||
// std::nth_element( first, nth, last, comp);
|
||||
// }
|
||||
// }
|
||||
// %}
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
%module track_objects
|
||||
|
||||
%include typemaps.i
|
||||
|
||||
%trackobjects Foo;
|
||||
|
||||
%newobject Bar::get_new_foo;
|
||||
|
||||
%typemap(in, numinputs=0) Foo** foo (Foo *temp) {
|
||||
/* %typemap(in, numinputs=0) Foo** foo */
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(argout) Foo** foo {
|
||||
/* %typemap(argout) Foo** foo */
|
||||
$result = SWIG_NewPointerObj((void *) *$1, $*1_descriptor, 0);
|
||||
}
|
||||
|
||||
%apply SWIGTYPE *DISOWN {Foo* ownedFoo};
|
||||
|
||||
|
||||
%trackobjects ItemA;
|
||||
%trackobjects ItemB;
|
||||
|
||||
%inline %{
|
||||
|
||||
class Foo
|
||||
{
|
||||
public:
|
||||
Foo() {}
|
||||
~Foo() {}
|
||||
|
||||
/* Helper method that can be called from Ruby that checks
|
||||
that two Ruby objects are pointing to the same underlying
|
||||
C++ object */
|
||||
bool cpp_equal(const Foo* other)
|
||||
{
|
||||
return (this == other);
|
||||
}
|
||||
|
||||
/* Just a simple method to call on Foo*/
|
||||
const char* say_hello()
|
||||
{
|
||||
return "Hello";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Bar
|
||||
{
|
||||
private:
|
||||
Foo* owned_;
|
||||
Foo* unowned_;
|
||||
public:
|
||||
Bar(): owned_(new Foo), unowned_(0)
|
||||
{
|
||||
}
|
||||
|
||||
~Bar()
|
||||
{
|
||||
delete owned_;
|
||||
}
|
||||
|
||||
/* Test that track objects works with %newobject */
|
||||
static Foo* get_new_foo()
|
||||
{
|
||||
return new Foo;
|
||||
}
|
||||
|
||||
/* Test the same foo Ruby object is created each time */
|
||||
Foo* get_owned_foo()
|
||||
{
|
||||
return owned_;
|
||||
}
|
||||
|
||||
/* Test that track objects works with argout parameters.*/
|
||||
void get_owned_foo_by_argument(Foo** foo)
|
||||
{
|
||||
*foo = owned_;
|
||||
}
|
||||
|
||||
/* Test that track objects works with the DISOWN typemap.*/
|
||||
void set_owned_foo(Foo* ownedFoo)
|
||||
{
|
||||
delete owned_;
|
||||
owned_ = ownedFoo;
|
||||
}
|
||||
|
||||
Foo* get_unowned_foo()
|
||||
{
|
||||
return unowned_;
|
||||
}
|
||||
|
||||
void set_unowned_foo(Foo* foo)
|
||||
{
|
||||
unowned_ = foo;
|
||||
}
|
||||
};
|
||||
|
||||
class ItemA
|
||||
{
|
||||
};
|
||||
|
||||
class ItemB: public ItemA
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
ItemB* downcast(ItemA* item)
|
||||
{
|
||||
return static_cast<ItemB*>(item);
|
||||
}
|
||||
|
||||
class Factory
|
||||
{
|
||||
public:
|
||||
Factory() {}
|
||||
|
||||
ItemA* createItem()
|
||||
{
|
||||
return new ItemB;
|
||||
}
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
%module(directors="1") track_objects_directors
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
%include "std_string.i";
|
||||
%feature("director") Foo;
|
||||
|
||||
%trackobjects;
|
||||
|
||||
%inline %{
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
Foo() {}
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping()
|
||||
{
|
||||
return "Foo::ping()";
|
||||
}
|
||||
|
||||
virtual std::string pong()
|
||||
{
|
||||
return "Foo::pong();" + ping();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Container {
|
||||
Foo* foo_;
|
||||
public:
|
||||
Foo* get_foo()
|
||||
{
|
||||
return foo_;
|
||||
}
|
||||
|
||||
void set_foo(Foo *foo)
|
||||
{
|
||||
foo_ = foo;
|
||||
}
|
||||
};
|
||||
|
||||
%}
|
||||
Loading…
Add table
Add a link
Reference in a new issue