Add minimal shared_ptr support

Enable the tests and support of shared_ptr in them for C (which required
disabling a previously passing, because not doing anything, attributes
test which is currently broken for unrelated reasons).
This commit is contained in:
Vadim Zeitlin 2021-10-15 01:26:22 +02:00
commit e78c8f39ed
12 changed files with 132 additions and 12 deletions

View file

@ -26,6 +26,12 @@ CPP_TEST_CASES := \
c_backend_cpp_natural_std_string \
c_backend_cpp_exception
CPP11_TEST_CASES := \
cpp11_shared_ptr_const \
cpp11_shared_ptr_nullptr_in_containers \
cpp11_shared_ptr_overload \
cpp11_shared_ptr_upcast \
# The following tests are currently broken and need to be fixed.
FAILING_C_TESTS := \
arrays \
@ -60,10 +66,7 @@ FAILING_CPP_TESTS := \
grouping \
import_nomodule \
li_attribute \
li_boost_shared_ptr \
li_boost_shared_ptr_bits \
li_boost_shared_ptr_director \
li_boost_shared_ptr_template \
li_boost_shared_ptr_attribute \
li_std_deque \
li_std_wstring \
li_windows \
@ -71,9 +74,7 @@ FAILING_CPP_TESTS := \
member_pointer \
member_pointer_const \
mixed_types \
multiple_inheritance_shared_ptr \
nested_class \
smart_pointer_template_defaults_overload \
template_basic \
template_default \
template_enum \

View file

@ -0,0 +1,16 @@
#include "cpp11_shared_ptr_const_wrap.h"
#include <assert.h>
int main(int argc, const char *argv[]) {
Foo* f;
Foo* f2;
f = Foo_new(17);
assert(Foo_get_m(f) == 17);
f2 = cpp11_shared_ptr_const_foo(f);
assert(Foo_get_m(f2) == 17);
Foo_delete(f2);
Foo_delete(f);
return 0;
}

View file

@ -0,0 +1,26 @@
#include "cpp11_shared_ptr_upcast_wrap.h"
#include <assert.h>
int main(int argc, const char *argv[]) {
{
Derived* d;
d = Derived_new_i(17);
assert( cpp11_shared_ptr_upcast_base_num1((Base *)d) == -1 );
assert( cpp11_shared_ptr_upcast_derived_num1(d) == 17 );
Derived_delete(d);
}
{
Derived2* d2;
d2 = Derived2_new_i(289);
assert( cpp11_shared_ptr_upcast_base2_num1((Base2 *)d2) == -1 );
assert( cpp11_shared_ptr_upcast_derived2_num1(d2) == 289 );
Derived2_delete(d2);
}
return 0;
}

View file

@ -0,0 +1,17 @@
#include "li_boost_shared_ptr_wrap.h"
#include <assert.h>
#include <string.h>
int main(int argc, const char *argv[]) {
{
Klass* k = Klass_new_rcstd_string("me oh my");
assert( strcmp(Klass_getValue(k), "me oh my") == 0 );
Klass_delete(k);
}
{
Klass* k = li_boost_shared_ptr_factorycreate();
assert( strcmp(Klass_getValue(k), "factorycreate") == 0 );
Klass_delete(k);
}
}

View file

@ -34,7 +34,7 @@ public:
%}
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#if defined(SWIGC) || defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif

View file

@ -44,7 +44,7 @@
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
#endif
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#if defined(SWIGC) || defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif

View file

@ -1,6 +1,6 @@
%module li_boost_shared_ptr_attribute
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#if defined(SWIGC) || defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif

View file

@ -1,6 +1,6 @@
%module li_boost_shared_ptr_bits
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#if defined(SWIGC) || defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif

View file

@ -4,7 +4,7 @@
#include <boost/shared_ptr.hpp>
%}
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGR)
#if defined(SWIGC) || defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGR)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif

View file

@ -30,7 +30,7 @@
%}
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#if defined(SWIGC) || defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif