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

Commits on Sep 6, 2016

  1. Copy the full SHA
    8303bc9 View commit details
  2. Copy the full SHA
    28f9c56 View commit details
  3. Copy the full SHA
    cbdcd2b View commit details
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/runtime/Visibility.java
Original file line number Diff line number Diff line change
@@ -38,6 +38,10 @@ public boolean isProtected() {
return this == PROTECTED;
}

public boolean isModuleFunction() {
return this == MODULE_FUNCTION;
}

public static Visibility[] getValues() {
return VALUES;
}
2 changes: 1 addition & 1 deletion lib/ruby/truffle/cext/ruby.h
Original file line number Diff line number Diff line change
@@ -416,7 +416,7 @@ VALUE rb_class_real(VALUE ruby_class);
VALUE rb_class_superclass(VALUE ruby_class);
VALUE rb_class_of(VALUE object);
VALUE rb_obj_class(VALUE object);
#define CLASS_OF(object) rb_class_of((VALUE) (object))
VALUE CLASS_OF(VALUE object);
VALUE rb_obj_alloc(VALUE ruby_class);
VALUE rb_class_path(VALUE ruby_class);
VALUE rb_path2class(const char *string);
4 changes: 4 additions & 0 deletions truffle/src/main/c/cext/ruby.c
Original file line number Diff line number Diff line change
@@ -597,6 +597,10 @@ VALUE rb_obj_class(VALUE object) {
return rb_class_real(rb_class_of(object));
}

VALUE CLASS_OF(VALUE object) {
return (VALUE) truffle_invoke(RUBY_CEXT, "CLASS_OF", object);
}

VALUE rb_class_of(VALUE object) {
return (VALUE) truffle_invoke((void *)object, "class");
}
64 changes: 33 additions & 31 deletions truffle/src/main/c/openssl/ossl_asn1.c
Original file line number Diff line number Diff line change
@@ -509,38 +509,40 @@ typedef struct {
VALUE *klass;
} ossl_asn1_info_t;

// TODO CS 06-09-16 Removed the address of the classes for now as it causes problems in Sulong

static const ossl_asn1_info_t ossl_asn1_info[] = {
{ "EOC", &cASN1EndOfContent, }, /* 0 */
{ "BOOLEAN", &cASN1Boolean, }, /* 1 */
{ "INTEGER", &cASN1Integer, }, /* 2 */
{ "BIT_STRING", &cASN1BitString, }, /* 3 */
{ "OCTET_STRING", &cASN1OctetString, }, /* 4 */
{ "NULL", &cASN1Null, }, /* 5 */
{ "OBJECT", &cASN1ObjectId, }, /* 6 */
{ "OBJECT_DESCRIPTOR", NULL, }, /* 7 */
{ "EXTERNAL", NULL, }, /* 8 */
{ "REAL", NULL, }, /* 9 */
{ "ENUMERATED", &cASN1Enumerated, }, /* 10 */
{ "EMBEDDED_PDV", NULL, }, /* 11 */
{ "UTF8STRING", &cASN1UTF8String, }, /* 12 */
{ "RELATIVE_OID", NULL, }, /* 13 */
{ "[UNIVERSAL 14]", NULL, }, /* 14 */
{ "[UNIVERSAL 15]", NULL, }, /* 15 */
{ "SEQUENCE", &cASN1Sequence, }, /* 16 */
{ "SET", &cASN1Set, }, /* 17 */
{ "NUMERICSTRING", &cASN1NumericString, }, /* 18 */
{ "PRINTABLESTRING", &cASN1PrintableString, }, /* 19 */
{ "T61STRING", &cASN1T61String, }, /* 20 */
{ "VIDEOTEXSTRING", &cASN1VideotexString, }, /* 21 */
{ "IA5STRING", &cASN1IA5String, }, /* 22 */
{ "UTCTIME", &cASN1UTCTime, }, /* 23 */
{ "GENERALIZEDTIME", &cASN1GeneralizedTime, }, /* 24 */
{ "GRAPHICSTRING", &cASN1GraphicString, }, /* 25 */
{ "ISO64STRING", &cASN1ISO64String, }, /* 26 */
{ "GENERALSTRING", &cASN1GeneralString, }, /* 27 */
{ "UNIVERSALSTRING", &cASN1UniversalString, }, /* 28 */
{ "CHARACTER_STRING", NULL, }, /* 29 */
{ "BMPSTRING", &cASN1BMPString, }, /* 30 */
{ "EOC", NULL /*&cASN1EndOfContent*/, }, /* 0 */
{ "BOOLEAN", NULL /*&cASN1Boolean*/, }, /* 1 */
{ "INTEGER", NULL /*&cASN1Integer*/, }, /* 2 */
{ "BIT_STRING", NULL /*&cASN1BitString*/, }, /* 3 */
{ "OCTET_STRING", NULL /*&cASN1OctetString*/, }, /* 4 */
{ "NULL", NULL /*&cASN1Null*/, }, /* 5 */
{ "OBJECT", NULL /*&cASN1ObjectId*/, }, /* 6 */
{ "OBJECT_DESCRIPTOR", NULL, }, /* 7 */
{ "EXTERNAL", NULL, }, /* 8 */
{ "REAL", NULL, }, /* 9 */
{ "ENUMERATED", NULL /*&cASN1Enumerated*/, }, /* 10 */
{ "EMBEDDED_PDV", NULL, }, /* 11 */
{ "UTF8STRING", NULL /*&cASN1UTF8String*/, }, /* 12 */
{ "RELATIVE_OID", NULL, }, /* 13 */
{ "[UNIVERSAL 14]", NULL, }, /* 14 */
{ "[UNIVERSAL 15]", NULL, }, /* 15 */
{ "SEQUENCE", NULL /*&cASN1Sequence*/, }, /* 16 */
{ "SET", NULL /*&cASN1Set*/, }, /* 17 */
{ "NUMERICSTRING", NULL /*&cASN1NumericString*/, }, /* 18 */
{ "PRINTABLESTRING", NULL /*&cASN1PrintableString*/, }, /* 19 */
{ "T61STRING", NULL /*&cASN1T61String*/, }, /* 20 */
{ "VIDEOTEXSTRING", NULL /*&cASN1VideotexString*/, }, /* 21 */
{ "IA5STRING", NULL /*&cASN1IA5String*/, }, /* 22 */
{ "UTCTIME", NULL /*&cASN1UTCTime*/, }, /* 23 */
{ "GENERALIZEDTIME", NULL /*&cASN1GeneralizedTime*/, }, /* 24 */
{ "GRAPHICSTRING", NULL /*&cASN1GraphicString*/, }, /* 25 */
{ "ISO64STRING", NULL /*&cASN1ISO64String*/, }, /* 26 */
{ "GENERALSTRING", NULL /*&cASN1GeneralString*/, }, /* 27 */
{ "UNIVERSALSTRING", NULL /*&cASN1UniversalString*/, }, /* 28 */
{ "CHARACTER_STRING", NULL, }, /* 29 */
{ "BMPSTRING", NULL /*&cASN1BMPString*/, }, /* 30 */
};

