forked from ruby-rice/rice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathANNOUNCE
88 lines (59 loc) · 2.18 KB
/
ANNOUNCE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Rice: Ruby Interface for C++ Extensions
========================================
What is Rice?
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.
What's New?
* Ruby 2.2 support
Potential breaking changes. Ruby 2.2 removed RHash as a public accessible struct
and as such I changed all of the Builtin_Objects to work directly off of RObject
instead of the specifics (RArray, RStruct, RString, etc). If you've been using these
objects directly I recommend using either the Rice API or Ruby's CAPI instead for
future compatibility.
Supported Platforms:
* Linux
* Mac OS X
* While Windows has been known to work with MinGW / MSYS, I haven't
been able to keep this testing up as of late. Would appreciate any help
here.
What Rice gives you:
* A simple C++-based syntax for wrapping and defining classes
* Automatic conversion of exceptions between C++ and Ruby
* Smart pointers for handling garbage collection
* Wrappers for most builtin types to simplify calling code
Documentation: http://jasonroelofs.github.io/rice
Project Page: http://github.com/jasonroelofs/rice
Mailing List: [email protected]
First email will be used as subscription and dropped.
How do you get Rice?
gem install rice
Note: Rice does require a C++ compiler. See the Documentation page for more details.
How simple of a syntax?
wrapper.cpp
#include <rice/Class.hpp>
#include <rice/Constructor.hpp>
class MyWrapper {
public:
MyWrapper() { }
void doThis() { }
int doThat(int a, float b) { }
};
extern "C"
void Init_wrapper()
{
define_class<MyWrapper>("MyWrapper")
.define_constructor(Constructor<MyWrapper>())
.define_method("do_this", &MyWrapper::doThis)
.define_method("do_that", &MyWrapper::doThat);
}
extconf.rb
require 'mkmf-rice'
create_makefile("wrapper")
test.rb
require 'wrapper'
c = MyWrapper.new
c.do_this
c.do_that(1, 2.0)