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: 16f5cf9a95d3
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e8aed55ccdbc
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Apr 25, 2016

  1. Copy the full SHA
    01ade30 View commit details
  2. Copy the full SHA
    7aec008 View commit details

Commits on Apr 26, 2016

  1. Copy the full SHA
    e8aed55 View commit details
Showing with 34 additions and 1 deletion.
  1. +10 −1 lib/ruby/truffle/cext/ruby.h
  2. BIN lib/ruby/truffle/cext/ruby.su
  3. +24 −0 truffle/src/main/c/cext/ruby.c
11 changes: 10 additions & 1 deletion lib/ruby/truffle/cext/ruby.h
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ extern "C" {
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>

#define xmalloc malloc
#define xfree free
@@ -44,7 +45,8 @@ VALUE get_rb_cHash();

VALUE get_rb_eRuntimeError();

#define rb_eRuntimeError get_rb_eRuntimeError();
#define rb_eRuntimeError get_rb_eRuntimeError()


int NUM2INT(VALUE value);
unsigned int NUM2UINT(VALUE value);
@@ -63,9 +65,13 @@ VALUE LONG2FIX(long value);

int FIXNUM_P(VALUE value);

VALUE rb_float_new(double value);

char *RSTRING_PTR(VALUE string);
int RSTRING_LEN(VALUE string);
ID rb_intern(const char *string);
VALUE rb_str_new2(const char *string);
VALUE ID2SYM(ID id);
VALUE rb_intern_str(VALUE string);
void rb_str_cat(VALUE string, char *to_concat, long length);

@@ -77,7 +83,10 @@ VALUE rb_ary_new();
void rb_ary_push(VALUE array, VALUE value);
void rb_ary_store(VALUE array, long index, VALUE value);
VALUE rb_ary_entry(VALUE array, long index);
int RARRAY_LENINT(VALUE array);
VALUE rb_ary_dup(VALUE array);

VALUE rb_hash_new();
VALUE rb_hash_aref(VALUE hash, VALUE key);
void rb_hash_aset(VALUE hash, VALUE key, VALUE value);

Binary file modified lib/ruby/truffle/cext/ruby.su
Binary file not shown.
24 changes: 24 additions & 0 deletions truffle/src/main/c/cext/ruby.c
Original file line number Diff line number Diff line change
@@ -95,6 +95,10 @@ int FIXNUM_P(VALUE value) {
return truffle_invoke_i(ruby_cext, "fixnum?", value);
}

VALUE rb_float_new(double value) {
return (VALUE) truffle_invoke(ruby_cext, "float_new", value);
}

char *RSTRING_PTR(VALUE string) {
// Needs to return a fake char* which actually calls back into Ruby when read or written
return (char*) truffle_invoke(ruby_cext, "string_ptr", string);
@@ -104,14 +108,26 @@ int RSTRING_LEN(VALUE string) {
return truffle_get_size(string);
}

VALUE rb_ary_dup(VALUE array) {
return (VALUE) truffle_invoke(array, "dup");
}

ID rb_intern(const char *string) {
return (ID) truffle_invoke(ruby_cext, "intern", string);
}

VALUE rb_str_new2(const char *string) {
return (VALUE) truffle_invoke(ruby_cext, "str_new2", string);
}

VALUE rb_intern_str(VALUE string) {
return (VALUE) truffle_invoke(ruby_cext, "intern", string);
}

VALUE ID2SYM(ID id) {
return truffle_invoke(ruby_cext, "id2sym", id);
}

void rb_str_cat(VALUE string, char *to_concat, long length) {
truffle_invoke(ruby_cext, "string_cat", string, to_concat, length);
}
@@ -149,6 +165,14 @@ VALUE rb_ary_entry(VALUE array, long index) {
return truffle_read_idx(array, (int) index);
}

int RARRAY_LENINT(VALUE array) {
return truffle_get_size(array);
}

VALUE rb_hash_new() {
return (VALUE) truffle_invoke(ruby_cext, "hash_new");
}

VALUE rb_hash_aref(VALUE hash, VALUE key) {
return truffle_read(hash, key);
}