Skip to content

Commit f9e0fb1

Browse files
committed
Add rb_dummy_tests_rb_eval_string
1 parent 453da5b commit f9e0fb1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

testdata/dummy/ext/dummy/tests.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ VALUE rb_dummy_tests_rb_const_get_at(VALUE self, VALUE name);
1717
void rb_dummy_tests_rb_const_set(VALUE self, VALUE name, VALUE val);
1818
VALUE rb_dummy_tests_rb_const_defined(VALUE self, VALUE name);
1919
VALUE rb_dummy_tests_rb_const_defined_at(VALUE self, VALUE name);
20+
VALUE rb_dummy_tests_rb_eval_string(VALUE self, VALUE str);
2021
*/
2122
import "C"
2223

@@ -154,6 +155,14 @@ func rb_dummy_tests_rb_const_defined_at(klass C.VALUE, name C.VALUE) C.VALUE {
154155
return C.VALUE(ruby.Qfalse())
155156
}
156157

158+
//export rb_dummy_tests_rb_eval_string
159+
func rb_dummy_tests_rb_eval_string(_ C.VALUE, str C.VALUE) C.VALUE {
160+
goStr := ruby.Value2String(ruby.VALUE(str))
161+
ret := ruby.RbEvalString(goStr)
162+
163+
return C.VALUE(ret)
164+
}
165+
157166
// defineMethodsToDummyTests define methods in Dummy::Tests
158167
func defineMethodsToDummyTests(rb_mDummy ruby.VALUE) {
159168
rb_cTests := ruby.RbDefineClassUnder(rb_mDummy, "Tests", ruby.VALUE(C.rb_cObject))
@@ -173,4 +182,5 @@ func defineMethodsToDummyTests(rb_mDummy ruby.VALUE) {
173182
ruby.RbDefineSingletonMethod(rb_cTests, "rb_const_set", C.rb_dummy_tests_rb_const_set, 2)
174183
ruby.RbDefineSingletonMethod(rb_cTests, "rb_const_defined", C.rb_dummy_tests_rb_const_defined, 1)
175184
ruby.RbDefineSingletonMethod(rb_cTests, "rb_const_defined_at", C.rb_dummy_tests_rb_const_defined_at, 1)
185+
ruby.RbDefineSingletonMethod(rb_cTests, "rb_eval_string", C.rb_dummy_tests_rb_eval_string, 1)
176186
}

0 commit comments

Comments
 (0)