Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jruby.ext.ffi.jffi;
 
        super();
    }
    @Override
    public long address(Object parameter) {
        RubyString s = (RubyStringparameter;
        Object existingHandle = s.getFFIHandle();
        if (existingHandle instanceof NativeStringHandle) {
            NativeStringHandle sh = (NativeStringHandleexistingHandle;
            if (s.getByteList() == sh.bl) {
                return sh.memory.getAddress();
            }
        }
        ByteList bl = s.getByteList();
        StringSupport.checkStringSafety(s.getRuntime(), s);
        DirectMemoryIO memory = TransientNativeMemoryIO.allocateAligned(s.getRuntime(), bl.length() + 1, 1, false);
        memory.putZeroTerminatedByteArray(0, bl.getUnsafeBytes(), bl.begin(), bl.length());
        s.setByteListShared();
        s.setFFIHandle(new NativeStringHandle(memorys.getByteList()));
        return memory.getAddress();
    }
    @Override
    public Object object(Object parameter) {
        StringSupport.checkStringSafety(((IRubyObjectparameter).getRuntime(), (IRubyObjectparameter);
        return ((RubyStringparameter).getByteList().unsafeBytes();
    }
    @Override
    public int offset(Object parameter) {
        return ((RubyStringparameter).getByteList().begin();
    }
    @Override
    public int length(Object parameter) {
        return ((RubyStringparameter).getByteList().length();
    }
New to GrepCode? Check out our FAQ X