Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9bd2147d61de
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: db7ac06ca0a4
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Jul 23, 2016

  1. Copy the full SHA
    b48a6ac View commit details
  2. [Truffle] rb_respond_to

    chrisseaton committed Jul 23, 2016
    Copy the full SHA
    794de75 View commit details
  3. Copy the full SHA
    db7ac06 View commit details
Showing with 39 additions and 2 deletions.
  1. +8 −1 lib/ruby/truffle/cext/ruby.h
  2. +26 −1 truffle/src/main/c/cext/ruby.c
  3. +5 −0 truffle/src/main/ruby/core/truffle/cext.rb
9 changes: 8 additions & 1 deletion lib/ruby/truffle/cext/ruby.h
Original file line number Diff line number Diff line change
@@ -202,7 +202,9 @@ double RFLOAT_VALUE(VALUE value);
// String

char *RSTRING_PTR(VALUE string);
int RSTRING_LEN(VALUE string);
int rb_str_len(VALUE string);
#define RSTRING_LEN(str) rb_str_len(str)
#define RSTRING_LENINT(str) rb_str_len(str)
VALUE rb_intern_str(VALUE string);
VALUE rb_str_new(const char *string, long length);
VALUE rb_str_new_cstr(const char *string);
@@ -255,10 +257,15 @@ VALUE rb_proc_new(void *function, VALUE value);

// Utilities

void rb_warn(const char *fmt, ...);
void rb_warning(const char *fmt, ...);

int rb_scan_args(int argc, VALUE *argv, const char *format, ...);

// Calls

int rb_respond_to(VALUE object, ID name);

#define rb_funcall(object, name, ...) truffle_invoke(RUBY_CEXT, "rb_funcall", object, name, __VA_ARGS__)

VALUE rb_yield(VALUE value);
27 changes: 26 additions & 1 deletion truffle/src/main/c/cext/ruby.c
Original file line number Diff line number Diff line change
@@ -11,6 +11,9 @@
* copyright (C) Yukihiro Matsumoto, licensed under the 2-clause BSD licence
* as described in the file BSDL included with JRuby+Truffle.
*/

#include <stdarg.h>
#include <stdio.h>

#include <truffle.h>

@@ -175,7 +178,7 @@ char *RSTRING_PTR(VALUE string) {
return truffle_invoke(RUBY_CEXT, "CExtString", string);
}

int RSTRING_LEN(VALUE string) {
int rb_str_len(VALUE string) {
return truffle_invoke_i(string, "bytesize");
}

@@ -325,12 +328,34 @@ VALUE rb_proc_new(void *function, VALUE value) {

// Utilities

void rb_warn(const char *format, ...) {
if (!truffle_invoke_b(truffle_invoke(RUBY_CEXT, "verbose"), "nil?")) {
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
}
}

void rb_warning(const char *format, ...) {
if (truffle_invoke(RUBY_CEXT, "verbose") == Qtrue) {
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
}
}

int rb_scan_args(int argc, VALUE *argv, const char *format, ...) {
return truffle_invoke_i(RUBY_CEXT, "rb_scan_args", argc, argv, format /*, where to get args? */);
}

// Calls

int rb_respond_to(VALUE object, ID name) {
return truffle_invoke_b(object, "respond_to?", name);
}

VALUE rb_yield(VALUE value) {
return truffle_invoke(RUBY_CEXT, "rb_yield", value);
}
5 changes: 5 additions & 0 deletions truffle/src/main/ruby/core/truffle/cext.rb
Original file line number Diff line number Diff line change
@@ -241,6 +241,10 @@ def rb_proc_new(function, value)
}
end

def verbose
$VERBOSE
end

def rb_scan_args
raise 'not implemented'
end
@@ -402,6 +406,7 @@ def rb_gc_enable
def rb_gc_disable
GC.disable
end

end

Truffle::Interop.export(:ruby_cext, Truffle::CExt)