rice2 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +23 -0
- data/Doxyfile +2268 -0
- data/Makefile.am +26 -0
- data/Makefile.in +929 -0
- data/README.md +1054 -0
- data/README.mingw +8 -0
- data/Rakefile +24 -0
- data/aclocal.m4 +1090 -0
- data/bootstrap +8 -0
- data/config.guess +1667 -0
- data/config.sub +1793 -0
- data/configure +8209 -0
- data/configure.ac +55 -0
- data/depcomp +791 -0
- data/doxygen.ac +314 -0
- data/doxygen.am +186 -0
- data/extconf.rb +66 -0
- data/install-sh +529 -0
- data/missing +215 -0
- data/post-autoconf.rb +22 -0
- data/post-automake.rb +28 -0
- data/rice/Address_Registration_Guard.cpp +22 -0
- data/rice/Address_Registration_Guard.hpp +7 -0
- data/rice/Address_Registration_Guard.ipp +37 -0
- data/rice/Address_Registration_Guard_defn.hpp +75 -0
- data/rice/Arg.hpp +8 -0
- data/rice/Arg_impl.hpp +129 -0
- data/rice/Arg_operators.cpp +21 -0
- data/rice/Arg_operators.hpp +19 -0
- data/rice/Array.hpp +214 -0
- data/rice/Array.ipp +256 -0
- data/rice/Builtin_Object.hpp +8 -0
- data/rice/Builtin_Object.ipp +50 -0
- data/rice/Builtin_Object_defn.hpp +50 -0
- data/rice/Class.cpp +57 -0
- data/rice/Class.hpp +8 -0
- data/rice/Class.ipp +6 -0
- data/rice/Class_defn.hpp +83 -0
- data/rice/Constructor.hpp +47 -0
- data/rice/Data_Object.hpp +8 -0
- data/rice/Data_Object.ipp +133 -0
- data/rice/Data_Object_defn.hpp +138 -0
- data/rice/Data_Type.cpp +54 -0
- data/rice/Data_Type.hpp +8 -0
- data/rice/Data_Type.ipp +365 -0
- data/rice/Data_Type_defn.hpp +261 -0
- data/rice/Data_Type_fwd.hpp +12 -0
- data/rice/Director.cpp +13 -0
- data/rice/Director.hpp +39 -0
- data/rice/Enum.hpp +117 -0
- data/rice/Enum.ipp +246 -0
- data/rice/Exception.cpp +59 -0
- data/rice/Exception.hpp +13 -0
- data/rice/Exception_Base.hpp +8 -0
- data/rice/Exception_Base.ipp +13 -0
- data/rice/Exception_Base_defn.hpp +27 -0
- data/rice/Exception_defn.hpp +69 -0
- data/rice/Hash.hpp +227 -0
- data/rice/Hash.ipp +329 -0
- data/rice/Identifier.cpp +8 -0
- data/rice/Identifier.hpp +50 -0
- data/rice/Identifier.ipp +33 -0
- data/rice/Jump_Tag.hpp +24 -0
- data/rice/Makefile.am +122 -0
- data/rice/Makefile.in +885 -0
- data/rice/Module.cpp +84 -0
- data/rice/Module.hpp +8 -0
- data/rice/Module.ipp +6 -0
- data/rice/Module_defn.hpp +88 -0
- data/rice/Module_impl.hpp +281 -0
- data/rice/Module_impl.ipp +345 -0
- data/rice/Object.cpp +169 -0
- data/rice/Object.hpp +8 -0
- data/rice/Object.ipp +33 -0
- data/rice/Object_defn.hpp +214 -0
- data/rice/Require_Guard.hpp +21 -0
- data/rice/String.cpp +94 -0
- data/rice/String.hpp +91 -0
- data/rice/Struct.cpp +117 -0
- data/rice/Struct.hpp +162 -0
- data/rice/Struct.ipp +26 -0
- data/rice/Symbol.cpp +25 -0
- data/rice/Symbol.hpp +66 -0
- data/rice/Symbol.ipp +44 -0
- data/rice/config.hpp +47 -0
- data/rice/config.hpp.in +46 -0
- data/rice/detail/Arguments.hpp +118 -0
- data/rice/detail/Auto_Function_Wrapper.hpp +898 -0
- data/rice/detail/Auto_Function_Wrapper.ipp +3694 -0
- data/rice/detail/Auto_Member_Function_Wrapper.hpp +897 -0
- data/rice/detail/Auto_Member_Function_Wrapper.ipp +2774 -0
- data/rice/detail/Caster.hpp +103 -0
- data/rice/detail/Exception_Handler.hpp +8 -0
- data/rice/detail/Exception_Handler.ipp +68 -0
- data/rice/detail/Exception_Handler_defn.hpp +96 -0
- data/rice/detail/Iterator.hpp +93 -0
- data/rice/detail/Not_Copyable.hpp +25 -0
- data/rice/detail/Wrapped_Function.hpp +33 -0
- data/rice/detail/cfp.hpp +24 -0
- data/rice/detail/cfp.ipp +51 -0
- data/rice/detail/check_ruby_type.cpp +27 -0
- data/rice/detail/check_ruby_type.hpp +23 -0
- data/rice/detail/creation_funcs.hpp +37 -0
- data/rice/detail/creation_funcs.ipp +36 -0
- data/rice/detail/default_allocation_func.hpp +23 -0
- data/rice/detail/default_allocation_func.ipp +11 -0
- data/rice/detail/define_method_and_auto_wrap.hpp +31 -0
- data/rice/detail/define_method_and_auto_wrap.ipp +30 -0
- data/rice/detail/demangle.cpp +56 -0
- data/rice/detail/demangle.hpp +19 -0
- data/rice/detail/env.hpp +11 -0
- data/rice/detail/from_ruby.hpp +43 -0
- data/rice/detail/from_ruby.ipp +60 -0
- data/rice/detail/method_data.cpp +92 -0
- data/rice/detail/method_data.hpp +21 -0
- data/rice/detail/node.hpp +13 -0
- data/rice/detail/protect.cpp +29 -0
- data/rice/detail/protect.hpp +34 -0
- data/rice/detail/ruby.hpp +74 -0
- data/rice/detail/ruby_version_code.hpp +6 -0
- data/rice/detail/ruby_version_code.hpp.in +6 -0
- data/rice/detail/st.hpp +22 -0
- data/rice/detail/to_ruby.hpp +22 -0
- data/rice/detail/to_ruby.ipp +36 -0
- data/rice/detail/traits.hpp +43 -0
- data/rice/detail/win32.hpp +16 -0
- data/rice/detail/wrap_function.hpp +66 -0
- data/rice/global_function.hpp +33 -0
- data/rice/global_function.ipp +22 -0
- data/rice/protect.hpp +38 -0
- data/rice/protect.ipp +1134 -0
- data/rice/ruby_mark.hpp +13 -0
- data/rice/ruby_try_catch.hpp +86 -0
- data/rice/rubypp.rb +97 -0
- data/rice/to_from_ruby.hpp +8 -0
- data/rice/to_from_ruby.ipp +418 -0
- data/rice/to_from_ruby_defn.hpp +70 -0
- data/ruby.ac +135 -0
- data/ruby/Makefile.am +1 -0
- data/ruby/Makefile.in +628 -0
- data/ruby/lib/Makefile.am +3 -0
- data/ruby/lib/Makefile.in +506 -0
- data/ruby/lib/mkmf-rice.rb.in +217 -0
- data/ruby/lib/version.rb +3 -0
- data/sample/Makefile.am +47 -0
- data/sample/Makefile.in +489 -0
- data/sample/enum/extconf.rb +3 -0
- data/sample/enum/sample_enum.cpp +54 -0
- data/sample/enum/test.rb +8 -0
- data/sample/inheritance/animals.cpp +98 -0
- data/sample/inheritance/extconf.rb +3 -0
- data/sample/inheritance/test.rb +7 -0
- data/sample/map/extconf.rb +3 -0
- data/sample/map/map.cpp +81 -0
- data/sample/map/test.rb +7 -0
- data/test/Makefile.am +72 -0
- data/test/Makefile.in +1213 -0
- data/test/ext/Makefile.am +41 -0
- data/test/ext/Makefile.in +483 -0
- data/test/ext/t1/Foo.hpp +10 -0
- data/test/ext/t1/extconf.rb +2 -0
- data/test/ext/t1/t1.cpp +15 -0
- data/test/ext/t2/extconf.rb +2 -0
- data/test/ext/t2/t2.cpp +11 -0
- data/test/test_Address_Registration_Guard.cpp +43 -0
- data/test/test_Array.cpp +248 -0
- data/test/test_Builtin_Object.cpp +71 -0
- data/test/test_Class.cpp +496 -0
- data/test/test_Constructor.cpp +128 -0
- data/test/test_Data_Object.cpp +275 -0
- data/test/test_Data_Type.cpp +348 -0
- data/test/test_Director.cpp +308 -0
- data/test/test_Enum.cpp +215 -0
- data/test/test_Exception.cpp +47 -0
- data/test/test_Hash.cpp +212 -0
- data/test/test_Identifier.cpp +70 -0
- data/test/test_Jump_Tag.cpp +17 -0
- data/test/test_Memory_Management.cpp +50 -0
- data/test/test_Module.cpp +497 -0
- data/test/test_Object.cpp +159 -0
- data/test/test_String.cpp +107 -0
- data/test/test_Struct.cpp +205 -0
- data/test/test_Symbol.cpp +63 -0
- data/test/test_To_From_Ruby.cpp +428 -0
- data/test/test_global_functions.cpp +114 -0
- data/test/test_rice.rb +41 -0
- data/test/unittest.cpp +136 -0
- data/test/unittest.hpp +294 -0
- metadata +297 -0
data/rice/Struct.cpp
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
#include "Struct.hpp"
|
2
|
+
#include "Symbol.hpp"
|
3
|
+
|
4
|
+
#include <stdexcept>
|
5
|
+
|
6
|
+
Rice::Struct::
|
7
|
+
Struct()
|
8
|
+
: Module_impl<Class, Struct>(rb_cObject)
|
9
|
+
, members_()
|
10
|
+
, members_guard_(&members_)
|
11
|
+
, member_offset_()
|
12
|
+
, member_offset_guard_(&member_offset_)
|
13
|
+
{
|
14
|
+
}
|
15
|
+
|
16
|
+
Rice::Struct::
|
17
|
+
Struct(Rice::Struct const & s)
|
18
|
+
: Module_impl<Class, Struct>(s)
|
19
|
+
, members_(s.members_.value())
|
20
|
+
, members_guard_(&members_)
|
21
|
+
, member_offset_(s.member_offset_.value())
|
22
|
+
, member_offset_guard_(&member_offset_)
|
23
|
+
{
|
24
|
+
}
|
25
|
+
|
26
|
+
Rice::Struct::
|
27
|
+
~Struct()
|
28
|
+
{
|
29
|
+
}
|
30
|
+
|
31
|
+
Rice::Struct & Rice::Struct::
|
32
|
+
initialize(
|
33
|
+
Module module,
|
34
|
+
Identifier name)
|
35
|
+
{
|
36
|
+
Class struct_class(rb_cStruct);
|
37
|
+
Object type = struct_class.vcall("new", members_);
|
38
|
+
|
39
|
+
set_value(type);
|
40
|
+
module.const_set(name, type);
|
41
|
+
|
42
|
+
return *this;
|
43
|
+
}
|
44
|
+
|
45
|
+
Rice::Struct & Rice::Struct::
|
46
|
+
define_member(
|
47
|
+
Identifier name)
|
48
|
+
{
|
49
|
+
if(value() != rb_cObject)
|
50
|
+
{
|
51
|
+
throw std::runtime_error("struct is already initialized");
|
52
|
+
}
|
53
|
+
|
54
|
+
// TODO: not exception-safe
|
55
|
+
Symbol ruby_name(name);
|
56
|
+
member_offset_[ruby_name] = members_.size();
|
57
|
+
members_.push(ruby_name);
|
58
|
+
|
59
|
+
return *this;
|
60
|
+
}
|
61
|
+
|
62
|
+
size_t Rice::Struct::
|
63
|
+
offset_of(Identifier name) const
|
64
|
+
{
|
65
|
+
Symbol ruby_name(name);
|
66
|
+
return from_ruby<size_t>(member_offset_[ruby_name]);
|
67
|
+
}
|
68
|
+
|
69
|
+
void Rice::Struct::
|
70
|
+
swap(Rice::Struct & other)
|
71
|
+
{
|
72
|
+
members_.swap(other.members_);
|
73
|
+
members_guard_.swap(other.members_guard_);
|
74
|
+
member_offset_.swap(other.member_offset_);
|
75
|
+
member_offset_guard_.swap(other.member_offset_guard_);
|
76
|
+
Class::swap(other);
|
77
|
+
}
|
78
|
+
|
79
|
+
Rice::Struct::Instance
|
80
|
+
Rice::Struct::
|
81
|
+
new_instance(Array args) const
|
82
|
+
{
|
83
|
+
Object instance = const_cast<Struct *>(this)->vcall("new", args);
|
84
|
+
return Instance(*this, instance);
|
85
|
+
}
|
86
|
+
|
87
|
+
Rice::Struct::Instance::
|
88
|
+
Instance(
|
89
|
+
Struct const & type,
|
90
|
+
Array args)
|
91
|
+
: Builtin_Object<T_STRUCT>(type.new_instance(args))
|
92
|
+
, type_(type)
|
93
|
+
{
|
94
|
+
}
|
95
|
+
|
96
|
+
Rice::Struct::Instance::
|
97
|
+
Instance(
|
98
|
+
Struct const & type,
|
99
|
+
Object s)
|
100
|
+
: Builtin_Object<T_STRUCT>(s)
|
101
|
+
, type_(type)
|
102
|
+
{
|
103
|
+
}
|
104
|
+
|
105
|
+
void Rice::Struct::Instance::
|
106
|
+
swap(Instance & other)
|
107
|
+
{
|
108
|
+
type_.swap(other.type_);
|
109
|
+
Builtin_Object<T_STRUCT>::swap(other);
|
110
|
+
}
|
111
|
+
|
112
|
+
Rice::Struct Rice::
|
113
|
+
define_struct()
|
114
|
+
{
|
115
|
+
return Struct();
|
116
|
+
}
|
117
|
+
|
data/rice/Struct.hpp
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
#ifndef Rice__ruby_struct__hpp_
|
2
|
+
#define Rice__ruby_struct__hpp_
|
3
|
+
|
4
|
+
#include "Array.hpp"
|
5
|
+
#include "Hash.hpp"
|
6
|
+
#include "Module.hpp"
|
7
|
+
#include "Class.hpp"
|
8
|
+
#include "Builtin_Object.hpp"
|
9
|
+
#include "Address_Registration_Guard.hpp"
|
10
|
+
|
11
|
+
namespace Rice
|
12
|
+
{
|
13
|
+
class Struct;
|
14
|
+
|
15
|
+
//! Define a new Struct
|
16
|
+
Struct define_struct();
|
17
|
+
|
18
|
+
//! A wrapper for creating Struct classes.
|
19
|
+
/*! The Struct class is used for creating new Classes. Note that the
|
20
|
+
* notation used here differs slightly from the notation inside the
|
21
|
+
* interpreter.
|
22
|
+
*
|
23
|
+
* Inside the interpreter, calling Struct.new creates a new Class:
|
24
|
+
* \code
|
25
|
+
* irb(main):001:0> MyStruct = Struct.new(:a, :b, :c)
|
26
|
+
* => S
|
27
|
+
* irb(main):002:0> MyStruct.class
|
28
|
+
* => Class
|
29
|
+
* \endcode
|
30
|
+
*
|
31
|
+
* Instantiating that Class creates an instance of that Class:
|
32
|
+
* \code
|
33
|
+
* irb(main):003:0> mystruct_instance = MyStruct.new
|
34
|
+
* => #<struct MyStruct a=nil, b=nil, c=nil>
|
35
|
+
* irb(main):004:0> mystruct_instance.class
|
36
|
+
* => MyStruct
|
37
|
+
* irb(main):005:0> mystruct_instance.class.ancestors
|
38
|
+
* => [MyStruct, Struct, Enumerable, Object, Kernel]
|
39
|
+
* \endcode
|
40
|
+
*
|
41
|
+
* Thus, inside the interpreter, MyStruct is a Class which inherits
|
42
|
+
* from Struct, and mystruct_instance is an instance of MyStruct.
|
43
|
+
*
|
44
|
+
* At the C++ level, we might do this instead:
|
45
|
+
* \code
|
46
|
+
* Struct rb_cMyStruct = define_struct()
|
47
|
+
* .define_member("a")
|
48
|
+
* .define_member("b")
|
49
|
+
* .define_member("c")
|
50
|
+
* .initialize("MyStruct");
|
51
|
+
* Struct::Instance mystruct_instance(rb_cMyStruct.new_instance());
|
52
|
+
* \endcode
|
53
|
+
*
|
54
|
+
* Here rb_cMyStruct is an instance of Struct and that mystruct_instance
|
55
|
+
* is an instance of Struct::Instance.
|
56
|
+
*/
|
57
|
+
class Struct
|
58
|
+
: public Module_impl<Class, Struct>
|
59
|
+
{
|
60
|
+
public:
|
61
|
+
//! Create a new Struct.
|
62
|
+
Struct();
|
63
|
+
|
64
|
+
//! Copy constructor.
|
65
|
+
Struct(Struct const & s);
|
66
|
+
|
67
|
+
//! Destructor.
|
68
|
+
virtual ~Struct();
|
69
|
+
|
70
|
+
//! Define a new Struct member.
|
71
|
+
/*! Defines a new member of the Struct. Must be called before the
|
72
|
+
* Struct is initialized.
|
73
|
+
* \return *this
|
74
|
+
*/
|
75
|
+
Struct & define_member(
|
76
|
+
Identifier name);
|
77
|
+
|
78
|
+
//! Initialize the Struct class.
|
79
|
+
/*! Must be called after all Struct members have been defined.
|
80
|
+
* \param module the module under which to define the Struct.
|
81
|
+
* \param name the name of the Class at the ruby level.
|
82
|
+
*/
|
83
|
+
Struct & initialize(
|
84
|
+
Module module,
|
85
|
+
Identifier name);
|
86
|
+
|
87
|
+
//! Get the offset of a member in the Struct.
|
88
|
+
/*! Internally, Struct members are stored as a single array of VALUE.
|
89
|
+
* This function determines the offset of a given member in that
|
90
|
+
* array.
|
91
|
+
* \param member the name of the desired member.
|
92
|
+
* \return the index of the given member.
|
93
|
+
*/
|
94
|
+
size_t offset_of(Identifier name) const;
|
95
|
+
|
96
|
+
class Instance;
|
97
|
+
friend class Instance;
|
98
|
+
friend Struct Rice::define_struct();
|
99
|
+
|
100
|
+
//! Create a new instance of the Struct
|
101
|
+
/*! \param args the arguments to the constructor.
|
102
|
+
* \return a new Struct::Instance
|
103
|
+
*/
|
104
|
+
Instance new_instance(Array args = Array()) const;
|
105
|
+
|
106
|
+
//! Swap with another Struct.
|
107
|
+
void swap(Struct & other);
|
108
|
+
|
109
|
+
Array members() const { return members_; }
|
110
|
+
|
111
|
+
private:
|
112
|
+
Array members_;
|
113
|
+
Address_Registration_Guard members_guard_;
|
114
|
+
|
115
|
+
Hash member_offset_;
|
116
|
+
Address_Registration_Guard member_offset_guard_;
|
117
|
+
};
|
118
|
+
|
119
|
+
|
120
|
+
//! An instance of a Struct
|
121
|
+
//! \sa Struct
|
122
|
+
class Struct::Instance
|
123
|
+
: public Builtin_Object<T_STRUCT>
|
124
|
+
{
|
125
|
+
public:
|
126
|
+
//! Create a new Instance of a Struct.
|
127
|
+
/*! \param type the Struct type to create.
|
128
|
+
* \param args the initial values for the objects of the instance.
|
129
|
+
*/
|
130
|
+
Instance(
|
131
|
+
Struct const & type,
|
132
|
+
Array args = Array());
|
133
|
+
|
134
|
+
//! Encapsulate an existing Struct instance.
|
135
|
+
/*! \param type the Struct type to encapsulate.
|
136
|
+
* \param s the instance to encapsulate.
|
137
|
+
*/
|
138
|
+
Instance(
|
139
|
+
Struct const & type,
|
140
|
+
Object s);
|
141
|
+
|
142
|
+
//! Get a member, given its offset.
|
143
|
+
/*! \param index the (integral) index into the Struct's internal
|
144
|
+
* array or its name (an Identifier or char const *)
|
145
|
+
* \return the member.
|
146
|
+
*/
|
147
|
+
template<typename T>
|
148
|
+
Object operator[](T index);
|
149
|
+
|
150
|
+
//! Swap with another Struct::Instance.
|
151
|
+
void swap(Instance & other);
|
152
|
+
|
153
|
+
private:
|
154
|
+
Struct type_;
|
155
|
+
};
|
156
|
+
|
157
|
+
} // namespace Rice
|
158
|
+
|
159
|
+
#include "Struct.ipp"
|
160
|
+
|
161
|
+
#endif // Rice__ruby_struct__hpp_
|
162
|
+
|
data/rice/Struct.ipp
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
namespace Rice
|
2
|
+
{
|
3
|
+
|
4
|
+
template<typename T>
|
5
|
+
inline Object Struct::Instance::
|
6
|
+
operator[](T index)
|
7
|
+
{
|
8
|
+
return rb_struct_aref(value(), ULONG2NUM(index));
|
9
|
+
}
|
10
|
+
|
11
|
+
template<>
|
12
|
+
inline Object Struct::Instance::
|
13
|
+
operator[]<Identifier>(Identifier member)
|
14
|
+
{
|
15
|
+
size_t index = type_.offset_of(member);
|
16
|
+
return (*this)[index];
|
17
|
+
}
|
18
|
+
|
19
|
+
template<>
|
20
|
+
inline Object Struct::Instance::
|
21
|
+
operator[]<char const *>(char const * name)
|
22
|
+
{
|
23
|
+
return (*this)[Identifier(name)];
|
24
|
+
}
|
25
|
+
|
26
|
+
} // Rice
|
data/rice/Symbol.cpp
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#include "Symbol.hpp"
|
2
|
+
|
3
|
+
namespace
|
4
|
+
{
|
5
|
+
VALUE check_type(Rice::Object value, int type)
|
6
|
+
{
|
7
|
+
rb_check_type(value, type);
|
8
|
+
return Qnil;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
Rice::Symbol::
|
13
|
+
Symbol(VALUE v)
|
14
|
+
: Object(v)
|
15
|
+
{
|
16
|
+
protect(check_type, v, T_SYMBOL);
|
17
|
+
}
|
18
|
+
|
19
|
+
Rice::Symbol::
|
20
|
+
Symbol(Object v)
|
21
|
+
: Object(v)
|
22
|
+
{
|
23
|
+
protect(check_type, v, T_SYMBOL);
|
24
|
+
}
|
25
|
+
|
data/rice/Symbol.hpp
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#ifndef Rice__Symbol__hpp_
|
2
|
+
#define Rice__Symbol__hpp_
|
3
|
+
|
4
|
+
#include "Identifier.hpp"
|
5
|
+
#include "Object.hpp"
|
6
|
+
#include "detail/ruby.hpp"
|
7
|
+
#include <string>
|
8
|
+
|
9
|
+
namespace Rice
|
10
|
+
{
|
11
|
+
|
12
|
+
//! A wrapper for ruby's Symbol class.
|
13
|
+
/*! Symbols are internal identifiers in ruby. They are singletons and
|
14
|
+
* can be thought of as frozen strings. They differ from an Identifier
|
15
|
+
* in that they are in fact real Objects, but they can be converted
|
16
|
+
* back and forth between Identifier and Symbol.
|
17
|
+
*/
|
18
|
+
class Symbol
|
19
|
+
: public Object
|
20
|
+
{
|
21
|
+
public:
|
22
|
+
//! Wrap an existing symbol.
|
23
|
+
Symbol(VALUE v);
|
24
|
+
|
25
|
+
//! Wrap an existing symbol.
|
26
|
+
Symbol(Object v);
|
27
|
+
|
28
|
+
//! Construct a Symbol from an Identifier.
|
29
|
+
Symbol(Identifier id);
|
30
|
+
|
31
|
+
//! Construct a Symbol from a null-terminated C string.
|
32
|
+
Symbol(char const * s = "");
|
33
|
+
|
34
|
+
//! Construct a Symbol from an std::string.
|
35
|
+
Symbol(std::string const & s);
|
36
|
+
|
37
|
+
//! Return a string representation of the Symbol.
|
38
|
+
char const * c_str() const;
|
39
|
+
|
40
|
+
//! Return a string representation of the Symbol.
|
41
|
+
std::string str() const;
|
42
|
+
|
43
|
+
//! Return the Symbol as an Identifier.
|
44
|
+
Identifier to_id() const;
|
45
|
+
};
|
46
|
+
|
47
|
+
} // namespace Rice
|
48
|
+
|
49
|
+
template<>
|
50
|
+
inline
|
51
|
+
Rice::Symbol from_ruby<Rice::Symbol>(Rice::Object x)
|
52
|
+
{
|
53
|
+
return Rice::Symbol(x);
|
54
|
+
}
|
55
|
+
|
56
|
+
template<>
|
57
|
+
inline
|
58
|
+
Rice::Object to_ruby<Rice::Symbol>(Rice::Symbol const & x)
|
59
|
+
{
|
60
|
+
return x;
|
61
|
+
}
|
62
|
+
|
63
|
+
#include "Symbol.ipp"
|
64
|
+
|
65
|
+
#endif // Rice__Symbol__hpp_
|
66
|
+
|
data/rice/Symbol.ipp
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#ifndef Rice__Symbol__ipp_
|
2
|
+
#define Rice__Symbol__ipp_
|
3
|
+
|
4
|
+
#include "protect.hpp"
|
5
|
+
#include "detail/ruby.hpp"
|
6
|
+
|
7
|
+
inline Rice::Symbol::
|
8
|
+
Symbol(char const * s)
|
9
|
+
: Object(ID2SYM(rb_intern(s)))
|
10
|
+
{
|
11
|
+
}
|
12
|
+
|
13
|
+
inline Rice::Symbol::
|
14
|
+
Symbol(std::string const & s)
|
15
|
+
: Object(ID2SYM(rb_intern(s.c_str())))
|
16
|
+
{
|
17
|
+
}
|
18
|
+
|
19
|
+
inline Rice::Symbol::
|
20
|
+
Symbol(Identifier id)
|
21
|
+
: Object(ID2SYM(id))
|
22
|
+
{
|
23
|
+
}
|
24
|
+
|
25
|
+
inline char const * Rice::Symbol::
|
26
|
+
c_str() const
|
27
|
+
{
|
28
|
+
return to_id().c_str();
|
29
|
+
}
|
30
|
+
|
31
|
+
inline std::string Rice::Symbol::
|
32
|
+
str() const
|
33
|
+
{
|
34
|
+
return to_id().str();
|
35
|
+
}
|
36
|
+
|
37
|
+
inline Rice::Identifier Rice::Symbol::
|
38
|
+
to_id() const
|
39
|
+
{
|
40
|
+
return rb_to_id(value());
|
41
|
+
}
|
42
|
+
|
43
|
+
#endif // Rice__Symbol__ipp_
|
44
|
+
|
data/rice/config.hpp
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
/* rice/config.hpp. Generated from config.hpp.in by configure. */
|
2
|
+
/* rice/config.hpp.in. Generated from configure.ac by autoheader. */
|
3
|
+
|
4
|
+
/* define if the compiler supports basic C++14 syntax */
|
5
|
+
#define HAVE_CXX14 1
|
6
|
+
|
7
|
+
/* Define to 1 if you have the <env.h> header file. */
|
8
|
+
/* #undef HAVE_ENV_H */
|
9
|
+
|
10
|
+
/* Define to 1 if you have the <node.h> header file. */
|
11
|
+
/* #undef HAVE_NODE_H */
|
12
|
+
|
13
|
+
/* Define to 1 if you have the <ruby.h> header file. */
|
14
|
+
#define HAVE_RUBY_H 1
|
15
|
+
|
16
|
+
/* Define to 1 if you have the <ruby/node.h> header file. */
|
17
|
+
/* #undef HAVE_RUBY_NODE_H */
|
18
|
+
|
19
|
+
/* Define to 1 if you have the <version.h> header file. */
|
20
|
+
/* #undef HAVE_VERSION_H */
|
21
|
+
|
22
|
+
/* Name of package */
|
23
|
+
#define PACKAGE "rice"
|
24
|
+
|
25
|
+
/* Define to the address where bug reports for this package should be sent. */
|
26
|
+
#define PACKAGE_BUGREPORT ""
|
27
|
+
|
28
|
+
/* Define to the full name of this package. */
|
29
|
+
#define PACKAGE_NAME "rice"
|
30
|
+
|
31
|
+
/* Define to the full name and version of this package. */
|
32
|
+
#define PACKAGE_STRING "rice 1.1"
|
33
|
+
|
34
|
+
/* Define to the one symbol short name of this package. */
|
35
|
+
#define PACKAGE_TARNAME "rice"
|
36
|
+
|
37
|
+
/* Define to the home page for this package. */
|
38
|
+
#define PACKAGE_URL ""
|
39
|
+
|
40
|
+
/* Define to the version of this package. */
|
41
|
+
#define PACKAGE_VERSION "1.1"
|
42
|
+
|
43
|
+
/* Define this macro to use ruby/node.h */
|
44
|
+
/* #undef REALLY_HAVE_RUBY_NODE_H */
|
45
|
+
|
46
|
+
/* Version number of package */
|
47
|
+
#define VERSION "1.1"
|