cplus2ruby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,149 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ #### Start of system configuration section. ####
5
+
6
+ srcdir = .
7
+ topdir = /usr/local/lib/ruby/1.8/i386-freebsd7
8
+ hdrdir = $(topdir)
9
+ VPATH = $(srcdir):$(topdir):$(hdrdir)
10
+ prefix = $(DESTDIR)/usr/local
11
+ exec_prefix = $(prefix)
12
+ sitedir = $(prefix)/lib/ruby/site_ruby
13
+ rubylibdir = $(libdir)/ruby/$(ruby_version)
14
+ docdir = $(datarootdir)/doc/$(PACKAGE)
15
+ dvidir = $(docdir)
16
+ datarootdir = $(prefix)/share
17
+ archdir = $(rubylibdir)/$(arch)
18
+ sbindir = $(exec_prefix)/sbin
19
+ psdir = $(docdir)
20
+ localedir = $(datarootdir)/locale
21
+ htmldir = $(docdir)
22
+ datadir = $(datarootdir)
23
+ includedir = $(prefix)/include
24
+ infodir = $(DESTDIR)/usr/local/info/
25
+ sysconfdir = $(prefix)/etc
26
+ mandir = $(DESTDIR)/usr/local/man
27
+ libdir = $(exec_prefix)/lib
28
+ sharedstatedir = $(prefix)/com
29
+ oldincludedir = $(DESTDIR)/usr/include
30
+ pdfdir = $(docdir)
31
+ sitearchdir = $(sitelibdir)/$(sitearch)
32
+ bindir = $(exec_prefix)/bin
33
+ localstatedir = $(prefix)/var
34
+ sitelibdir = $(sitedir)/$(ruby_version)
35
+ libexecdir = $(exec_prefix)/libexec
36
+
37
+ CC = cc
38
+ LIBRUBY = $(LIBRUBY_SO)
39
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
40
+ LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
41
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
42
+
43
+ RUBY_EXTCONF_H =
44
+ CFLAGS = -fPIC
45
+ INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
46
+ CPPFLAGS =
47
+ CXXFLAGS = $(CFLAGS)
48
+ DLDFLAGS = -L. -rdynamic -Wl,-soname,$(.TARGET)
49
+ LDSHARED = cc -shared
50
+ AR = ar
51
+ EXEEXT =
52
+
53
+ RUBY_INSTALL_NAME = ruby18
54
+ RUBY_SO_NAME = ruby18
55
+ arch = i386-freebsd7
56
+ sitearch = i386-freebsd7
57
+ ruby_version = 1.8
58
+ ruby = /usr/local/bin/ruby18
59
+ RUBY = $(ruby)
60
+ RM = rm -f
61
+ MAKEDIRS = mkdir -p
62
+ INSTALL = /usr/bin/install -c -o root -g wheel
63
+ INSTALL_PROG = $(INSTALL) -m 0755
64
+ INSTALL_DATA = install -o root -g wheel -m 444
65
+ COPY = cp
66
+
67
+ #### End of system configuration section. ####
68
+
69
+ preload =
70
+
71
+ libpath = . $(libdir)
72
+ LIBPATH = -L'.' -L'$(libdir)' -Wl,-R'$(libdir)'
73
+ DEFFILE =
74
+
75
+ CLEANFILES = mkmf.log
76
+ DISTCLEANFILES =
77
+
78
+ extout =
79
+ extout_prefix =
80
+ target_prefix =
81
+ LOCAL_LIBS =
82
+ LIBS = $(LIBRUBYARG_SHARED) -lcrypt -lm -rpath=/usr/lib:/usr/local/lib -pthread -lc -lstdc++
83
+ SRCS = test_mixin.cc test_mixin_wrap.cc
84
+ OBJS = test_mixin.o test_mixin_wrap.o
85
+ TARGET = test_mixin
86
+ DLLIB = $(TARGET).so
87
+ EXTSTATIC =
88
+ STATIC_LIB =
89
+
90
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
91
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
92
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
93
+
94
+ TARGET_SO = $(DLLIB)
95
+ CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
96
+ CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
97
+
98
+ all: $(DLLIB)
99
+ static: $(STATIC_LIB)
100
+
101
+ clean:
102
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
103
+
104
+ distclean: clean
105
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
106
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
107
+
108
+ realclean: distclean
109
+ install: install-so install-rb
110
+
111
+ install-so: $(RUBYARCHDIR)
112
+ install-so: $(RUBYARCHDIR)/$(DLLIB)
113
+ $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
114
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
115
+ install-rb: pre-install-rb install-rb-default
116
+ install-rb-default: pre-install-rb-default
117
+ pre-install-rb: Makefile
118
+ pre-install-rb-default: Makefile
119
+ $(RUBYARCHDIR):
120
+ $(MAKEDIRS) $@
121
+
122
+ site-install: site-install-so site-install-rb install
123
+ site-install-so: install-so
124
+ site-install-rb: install-rb
125
+
126
+ .SUFFIXES: .c .m .cc .cxx .cpp .C .o
127
+
128
+ .cc.o:
129
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
130
+
131
+ .cxx.o:
132
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
133
+
134
+ .cpp.o:
135
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
136
+
137
+ .C.o:
138
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
139
+
140
+ .c.o:
141
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
142
+
143
+ $(DLLIB): $(OBJS)
144
+ @-$(RM) $@
145
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
146
+
147
+
148
+
149
+ $(OBJS): ruby.h defines.h
@@ -0,0 +1,23 @@
1
+ #include "test_mixin.h"
2
+
3
+
4
+ A::A()
5
+ {
6
+ this->y = 0;
7
+ }
8
+
9
+
10
+
11
+ B::B()
12
+ {
13
+ this->a = 0;
14
+ }
15
+
16
+
17
+
18
+ C::C()
19
+ {
20
+ this->z = 0;
21
+ }
22
+
23
+
@@ -0,0 +1,51 @@
1
+ #include <stdlib.h>
2
+ #include "ruby.h"
3
+ struct RubyObject {
4
+ VALUE __obj__;
5
+ RubyObject() { __obj__ = Qnil; }
6
+ virtual ~RubyObject() {};
7
+ static void __free(void *ptr) { ((RubyObject*)ptr)->__free__(); }
8
+ static void __mark(void *ptr) { ((RubyObject*)ptr)->__mark__(); }
9
+ virtual void __free__() { delete this; }
10
+ virtual void __mark__() { }
11
+ };
12
+ struct A;
13
+ struct B;
14
+ struct C;
15
+
16
+ struct A : RubyObject
17
+ {
18
+ typedef RubyObject super;
19
+
20
+ A();
21
+
22
+
23
+
24
+
25
+ int y;
26
+ };
27
+
28
+ struct B : A
29
+ {
30
+ typedef A super;
31
+
32
+ B();
33
+
34
+
35
+
36
+
37
+ int a;
38
+ };
39
+
40
+ struct C : B
41
+ {
42
+ typedef B super;
43
+
44
+ C();
45
+
46
+
47
+
48
+
49
+ int z;
50
+ };
51
+
Binary file
Binary file
@@ -0,0 +1,105 @@
1
+ #include "test_mixin.h"
2
+
3
+
4
+ static VALUE
5
+ A_alloc__(VALUE klass)
6
+ {
7
+ A *__cobj__;
8
+ __cobj__ = new A();
9
+ __cobj__->__obj__ = Data_Wrap_Struct(klass, RubyObject::__mark, RubyObject::__free, __cobj__);
10
+ return __cobj__->__obj__;
11
+ }
12
+ static VALUE
13
+ A_get__y(VALUE __self__)
14
+ {
15
+ int __res__;
16
+ A *__cobj__;
17
+ Check_Type(__self__, T_DATA);
18
+ __cobj__ = (A*) DATA_PTR(__self__);
19
+ __res__ = __cobj__->y;
20
+ return INT2NUM(__res__);
21
+ }
22
+ static VALUE
23
+ A_set__y(VALUE __self__, VALUE __val__)
24
+ {
25
+ A *__cobj__;
26
+ Check_Type(__self__, T_DATA);
27
+ __cobj__ = (A*) DATA_PTR(__self__);
28
+ ;
29
+ __cobj__->y = (int)NUM2INT(__val__);
30
+ return Qnil;
31
+ }
32
+
33
+ static VALUE
34
+ B_alloc__(VALUE klass)
35
+ {
36
+ B *__cobj__;
37
+ __cobj__ = new B();
38
+ __cobj__->__obj__ = Data_Wrap_Struct(klass, RubyObject::__mark, RubyObject::__free, __cobj__);
39
+ return __cobj__->__obj__;
40
+ }
41
+ static VALUE
42
+ B_get__a(VALUE __self__)
43
+ {
44
+ int __res__;
45
+ B *__cobj__;
46
+ Check_Type(__self__, T_DATA);
47
+ __cobj__ = (B*) DATA_PTR(__self__);
48
+ __res__ = __cobj__->a;
49
+ return INT2NUM(__res__);
50
+ }
51
+ static VALUE
52
+ B_set__a(VALUE __self__, VALUE __val__)
53
+ {
54
+ B *__cobj__;
55
+ Check_Type(__self__, T_DATA);
56
+ __cobj__ = (B*) DATA_PTR(__self__);
57
+ ;
58
+ __cobj__->a = (int)NUM2INT(__val__);
59
+ return Qnil;
60
+ }
61
+
62
+ static VALUE
63
+ C_alloc__(VALUE klass)
64
+ {
65
+ C *__cobj__;
66
+ __cobj__ = new C();
67
+ __cobj__->__obj__ = Data_Wrap_Struct(klass, RubyObject::__mark, RubyObject::__free, __cobj__);
68
+ return __cobj__->__obj__;
69
+ }
70
+ static VALUE
71
+ C_get__z(VALUE __self__)
72
+ {
73
+ int __res__;
74
+ C *__cobj__;
75
+ Check_Type(__self__, T_DATA);
76
+ __cobj__ = (C*) DATA_PTR(__self__);
77
+ __res__ = __cobj__->z;
78
+ return INT2NUM(__res__);
79
+ }
80
+ static VALUE
81
+ C_set__z(VALUE __self__, VALUE __val__)
82
+ {
83
+ C *__cobj__;
84
+ Check_Type(__self__, T_DATA);
85
+ __cobj__ = (C*) DATA_PTR(__self__);
86
+ ;
87
+ __cobj__->z = (int)NUM2INT(__val__);
88
+ return Qnil;
89
+ }
90
+ extern "C" void Init_test_mixin()
91
+ {
92
+ VALUE klass;
93
+ klass = rb_eval_string("A");
94
+ rb_define_alloc_func(klass, A_alloc__);
95
+ rb_define_method(klass, "y", (VALUE(*)(...))A_get__y, 0);
96
+ rb_define_method(klass, "y=", (VALUE(*)(...))A_set__y, 1);
97
+ klass = rb_eval_string("B");
98
+ rb_define_alloc_func(klass, B_alloc__);
99
+ rb_define_method(klass, "a", (VALUE(*)(...))B_get__a, 0);
100
+ rb_define_method(klass, "a=", (VALUE(*)(...))B_set__a, 1);
101
+ klass = rb_eval_string("C");
102
+ rb_define_alloc_func(klass, C_alloc__);
103
+ rb_define_method(klass, "z", (VALUE(*)(...))C_get__z, 0);
104
+ rb_define_method(klass, "z=", (VALUE(*)(...))C_set__z, 1);
105
+ }
Binary file
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cplus2ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Neumann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-03-16 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: facets
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.3.0
23
+ version:
24
+ description:
25
+ email: mneumann@ntecs.de
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - cplus2ruby.gemspec
34
+ - example.rb
35
+ - README
36
+ - lib
37
+ - lib/cplus2ruby.rb
38
+ - lib/cplus2ruby
39
+ - lib/cplus2ruby/model.rb
40
+ - lib/cplus2ruby/cpp_code_generator.rb
41
+ - lib/cplus2ruby/compiler.rb
42
+ - lib/cplus2ruby/wrapper_code_generator.rb
43
+ - lib/cplus2ruby/typing.rb
44
+ - lib/cplus2ruby/code_generator.rb
45
+ - test
46
+ - test/test_mixin.rb
47
+ - test/work
48
+ - test/work/test_mixin.h
49
+ - test/work/test_mixin.o
50
+ - test/work/test_mixin.cc
51
+ - test/work/Makefile
52
+ - test/work/test_mixin.so
53
+ - test/work/test_mixin_wrap.cc
54
+ - test/work/test_mixin_wrap.o
55
+ has_rdoc: false
56
+ homepage: http://www.ntecs.de/projects/cplus2ruby/
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ requirements: []
75
+
76
+ rubyforge_project: cplus2ruby
77
+ rubygems_version: 1.0.1
78
+ signing_key:
79
+ specification_version: 2
80
+ summary: Gluing C++ and Ruby together in an OO manner
81
+ test_files: []
82
+