enum {ossl_asn1_info_size = (sizeof(ossl_asn1_info)/sizeof(ossl_asn1_info[0]))};
Original file line number Diff line number Diff line change
@@ -37,13 +37,16 @@
import org.jruby.truffle.core.cast.NameToJavaStringNodeGen;
import org.jruby.truffle.core.module.ModuleNodes;
import org.jruby.truffle.core.module.ModuleNodesFactory;
import org.jruby.truffle.language.CallStackManager;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyConstant;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.arguments.RubyArguments;
import org.jruby.truffle.language.constants.GetConstantNode;
import org.jruby.truffle.language.constants.LookupConstantNode;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.methods.DeclarationContext;
import org.jruby.truffle.language.objects.MetaClassNode;

@CoreClass("Truffle::CExt")
public class CExtNodes {
@@ -209,6 +212,17 @@ public long long2fix(long num) {

}

@CoreMethod(names = "CLASS_OF", isModuleFunction = true, required = 1)
public abstract static class CLASSOFNode extends CoreMethodArrayArgumentsNode {

@Specialization
public DynamicObject class_of(DynamicObject object,
@Cached("create()") MetaClassNode metaClassNode) {
return metaClassNode.executeMetaClass(object);
}

}

@CoreMethod(names = "rb_long2int", isModuleFunction = true, required = 1)
public abstract static class Long2Int extends CoreMethodArrayArgumentsNode {

@@ -343,4 +357,27 @@ public DynamicObject cextModuleFunction(VirtualFrame frame, DynamicObject module

}

@CoreMethod(names = "caller_frame_visibility", isModuleFunction = true, required = 1)
public abstract static class CallerFrameVisibilityNode extends CoreMethodArrayArgumentsNode {

@TruffleBoundary
@Specialization(guards = "isRubySymbol(visibility)")
public boolean toRubyString(DynamicObject visibility) {
final Frame callerFrame = getContext().getCallStack().getCallerFrameIgnoringSend().getFrame(FrameAccess.MATERIALIZE, true);
final Visibility callerVisibility = DeclarationContext.findVisibility(callerFrame);

switch (visibility.toString()) {
case "private":
return callerVisibility.isPrivate();
case "protected":
return callerVisibility.isProtected();
case "module_function":
return callerVisibility.isModuleFunction();
default:
throw new UnsupportedOperationException();
}
}

}

}
Original file line number Diff line number Diff line change
@@ -24,10 +24,17 @@
@NodeChild(value="object", type=RubyNode.class)
public abstract class MetaClassNode extends RubyNode {

public MetaClassNode() {
}

public MetaClassNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public static MetaClassNode create() {
return MetaClassNodeGen.create(null, null, null);
}

public abstract DynamicObject executeMetaClass(Object value);

@Specialization(guards = "value")
22 changes: 20 additions & 2 deletions truffle/src/main/ruby/core/truffle/cext.rb
Original file line number Diff line number Diff line change
@@ -447,18 +447,36 @@ def rb_undef(mod, name)
end

def rb_attr(ruby_class, name, read, write, ex)
raise 'rb_attr with ex not supported' unless ex.zero?
if ex.zero?
private = false
protected = false
module_function = false
else
private = caller_frame_visibility(:private)
protected = caller_frame_visibility(:protected)
module_function = caller_frame_visibility(:module_function)
end

if read
ruby_class.send :define_method, name do
instance_variable_get(name)
end

ruby_class.send :private, name if private
ruby_class.send :protected, name if protected
ruby_class.send :module_function, name if module_function
end

if write
ruby_class.send :define_method, :"#{name}=" do |value|
setter_name = :"#{name}="

ruby_class.send :define_method, setter_name do |value|
instance_variable_set(name, value)
end

ruby_class.send :private, setter_name if private
ruby_class.send :protected, setter_name if protected
ruby_class.send :module_function, setter_name if module_function
end
end