本文整理了Java中org.jruby.Ruby.getObjectSpace
方法的一些代码示例,展示了Ruby.getObjectSpace
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getObjectSpace
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getObjectSpace
暂无
代码示例来源:origin: org.jruby/jruby-complete
/**
* Will make sure that this object is added to the current object
* space.
*
* @see org.jruby.runtime.ObjectSpace
*/
public void attachToObjectSpace() {
getRuntime().getObjectSpace().add(this);
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Will make sure that this object is added to the current object
* space.
*
* @see org.jruby.runtime.ObjectSpace
*/
public void attachToObjectSpace() {
getRuntime().getObjectSpace().add(this);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Will make sure that this object is added to the current object
* space.
*
* @see org.jruby.runtime.ObjectSpace
*/
public void attachToObjectSpace() {
getRuntime().getObjectSpace().add(this);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Will make sure that this object is added to the current object
* space.
*
* @see org.jruby.runtime.ObjectSpace
*/
public void attachToObjectSpace() {
getRuntime().getObjectSpace().add(this);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(required = 1, module = true, visibility = PRIVATE)
public static IRubyObject undefine_finalizer(IRubyObject recv, IRubyObject obj, Block block) {
recv.getRuntime().getObjectSpace().removeFinalizers(RubyNumeric.fix2long(obj.id()));
return recv;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, module = true, visibility = PRIVATE)
public static IRubyObject undefine_finalizer(IRubyObject recv, IRubyObject arg1, Block block) {
recv.getRuntime().getObjectSpace().removeFinalizers(RubyNumeric.fix2long(arg1.id()));
return recv;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, module = true, visibility = PRIVATE)
public static IRubyObject undefine_finalizer(IRubyObject recv, IRubyObject arg1, Block block) {
recv.getRuntime().getObjectSpace().removeFinalizers(RubyNumeric.fix2long(arg1.id()));
return recv;
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(required = 1, module = true, visibility = PRIVATE)
public static IRubyObject undefine_finalizer(IRubyObject recv, IRubyObject obj, Block block) {
recv.getRuntime().getObjectSpace().removeFinalizers(RubyNumeric.fix2long(obj.id()));
return recv;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* We lazily stand up the object ID since it forces us to stand up
* per-object state for a given object. We also check for ObjectSpace here,
* and normally we do not register a given object ID into ObjectSpace due
* to the high cost associated with constructing the related weakref. Most
* uses of id/object_id will only ever need it to be a unique identifier,
* and the id2ref behavior provided by ObjectSpace is considered internal
* and not generally supported.
*
* @param objectIdAccessor The variable accessor to use for storing the
* generated object ID
* @return The generated object ID
*/
protected synchronized long initObjectId(RubyBasicObject self, VariableAccessor objectIdAccessor) {
Ruby runtime = self.getRuntime();
long id;
if (runtime.isObjectSpaceEnabled()) {
id = runtime.getObjectSpace().createAndRegisterObjectId(self);
} else {
id = ObjectSpace.calculateObjectId(self);
}
// we use a direct path here to avoid frozen checks
setObjectId(realClass, self, objectIdAccessor.getIndex(), id);
return id;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(required = 1, optional = 1, module = true, visibility = PRIVATE)
public static IRubyObject define_finalizer(IRubyObject recv, IRubyObject[] args, Block block) {
Ruby runtime = recv.getRuntime();
IRubyObject finalizer;
if (args.length == 2) {
finalizer = args[1];
if (!finalizer.respondsTo("call")) {
throw runtime.newArgumentError("wrong type argument " + finalizer.getType() + " (should be callable)");
}
} else {
finalizer = runtime.newProc(Block.Type.PROC, block);
}
IRubyObject obj = args[0];
runtime.getObjectSpace().addFinalizer(obj, finalizer);
return runtime.newArray(RubyFixnum.zero(runtime), finalizer);
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(required = 1, optional = 1, module = true, visibility = PRIVATE)
public static IRubyObject define_finalizer(IRubyObject recv, IRubyObject[] args, Block block) {
Ruby runtime = recv.getRuntime();
IRubyObject finalizer;
if (args.length == 2) {
finalizer = args[1];
if (!finalizer.respondsTo("call")) {
throw runtime.newArgumentError("wrong type argument " + finalizer.getType() + " (should be callable)");
}
} else {
finalizer = runtime.newProc(Block.Type.PROC, block);
}
IRubyObject obj = args[0];
runtime.getObjectSpace().addFinalizer(obj, finalizer);
return runtime.newArray(RubyFixnum.zero(runtime), finalizer);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, optional = 1, module = true, visibility = PRIVATE)
public static IRubyObject define_finalizer(IRubyObject recv, IRubyObject[] args, Block block) {
Ruby runtime = recv.getRuntime();
IRubyObject finalizer = null;
if (args.length == 2) {
finalizer = args[1];
if (!finalizer.respondsTo("call")) {
throw runtime.newArgumentError("wrong type argument "
+ finalizer.getType() + " (should be callable)");
}
} else {
finalizer = runtime.newProc(Block.Type.PROC, block);
}
IRubyObject obj = args[0];
runtime.getObjectSpace().addFinalizer(obj, finalizer);
return runtime.newArray(RubyFixnum.zero(runtime), finalizer);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, optional = 1, module = true, visibility = PRIVATE)
public static IRubyObject define_finalizer(IRubyObject recv, IRubyObject[] args, Block block) {
Ruby runtime = recv.getRuntime();
IRubyObject finalizer = null;
if (args.length == 2) {
finalizer = args[1];
if (!finalizer.respondsTo("call")) {
throw runtime.newArgumentError("wrong type argument "
+ finalizer.getType() + " (should be callable)");
}
} else {
finalizer = runtime.newProc(Block.Type.PROC, block);
}
IRubyObject obj = args[0];
runtime.getObjectSpace().addFinalizer(obj, finalizer);
return runtime.newArray(RubyFixnum.zero(runtime), finalizer);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Adds the specified object as a finalizer for this object.
*/
public void addFinalizer(IRubyObject f) {
Finalizer finalizer = (Finalizer)getInternalVariable("__finalizer__");
if (finalizer == null) {
// since this is the first time we're registering a finalizer, we
// must also register this object in ObjectSpace, so that future
// calls to undefine_finalizer, which takes an object ID, can
// locate the object properly. See JRUBY-4839.
long id = getObjectId();
RubyFixnum fixnumId = (RubyFixnum)id();
getRuntime().getObjectSpace().registerObjectId(id, this);
finalizer = new Finalizer(fixnumId);
fastSetInternalVariable("__finalizer__", finalizer);
getRuntime().addFinalizer(finalizer);
}
finalizer.addFinalizer(f);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Adds the specified object as a finalizer for this object.
*/
public void addFinalizer(IRubyObject f) {
Finalizer finalizer = (Finalizer)getInternalVariable("__finalizer__");
if (finalizer == null) {
// since this is the first time we're registering a finalizer, we
// must also register this object in ObjectSpace, so that future
// calls to undefine_finalizer, which takes an object ID, can
// locate the object properly. See JRUBY-4839.
long id = getObjectId();
RubyFixnum fixnumId = (RubyFixnum)id();
getRuntime().getObjectSpace().registerObjectId(id, this);
finalizer = new Finalizer(fixnumId);
fastSetInternalVariable("__finalizer__", finalizer);
getRuntime().addFinalizer(finalizer);
}
finalizer.addFinalizer(f);
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Adds the specified object as a finalizer for this object.
*/
@Override
public void addFinalizer(IRubyObject f) {
Finalizer finalizer = (Finalizer) getInternalVariable("__finalizer__");
if (finalizer == null) {
// since this is the first time we're registering a finalizer, we
// must also register this object in ObjectSpace, so that future
// calls to undefine_finalizer, which takes an object symbol, can
// locate the object properly. See JRUBY-4839.
long id = getObjectId();
IRubyObject fixnumId = id();
getRuntime().getObjectSpace().registerObjectId(id, this);
finalizer = new Finalizer(fixnumId);
setInternalVariable("__finalizer__", finalizer);
getRuntime().addFinalizer(finalizer);
}
finalizer.addFinalizer(f);
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Adds the specified object as a finalizer for this object.
*/
@Override
public void addFinalizer(IRubyObject f) {
Finalizer finalizer = (Finalizer) getInternalVariable("__finalizer__");
if (finalizer == null) {
// since this is the first time we're registering a finalizer, we
// must also register this object in ObjectSpace, so that future
// calls to undefine_finalizer, which takes an object symbol, can
// locate the object properly. See JRUBY-4839.
long id = getObjectId();
IRubyObject fixnumId = id();
getRuntime().getObjectSpace().registerObjectId(id, this);
finalizer = new Finalizer(fixnumId);
setInternalVariable("__finalizer__", finalizer);
getRuntime().addFinalizer(finalizer);
}
finalizer.addFinalizer(f);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "_id2ref", required = 1, module = true, visibility = PRIVATE)
public static IRubyObject id2ref(IRubyObject recv, IRubyObject id) {
final Ruby runtime = id.getRuntime();
if (!(id instanceof RubyFixnum)) {
throw runtime.newTypeError(id, runtime.getFixnum());
}
long longId = ((RubyFixnum) id).getLongValue();
if (longId == 0) {
return runtime.getFalse();
} else if (longId == 20) {
return runtime.getTrue();
} else if (longId == 8) {
return runtime.getNil();
} else if (longId % 2 != 0) {
// odd
return runtime.newFixnum((longId - 1) / 2);
} else {
if (runtime.isObjectSpaceEnabled()) {
IRubyObject object = runtime.getObjectSpace().id2ref(longId);
if (object == null) {
return runtime.getNil();
}
return object;
} else {
runtime.getWarnings().warn("ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable");
throw runtime.newRangeError(String.format("0x%016x is not id value", longId));
}
}
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "_id2ref", required = 1, module = true, visibility = PRIVATE)
public static IRubyObject id2ref(IRubyObject recv, IRubyObject id) {
final Ruby runtime = id.getRuntime();
if (!(id instanceof RubyFixnum)) {
throw runtime.newTypeError(id, runtime.getFixnum());
}
long longId = ((RubyFixnum) id).getLongValue();
if (longId == 0) {
return runtime.getFalse();
} else if (longId == 20) {
return runtime.getTrue();
} else if (longId == 8) {
return runtime.getNil();
} else if (longId % 2 != 0) {
// odd
return runtime.newFixnum((longId - 1) / 2);
} else {
if (runtime.isObjectSpaceEnabled()) {
IRubyObject object = runtime.getObjectSpace().id2ref(longId);
if (object == null) {
return runtime.getNil();
}
return object;
} else {
runtime.getWarnings().warn("ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable");
throw runtime.newRangeError(String.format("0x%016x is not id value", longId));
}
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
} else {
if (runtime.isObjectSpaceEnabled()) {
IRubyObject object = runtime.getObjectSpace().id2ref(longId);
if (object == null) {
return runtime.getNil();
内容来源于网络,如有侵权,请联系作者删除!