rice 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Makefile.in +15 -10
- data/README.mingw +0 -0
- data/Rakefile +1 -1
- data/aclocal.m4 +22 -16
- data/bootstrap +0 -0
- data/config.guess +21 -11
- data/config.sub +38 -6
- data/configure +13 -10
- data/depcomp +19 -14
- data/install-sh +120 -108
- data/missing +0 -0
- data/rice/Class.ipp +2 -0
- data/rice/Data_Type.ipp +18 -0
- data/rice/Data_Type_defn.hpp +1 -1
- data/rice/Enum.hpp +1 -1
- data/rice/Enum.ipp +3 -3
- data/rice/Hash.ipp +2 -0
- data/rice/Makefile.am +2 -0
- data/rice/Makefile.in +26 -10
- data/rice/Module.cpp +3 -2
- data/rice/Module_defn.hpp +2 -1
- data/rice/String.cpp +1 -0
- data/rice/String.hpp +2 -1
- data/rice/detail/default_allocation_func.ipp +2 -2
- data/rice/detail/demangle.cpp +56 -0
- data/rice/detail/demangle.hpp +19 -0
- data/rice/detail/env.hpp +15 -13
- data/rice/detail/from_ruby.ipp +12 -26
- data/rice/detail/ruby.hpp +12 -2
- data/rice/detail/to_ruby.hpp +7 -1
- data/rice/detail/to_ruby.ipp +34 -7
- data/ruby/Makefile.in +8 -9
- data/ruby/lib/Makefile.in +2 -2
- data/ruby/lib/mkmf-rice.rb.in +7 -0
- data/ruby.ac +4 -2
- data/sample/Makefile.in +2 -2
- data/test/Makefile.in +9 -10
- data/test/test_Class.cpp +23 -0
- data/test/test_Constructor.cpp +33 -0
- data/test/test_Module.cpp +1 -1
- metadata +43 -34
@@ -0,0 +1,56 @@
|
|
1
|
+
#include "demangle.hpp"
|
2
|
+
|
3
|
+
#ifdef __GNUC__
|
4
|
+
#include <cxxabi.h>
|
5
|
+
#include <cstdlib>
|
6
|
+
#include <cstring>
|
7
|
+
#endif
|
8
|
+
|
9
|
+
std::string
|
10
|
+
Rice::detail::
|
11
|
+
demangle(char const * mangled_name)
|
12
|
+
{
|
13
|
+
#ifdef __GNUC__
|
14
|
+
struct Helper
|
15
|
+
{
|
16
|
+
Helper(
|
17
|
+
char const * mangled_name)
|
18
|
+
: name_(0)
|
19
|
+
{
|
20
|
+
int status = 0;
|
21
|
+
name_ = abi::__cxa_demangle(mangled_name, 0, 0, &status);
|
22
|
+
}
|
23
|
+
|
24
|
+
~Helper()
|
25
|
+
{
|
26
|
+
std::free(name_);
|
27
|
+
}
|
28
|
+
|
29
|
+
char * name_;
|
30
|
+
|
31
|
+
private:
|
32
|
+
Helper(Helper const &);
|
33
|
+
void operator=(Helper const &);
|
34
|
+
};
|
35
|
+
|
36
|
+
Helper helper(mangled_name);
|
37
|
+
if(helper.name_)
|
38
|
+
{
|
39
|
+
return helper.name_;
|
40
|
+
}
|
41
|
+
else
|
42
|
+
{
|
43
|
+
return mangled_name;
|
44
|
+
}
|
45
|
+
#else
|
46
|
+
return mangled_name;
|
47
|
+
#endif
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
std::string
|
52
|
+
Rice::detail::
|
53
|
+
demangle(std::string const & mangled_name)
|
54
|
+
{
|
55
|
+
return demangle(mangled_name.c_str());
|
56
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#ifndef Rice__detail__demangle__hpp_
|
2
|
+
#define Rice__detail__demangle__hpp_
|
3
|
+
|
4
|
+
#include <string>
|
5
|
+
|
6
|
+
namespace Rice
|
7
|
+
{
|
8
|
+
|
9
|
+
namespace detail
|
10
|
+
{
|
11
|
+
|
12
|
+
std::string demangle(char const * mangled_name);
|
13
|
+
std::string demangle(std::string const & mangled_name);
|
14
|
+
|
15
|
+
} // detail
|
16
|
+
|
17
|
+
} // Rice
|
18
|
+
|
19
|
+
#endif // Rice__detail__demangle__hpp_
|
data/rice/detail/env.hpp
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
#ifndef Rice__detail__env__hpp_
|
2
|
-
#define Rice__detail__env__hpp_
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Helper header for the env.h ruby include file, which does
|
6
|
-
* not have extern "C"
|
7
|
-
*/
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
#ifndef Rice__detail__env__hpp_
|
2
|
+
#define Rice__detail__env__hpp_
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Helper header for the env.h ruby include file, which does
|
6
|
+
* not have extern "C"
|
7
|
+
*/
|
8
|
+
|
9
|
+
// TODO: Won't work on ruby 1.9
|
10
|
+
|
11
|
+
extern "C" {
|
12
|
+
#include "env.h"
|
13
|
+
}
|
14
|
+
|
15
|
+
#endif
|
data/rice/detail/from_ruby.ipp
CHANGED
@@ -2,28 +2,10 @@
|
|
2
2
|
#define Rice__detail__from_ruby__ipp_
|
3
3
|
|
4
4
|
#include "../Data_Type.hpp"
|
5
|
+
#include "../String.hpp"
|
6
|
+
#include "demangle.hpp"
|
5
7
|
#include <typeinfo>
|
6
8
|
|
7
|
-
#if 0
|
8
|
-
namespace Rice
|
9
|
-
{
|
10
|
-
namespace detail
|
11
|
-
{
|
12
|
-
template<typename T>
|
13
|
-
struct unpointer
|
14
|
-
{
|
15
|
-
// can't unpointer a non-pointer
|
16
|
-
};
|
17
|
-
|
18
|
-
template<typename T>
|
19
|
-
struct unpointer<T *>
|
20
|
-
{
|
21
|
-
typedef T type;
|
22
|
-
};
|
23
|
-
}
|
24
|
-
}
|
25
|
-
#endif
|
26
|
-
|
27
9
|
template<typename T>
|
28
10
|
T Rice::detail::from_ruby_<T>::
|
29
11
|
convert(Rice::Object x)
|
@@ -34,9 +16,11 @@ convert(Rice::Object x)
|
|
34
16
|
}
|
35
17
|
else
|
36
18
|
{
|
37
|
-
std::string s("
|
38
|
-
s +=
|
39
|
-
|
19
|
+
std::string s("Unable to convert ");
|
20
|
+
s += x.class_of().name().c_str();
|
21
|
+
s += " to ";
|
22
|
+
s += demangle(typeid(T).name());
|
23
|
+
throw std::invalid_argument(s.c_str());
|
40
24
|
}
|
41
25
|
}
|
42
26
|
|
@@ -50,9 +34,11 @@ convert(Rice::Object x)
|
|
50
34
|
}
|
51
35
|
else
|
52
36
|
{
|
53
|
-
std::string s("
|
54
|
-
s +=
|
55
|
-
|
37
|
+
std::string s("Unable to convert ");
|
38
|
+
s += x.class_of().name().c_str();
|
39
|
+
s += " to ";
|
40
|
+
s += demangle(typeid(T *).name());
|
41
|
+
throw std::invalid_argument(s.c_str());
|
56
42
|
}
|
57
43
|
}
|
58
44
|
|
data/rice/detail/ruby.hpp
CHANGED
@@ -14,11 +14,21 @@
|
|
14
14
|
#define HAVE_ISINF
|
15
15
|
#endif
|
16
16
|
|
17
|
-
#include <ruby.h>
|
18
|
-
|
19
17
|
// TODO: Is there a way to ensure that this is Ruby's version.h?
|
18
|
+
#define RUBY_EXTERN extern "C"
|
20
19
|
#include <version.h>
|
21
20
|
|
21
|
+
// workaround for ruby 1.8.4, which defines eaccess and shouldn't
|
22
|
+
#if RUBY_VERSION_CODE <= 184
|
23
|
+
#define eaccess ruby_eaccess
|
24
|
+
#endif
|
25
|
+
|
26
|
+
#include <ruby.h>
|
27
|
+
|
28
|
+
#if RUBY_VERSION_CODE <= 184
|
29
|
+
#undef eaccess
|
30
|
+
#endif
|
31
|
+
|
22
32
|
#ifdef WIN32
|
23
33
|
#include "win32.hpp"
|
24
34
|
#endif
|
data/rice/detail/to_ruby.hpp
CHANGED
@@ -8,7 +8,13 @@ namespace Rice
|
|
8
8
|
template<typename T>
|
9
9
|
struct to_ruby_
|
10
10
|
{
|
11
|
-
static Rice::Object convert(T
|
11
|
+
static Rice::Object convert(T & x);
|
12
|
+
};
|
13
|
+
|
14
|
+
template<typename T>
|
15
|
+
struct to_ruby_<T *>
|
16
|
+
{
|
17
|
+
static Rice::Object convert(T * x);
|
12
18
|
};
|
13
19
|
} // detail
|
14
20
|
} // Rice
|
data/rice/detail/to_ruby.ipp
CHANGED
@@ -1,10 +1,37 @@
|
|
1
|
+
#include "../Data_Object.hpp"
|
2
|
+
|
1
3
|
template<typename T>
|
2
|
-
Rice::Object
|
3
|
-
|
4
|
+
Rice::Object
|
5
|
+
Rice::detail::to_ruby_<T>::
|
6
|
+
convert(T & x)
|
4
7
|
{
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}
|
8
|
+
if(Data_Type<T>::is_bound())
|
9
|
+
{
|
10
|
+
Data_Object<T> obj(&x);
|
11
|
+
return obj;
|
12
|
+
}
|
13
|
+
else
|
14
|
+
{
|
15
|
+
std::string s("Unable to convert ");
|
16
|
+
s += demangle(typeid(T *).name());
|
17
|
+
throw std::invalid_argument(s.c_str());
|
18
|
+
}
|
19
|
+
}
|
10
20
|
|
21
|
+
template<typename T>
|
22
|
+
Rice::Object
|
23
|
+
Rice::detail::to_ruby_<T *>::
|
24
|
+
convert(T * x)
|
25
|
+
{
|
26
|
+
if(Data_Type<T>::is_bound())
|
27
|
+
{
|
28
|
+
Data_Object<T> obj(x);
|
29
|
+
return obj;
|
30
|
+
}
|
31
|
+
else
|
32
|
+
{
|
33
|
+
std::string s("Unable to convert ");
|
34
|
+
s += demangle(typeid(T *).name());
|
35
|
+
throw std::invalid_argument(s.c_str());
|
36
|
+
}
|
37
|
+
}
|
data/ruby/Makefile.in
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Makefile.in generated by automake 1.10 from Makefile.am.
|
1
|
+
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
2
2
|
# @configure_input@
|
3
3
|
|
4
4
|
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
5
|
-
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
5
|
+
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
6
6
|
# This Makefile.in is free software; the Free Software Foundation
|
7
7
|
# gives unlimited permission to copy and/or distribute it,
|
8
8
|
# with or without modifications, as long as this notice is preserved.
|
@@ -292,8 +292,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
|
292
292
|
unique=`for i in $$list; do \
|
293
293
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
294
294
|
done | \
|
295
|
-
$(AWK) '
|
296
|
-
|
295
|
+
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
|
296
|
+
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
297
297
|
mkid -fID $$unique
|
298
298
|
tags: TAGS
|
299
299
|
|
@@ -318,8 +318,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
|
318
318
|
unique=`for i in $$list; do \
|
319
319
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
320
320
|
done | \
|
321
|
-
$(AWK) '
|
322
|
-
|
321
|
+
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
322
|
+
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
323
323
|
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
324
324
|
test -n "$$unique" || unique=$$empty_fix; \
|
325
325
|
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
@@ -329,13 +329,12 @@ ctags: CTAGS
|
|
329
329
|
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
330
330
|
$(TAGS_FILES) $(LISP)
|
331
331
|
tags=; \
|
332
|
-
here=`pwd`; \
|
333
332
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
334
333
|
unique=`for i in $$list; do \
|
335
334
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
336
335
|
done | \
|
337
|
-
$(AWK) '
|
338
|
-
|
336
|
+
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
337
|
+
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
339
338
|
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
340
339
|
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
341
340
|
$$tags $$unique
|
data/ruby/lib/Makefile.in
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Makefile.in generated by automake 1.10 from Makefile.am.
|
1
|
+
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
2
2
|
# @configure_input@
|
3
3
|
|
4
4
|
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
5
|
-
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
5
|
+
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
6
6
|
# This Makefile.in is free software; the Free Software Foundation
|
7
7
|
# gives unlimited permission to copy and/or distribute it,
|
8
8
|
# with or without modifications, as long as this notice is preserved.
|
data/ruby/lib/mkmf-rice.rb.in
CHANGED
@@ -31,6 +31,9 @@ def init_mkmf_rice(config = CONFIG)
|
|
31
31
|
# Ruby < 1.8.6 does not have $DEFLIBPATH
|
32
32
|
$DEFLIBPATH ||= []
|
33
33
|
|
34
|
+
# Ruby 1.8.6 uses $preload without setting it
|
35
|
+
$preload ||= nil
|
36
|
+
|
34
37
|
$CPPFLAGS << " #{$RICE_CPPFLAGS} -I#{$RICE_PREFIX}/include"
|
35
38
|
$LDFLAGS << " #{$RICE_LDFLAGS} -L#{$RICE_PREFIX}/lib"
|
36
39
|
|
@@ -176,6 +179,10 @@ class RiceMakefileCreator
|
|
176
179
|
@file.printf(format, *args)
|
177
180
|
end
|
178
181
|
|
182
|
+
def puts(*strings)
|
183
|
+
print strings.map { |s| "#{s}\n" }
|
184
|
+
end
|
185
|
+
|
179
186
|
def close
|
180
187
|
@file.close
|
181
188
|
end
|
data/ruby.ac
CHANGED
@@ -29,14 +29,15 @@ RUBY_CONFIG_DLDLIBS=`RUBY_CONFIG(DLDLIBS)`
|
|
29
29
|
RUBY_CONFIG_LDFLAGS=`RUBY_CONFIG(LDFLAGS)`
|
30
30
|
RUBY_CONFIG_LIBRUBYARG=`RUBY_CONFIG(LIBRUBYARG)`
|
31
31
|
RUBY_CONFIG_LIBRUBYARG_STATIC=`RUBY_CONFIG(LIBRUBYARG_STATIC)`
|
32
|
+
RUBY_CONFIG_CCDLFLAGS=`RUBY_CONFIG(CCDLFLAGS)`
|
32
33
|
|
33
34
|
RUBY_CPPFLAGS="-I${RUBY_CONFIG_ARCHDIR}"
|
34
35
|
AC_SUBST(RUBY_CPPFLAGS)
|
35
36
|
|
36
|
-
RUBY_CFLAGS="${RUBY_CONFIG_CFLAGS}"
|
37
|
+
RUBY_CFLAGS="${RUBY_CONFIG_CFLAGS} ${RUBY_CONFIG_CCDLFLAGS}"
|
37
38
|
AC_SUBST(RUBY_CFLAGS)
|
38
39
|
|
39
|
-
RUBY_CXXFLAGS="${RUBY_CONFIG_CFLAGS}"
|
40
|
+
RUBY_CXXFLAGS="${RUBY_CONFIG_CFLAGS} ${RUBY_CONFIG_CCDLFLAGS}"
|
40
41
|
AC_SUBST(RUBY_CXXFLAGS)
|
41
42
|
|
42
43
|
RUBY_LDFLAGS="-L${RUBY_ARCHDIR} -L${RUBY_CONFIG_LIBDIR} ${RUBY_LDFLAGS}"
|
@@ -73,6 +74,7 @@ dnl The fourth parameter to AC_CHECK_HEADER keeps autoconf from
|
|
73
74
|
dnl searching for standard header files as a side-effect (which we want)
|
74
75
|
CPPFLAGS_save="${CPPFLAGS}"
|
75
76
|
CPPFLAGS="${CPPFLAGS} ${RUBY_CPPFLAGS}"
|
77
|
+
CXXFLAGS="${CPPFLAGS}"
|
76
78
|
AC_CHECK_HEADER(ruby.h,,AC_MSG_ERROR(
|
77
79
|
could not find ruby.h (check config.log)),[ ])
|
78
80
|
AC_CHECK_HEADER(node.h,,AC_MSG_ERROR(
|
data/sample/Makefile.in
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Makefile.in generated by automake 1.10 from Makefile.am.
|
1
|
+
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
2
2
|
# @configure_input@
|
3
3
|
|
4
4
|
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
5
|
-
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
5
|
+
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
6
6
|
# This Makefile.in is free software; the Free Software Foundation
|
7
7
|
# gives unlimited permission to copy and/or distribute it,
|
8
8
|
# with or without modifications, as long as this notice is preserved.
|
data/test/Makefile.in
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Makefile.in generated by automake 1.10 from Makefile.am.
|
1
|
+
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
2
2
|
# @configure_input@
|
3
3
|
|
4
4
|
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
5
|
-
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
5
|
+
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
6
6
|
# This Makefile.in is free software; the Free Software Foundation
|
7
7
|
# gives unlimited permission to copy and/or distribute it,
|
8
8
|
# with or without modifications, as long as this notice is preserved.
|
@@ -61,7 +61,7 @@ unittest_LDADD = $(LDADD)
|
|
61
61
|
am_vm_unittest_OBJECTS = unittest.$(OBJEXT) test_VM.$(OBJEXT)
|
62
62
|
vm_unittest_OBJECTS = $(am_vm_unittest_OBJECTS)
|
63
63
|
vm_unittest_LDADD = $(LDADD)
|
64
|
-
DEFAULT_INCLUDES = -I
|
64
|
+
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/rice
|
65
65
|
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
66
66
|
am__depfiles_maybe = depfiles
|
67
67
|
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
@@ -332,8 +332,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
|
332
332
|
unique=`for i in $$list; do \
|
333
333
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
334
334
|
done | \
|
335
|
-
$(AWK) '
|
336
|
-
|
335
|
+
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
|
336
|
+
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
337
337
|
mkid -fID $$unique
|
338
338
|
tags: TAGS
|
339
339
|
|
@@ -345,8 +345,8 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
|
345
345
|
unique=`for i in $$list; do \
|
346
346
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
347
347
|
done | \
|
348
|
-
$(AWK) '
|
349
|
-
|
348
|
+
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
349
|
+
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
350
350
|
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
351
351
|
test -n "$$unique" || unique=$$empty_fix; \
|
352
352
|
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
@@ -356,13 +356,12 @@ ctags: CTAGS
|
|
356
356
|
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
357
357
|
$(TAGS_FILES) $(LISP)
|
358
358
|
tags=; \
|
359
|
-
here=`pwd`; \
|
360
359
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
361
360
|
unique=`for i in $$list; do \
|
362
361
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
363
362
|
done | \
|
364
|
-
$(AWK) '
|
365
|
-
|
363
|
+
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
364
|
+
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
366
365
|
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
367
366
|
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
368
367
|
$$tags $$unique
|
data/test/test_Class.cpp
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#include "unittest.hpp"
|
2
2
|
#include "rice/Class.hpp"
|
3
|
+
#include "rice/Constructor.hpp"
|
3
4
|
#include "rice/protect.hpp"
|
4
5
|
#include "rice/Exception.hpp"
|
5
6
|
#include "rice/Array.hpp"
|
@@ -348,3 +349,25 @@ TESTCASE(module_define_class)
|
|
348
349
|
ASSERT_EQUAL(c, math.const_get("Foo"));
|
349
350
|
ASSERT(!object.const_defined("Foo"));
|
350
351
|
}
|
352
|
+
|
353
|
+
namespace {
|
354
|
+
class BaseClass {
|
355
|
+
public:
|
356
|
+
BaseClass() { }
|
357
|
+
};
|
358
|
+
}
|
359
|
+
|
360
|
+
TESTCASE(subclassing)
|
361
|
+
{
|
362
|
+
Module m = define_module("Testing");
|
363
|
+
define_class_under<BaseClass>(m, "BaseClass").
|
364
|
+
define_constructor(Constructor<BaseClass>());
|
365
|
+
|
366
|
+
// Not sure how to make this a true failure case. If the subclassing
|
367
|
+
// doesn't work, Ruby will throw an error:
|
368
|
+
//
|
369
|
+
// in `new': wrong instance allocation
|
370
|
+
//
|
371
|
+
m.instance_eval("class NewClass < Testing::BaseClass; end;");
|
372
|
+
m.instance_eval("n = NewClass.new");
|
373
|
+
}
|
data/test/test_Constructor.cpp
CHANGED
@@ -28,3 +28,36 @@ TESTCASE(default_constructor)
|
|
28
28
|
ASSERT_EQUAL(rb_cDefault_Constructible, o.class_of());
|
29
29
|
}
|
30
30
|
|
31
|
+
|
32
|
+
namespace
|
33
|
+
{
|
34
|
+
class Non_Default_Constructible
|
35
|
+
{
|
36
|
+
public:
|
37
|
+
Non_Default_Constructible(int i)
|
38
|
+
: i_(i)
|
39
|
+
{
|
40
|
+
}
|
41
|
+
|
42
|
+
int i() const
|
43
|
+
{
|
44
|
+
return i_;
|
45
|
+
}
|
46
|
+
|
47
|
+
private:
|
48
|
+
int i_;
|
49
|
+
};
|
50
|
+
}
|
51
|
+
|
52
|
+
TESTCASE(non_default_constructor)
|
53
|
+
{
|
54
|
+
Data_Type<Non_Default_Constructible> rb_cNon_Default_Constructible(
|
55
|
+
anonymous_class());
|
56
|
+
rb_cNon_Default_Constructible
|
57
|
+
.define_constructor(Constructor<Non_Default_Constructible, int>());
|
58
|
+
Data_Object<Non_Default_Constructible> o =
|
59
|
+
rb_cNon_Default_Constructible.call("new", 42);
|
60
|
+
ASSERT_EQUAL(rb_cNon_Default_Constructible, o.class_of());
|
61
|
+
ASSERT_EQUAL(42, o->i());
|
62
|
+
}
|
63
|
+
|
data/test/test_Module.cpp
CHANGED
metadata
CHANGED
@@ -1,33 +1,26 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: rice
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2008-02-18 00:00:00 -05:00
|
8
|
-
summary: Ruby Interface for C++ Extensions
|
9
|
-
require_paths:
|
10
|
-
- ruby/lib
|
11
|
-
email: curlypaul924@gmail.com
|
12
|
-
homepage: http://rice.rubyforge.org/
|
13
|
-
rubyforge_project: rice
|
14
|
-
description: Rice is a C++ interface to Ruby's C API. It provides a type-safe and exception-safe interface in order to make embedding Ruby and writing Ruby extensions with C++ easier. It is similar to Boost.Python in many ways, but also attempts to provide an object-oriented interface to all of the Ruby C API.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: false
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 1.0.2
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Paul Brannan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-07-22 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Rice is a C++ interface to Ruby's C API. It provides a type-safe and exception-safe interface in order to make embedding Ruby and writing Ruby extensions with C++ easier. It is similar to Boost.Python in many ways, but also attempts to provide an object-oriented interface to all of the Ruby C API.
|
17
|
+
email: curlypaul924@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- configure
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
31
24
|
files:
|
32
25
|
- COPYING
|
33
26
|
- README
|
@@ -158,6 +151,8 @@ files:
|
|
158
151
|
- rice/detail/Auto_Member_Function_Wrapper.ipp
|
159
152
|
- rice/detail/st.hpp
|
160
153
|
- rice/detail/Wrapped_Function.hpp
|
154
|
+
- rice/detail/demangle.cpp
|
155
|
+
- rice/detail/demangle.hpp
|
161
156
|
- rice/detail/Auto_Function_Wrapper.hpp
|
162
157
|
- rice/detail/Auto_Function_Wrapper.ipp
|
163
158
|
- rice/detail/node.hpp
|
@@ -195,17 +190,31 @@ files:
|
|
195
190
|
- test/test_Exception.cpp
|
196
191
|
- test/test_Struct.cpp
|
197
192
|
- test/test_Address_Registration_Guard.cpp
|
198
|
-
|
199
|
-
|
193
|
+
has_rdoc: false
|
194
|
+
homepage: http://rice.rubyforge.org/
|
195
|
+
post_install_message:
|
200
196
|
rdoc_options: []
|
201
197
|
|
202
|
-
|
203
|
-
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
-
|
198
|
+
require_paths:
|
199
|
+
- ruby/lib
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: "0"
|
205
|
+
version:
|
206
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: "0"
|
211
|
+
version:
|
208
212
|
requirements: []
|
209
213
|
|
210
|
-
|
211
|
-
|
214
|
+
rubyforge_project: rice
|
215
|
+
rubygems_version: 1.2.0
|
216
|
+
signing_key:
|
217
|
+
specification_version: 2
|
218
|
+
summary: Ruby Interface for C++ Extensions
|
219
|
+
test_files:
|
220
|
+
- test/test_rice.rb
|