/** * Retrieve the class with the given name from the Object namespace. * * @param name The name of the class * @return The class */ public RubyClass getClass(String name) { return objectClass.getClass(name); }
/** * Retrieve the class with the given name from the Object namespace. * * @param name The name of the class * @return The class */ public RubyClass getClass(String name) { return objectClass.getClass(name); }
/** * Initializes a new <tt>Type.Array</tt> instance. */ public Array(Ruby runtime, Type componentType, int length) { this(runtime, getTypeClass(runtime).getClass("Array"), componentType, length); }
/** * Initializes a new <tt>Type.Array</tt> instance. */ public Array(Ruby runtime, Type componentType, int length) { this(runtime, getTypeClass(runtime).getClass("Array"), componentType, length); }
/** * Initializes a new <tt>Type.Array</tt> instance. */ public Array(Ruby runtime, Type componentType, int length) { this(runtime, getTypeClass(runtime).getClass("Array"), componentType, length); }
@Deprecated public RaiseException newInvalidEncoding(String message) { return newRaiseException(getClass("Iconv").getClass("InvalidEncoding"), message); }
StructByValue(Ruby runtime, RubyClass structClass, StructLayout structLayout) { super(runtime, runtime.getModule("FFI").getClass("Type").getClass("Struct"), NativeType.STRUCT, structLayout.size, structLayout.alignment); this.structClass = structClass; this.structLayout = structLayout; }
public Symbol(Ruby runtime, DynamicLibrary library, String name, MemoryIO io) { super(runtime, runtime.getModule("FFI").getClass("DynamicLibrary").getClass("Symbol"), io, Long.MAX_VALUE); this.library = library; this.name = name; }
public Symbol(Ruby runtime, DynamicLibrary library, String name, MemoryIO io) { super(runtime, runtime.getModule("FFI").getClass("DynamicLibrary").getClass("Symbol"), io, Long.MAX_VALUE); this.library = library; this.name = name; }
@Override @JRubyMethod(name="initialize", visibility = PRIVATE, required = 3, optional = 1) public final IRubyObject initialize(ThreadContext context, IRubyObject[] args) { IRubyObject type = args[2]; if (!(type instanceof CallbackInfo)) { throw context.runtime.newTypeError(type, context.runtime.getModule("FFI").getClass("Type").getClass("Function")); } init(args, FunctionFieldIO.INSTANCE); return this; } }
private static Mutex getMutexForThreadExclusive(ThreadContext context, RubyClass recv) { Mutex mutex = (Mutex) recv.getConstantNoConstMissing(MUTEX_FOR_THREAD_EXCLUSIVE, false, false); if (mutex != null) return mutex; synchronized (recv) { mutex = (Mutex) recv.getConstantNoConstMissing(MUTEX_FOR_THREAD_EXCLUSIVE, false, false); if (mutex == null) { mutex = Mutex.newInstance(context, context.runtime.getThread().getClass("Mutex"), NULL_ARRAY, Block.NULL_BLOCK); recv.setConstant(MUTEX_FOR_THREAD_EXCLUSIVE, mutex, true); } return mutex; } }
@Override @JRubyMethod(name="initialize", visibility = PRIVATE, required = 3, optional = 1) public final IRubyObject initialize(ThreadContext context, IRubyObject[] args) { IRubyObject type = args[2]; if (!(type instanceof CallbackInfo)) { throw context.runtime.newTypeError(type, context.runtime.getModule("FFI").getClass("Type").getClass("Function")); } init(args, FunctionFieldIO.INSTANCE); return this; } }
@Override @JRubyMethod(name="initialize", visibility = PRIVATE, required = 3, optional = 1) public final IRubyObject initialize(ThreadContext context, IRubyObject[] args) { IRubyObject type = args[2]; if (!(type instanceof Type.Array)) { throw context.runtime.newTypeError(type, context.runtime.getModule("FFI").getClass("Type").getClass("Array")); } init(args, new ArrayFieldIO((Type.Array) type)); return this; } }
@Override @JRubyMethod(name="initialize", visibility = PRIVATE, required = 3, optional = 1) public final IRubyObject initialize(ThreadContext context, IRubyObject[] args) { IRubyObject type = args[2]; if (!(type instanceof Type.Array)) { throw context.runtime.newTypeError(type, context.runtime.getModule("FFI").getClass("Type").getClass("Array")); } init(args, new ArrayFieldIO((Type.Array) type)); return this; } }
static RaiseException newGzipFileError(Ruby runtime, String klass, String message) { RubyClass errorClass = runtime.getModule("Zlib").getClass("GzipFile").getClass(klass); RubyException excn = RubyException.newException(runtime, errorClass, message); // TODO: not yet supported. rewrite GzipReader/Writer with Inflate/Deflate? excn.setInstanceVariable("@input", runtime.getNil()); return excn.toThrowable(); }
@Override @JRubyMethod(name="initialize", visibility = PRIVATE, required = 3, optional = 1) public IRubyObject initialize(ThreadContext context, IRubyObject[] args) { IRubyObject type = args[2]; if (!(type instanceof StructByValue)) { throw context.runtime.newTypeError(type, context.runtime.getModule("FFI").getClass("Type").getClass("Struct")); } init(args, new InnerStructFieldIO((StructByValue) type)); return this; } }
private RaiseException newRefError(String message) { Ruby runtime = getRuntime(); ThreadContext context = runtime.getCurrentContext(); RubyException exception = (RubyException)runtime.getClass("WeakRef").getClass("RefError").newInstance(context, new IRubyObject[] {runtime.newString(message)}, Block.NULL_BLOCK); RaiseException re = new RaiseException(exception); return re; } }
@JRubyMethod(name = "unscan") public IRubyObject unscan() { check(); Ruby runtime = getRuntime(); if (!isMatched()) { RubyClass errorClass = runtime.getClass("StringScanner").getClass("Error"); throw RaiseException.from(runtime, errorClass, "unscan failed: previous match had failed"); } pos = lastPos; clearMatched(); return this; }
@JRubyMethod(name = "unscan") public IRubyObject unscan() { check(); Ruby runtime = getRuntime(); if (!isMatched()) { RubyClass errorClass = runtime.getClass("StringScanner").getClass("Error"); throw RaiseException.from(runtime, errorClass, "unscan failed: previous match had failed"); } pos = lastPos; clearMatched(); return this; }
static RaiseException newGzipFileError(Ruby runtime, String klass, String message) { RubyClass errorClass = runtime.getModule("Zlib").getClass("GzipFile").getClass(klass); RubyException excn = RubyException.newException(runtime, errorClass, message); if (runtime.is1_9()) { // TODO: not yet supported. rewrite GzipReader/Writer with Inflate/Deflate? excn.setInstanceVariable("@input", runtime.getNil()); } return new RaiseException(excn, true); }