com.apple.jobjc.Invoke.MsgSend Java Examples

The following examples show how to use com.apple.jobjc.Invoke.MsgSend. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubclassingTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #2
Source File: SubclassingTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #3
Source File: SubclassingTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #4
Source File: SubclassingTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void testDoubleIntLongMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final int arg1 = 3;
    final long arg2 = 4;
    final float arg3 = 5.5F;
    final double expected = 12.5D;

    final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
            SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
    sel.init(ctx, instObj);
    SIntCoder.INST.push(ctx, arg1);
    SLongLongCoder.INST.push(ctx, arg2);
    FloatCoder.INST.push(ctx, arg3);
    sel.invoke(ctx);
    final double ret = DoubleCoder.INST.pop(ctx);
    assertEquals(expected, ret);
}
 
Example #5
Source File: SELTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void testGetBlackColor() throws Throwable {
    final MacOSXFramework appKit = TestUtils.getAppKit();
    final NSClass<? extends ID> clazz = UnsafeRuntimeAccess.getNSClass(appKit, "NSColor");
    final MsgSend sel = UnsafeRuntimeAccess.createMsgSend(clazz, "redColor", PointerCoder.INST);

    sel.init(nativeBuffer, clazz);
    sel.invoke(nativeBuffer);

    final long blackColorPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    String dscr = UnsafeRuntimeAccess.getDescriptionForPtr(blackColorPtr);

    System.out.println("0x" + Long.toHexString(blackColorPtr) + ": " + dscr);
    assertEquals("NSCalibratedRGBColorSpace 1 0 0 1", dscr);
}
 
Example #6
Source File: SubclassingTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void testVoidVoidMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    assertEquals(0, instObj.myMethodHits);
    MsgSend sel = new MsgSend(runtime, "myMethod", VoidCoder.INST);
    sel.init(ctx, instObj);
    sel.invoke(ctx);
    assertEquals(1, instObj.myMethodHits);
}
 
Example #7
Source File: SubclassingTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testVoidIntMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    MsgSend sel2 = new MsgSend(runtime, "intMethod", SIntCoder.INST);
    sel2.init(ctx, instObj);
    sel2.invoke(ctx);
    int ret = SIntCoder.INST.popInt(ctx);
    assertEquals(3, ret);
}
 
Example #8
Source File: SELTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testGetBlackColor() throws Throwable {
    final MacOSXFramework appKit = TestUtils.getAppKit();
    final NSClass<? extends ID> clazz = UnsafeRuntimeAccess.getNSClass(appKit, "NSColor");
    final MsgSend sel = UnsafeRuntimeAccess.createMsgSend(clazz, "redColor", PointerCoder.INST);

    sel.init(nativeBuffer, clazz);
    sel.invoke(nativeBuffer);

    final long blackColorPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    String dscr = UnsafeRuntimeAccess.getDescriptionForPtr(blackColorPtr);

    System.out.println("0x" + Long.toHexString(blackColorPtr) + ": " + dscr);
    assertEquals("NSCalibratedRGBColorSpace 1 0 0 1", dscr);
}
 
Example #9
Source File: SubclassingTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void testVoidVoidMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    assertEquals(0, instObj.myMethodHits);
    MsgSend sel = new MsgSend(runtime, "myMethod", VoidCoder.INST);
    sel.init(ctx, instObj);
    sel.invoke(ctx);
    assertEquals(1, instObj.myMethodHits);
}
 
Example #10
Source File: SELTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void testGetBlackColor() throws Throwable {
    final MacOSXFramework appKit = TestUtils.getAppKit();
    final NSClass<? extends ID> clazz = UnsafeRuntimeAccess.getNSClass(appKit, "NSColor");
    final MsgSend sel = UnsafeRuntimeAccess.createMsgSend(clazz, "redColor", PointerCoder.INST);

    sel.init(nativeBuffer, clazz);
    sel.invoke(nativeBuffer);

    final long blackColorPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    String dscr = UnsafeRuntimeAccess.getDescriptionForPtr(blackColorPtr);

    System.out.println("0x" + Long.toHexString(blackColorPtr) + ": " + dscr);
    assertEquals("NSCalibratedRGBColorSpace 1 0 0 1", dscr);
}
 
Example #11
Source File: CategoryClassClassFile.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    Set<String> written = new HashSet<String>();
    for(final Method method : this.clazz.classMethods)
        if(written.add(method.name))
            FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this");
        else
            System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name);
}
 
Example #12
Source File: JObjCClassClassFile.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    Set<String> written = new HashSet<String>();
    for(final Method method : this.clazz.classMethods)
        if(written.add(method.name))
            FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this");
        else
            System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name);
}
 
Example #13
Source File: SubclassingTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testVoidIntMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    MsgSend sel2 = new MsgSend(runtime, "intMethod", SIntCoder.INST);
    sel2.init(ctx, instObj);
    sel2.invoke(ctx);
    int ret = SIntCoder.INST.popInt(ctx);
    assertEquals(3, ret);
}
 
Example #14
Source File: SubclassingTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testNSStringNSStringMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final NSString orig = Utils.get().strings().nsString("foobar");
    final String expected = "foobarfoobarfoobar";

    final MsgSend sel = new MsgSend(runtime, "stringTimesThree:", IDCoder.INST, IDCoder.INST);
    sel.init(ctx, instObj);
    IDCoder.INST.push(ctx, orig);
    sel.invoke(ctx);
    NSString ret = (NSString) IDCoder.INST.pop(ctx);
    assertEquals(expected, Utils.get().strings().javaString(ret));
}
 
Example #15
Source File: SubclassingTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example #16
Source File: SubclassingTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void testNSStringNSStringMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final NSString orig = Utils.get().strings().nsString("foobar");
    final String expected = "foobarfoobarfoobar";

    final MsgSend sel = new MsgSend(runtime, "stringTimesThree:", IDCoder.INST, IDCoder.INST);
    sel.init(ctx, instObj);
    IDCoder.INST.push(ctx, orig);
    sel.invoke(ctx);
    NSString ret = (NSString) IDCoder.INST.pop(ctx);
    assertEquals(expected, Utils.get().strings().javaString(ret));
}
 
Example #17
Source File: SubclassingTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void testVoidIntMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    MsgSend sel2 = new MsgSend(runtime, "intMethod", SIntCoder.INST);
    sel2.init(ctx, instObj);
    sel2.invoke(ctx);
    int ret = SIntCoder.INST.popInt(ctx);
    assertEquals(3, ret);
}
 
Example #18
Source File: SubclassingTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example #19
Source File: CategoryClassClassFile.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    Set<String> written = new HashSet<String>();
    for(final Method method : this.clazz.classMethods)
        if(written.add(method.name))
            FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this");
        else
            System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name);
}
 
Example #20
Source File: JObjCClassClassFile.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    Set<String> written = new HashSet<String>();
    for(final Method method : this.clazz.classMethods)
        if(written.add(method.name))
            FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this");
        else
            System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name);
}
 
Example #21
Source File: JObjCClassFile.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    Set<String> written = new HashSet<String>();
    for(final Method method : this.clazz.instanceMethods)
        if(written.add(method.name))
            FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this");
        else
            System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name);
}
 
Example #22
Source File: CategoryClassClassFile.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    Set<String> written = new HashSet<String>();
    for(final Method method : this.clazz.classMethods)
        if(written.add(method.name))
            FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this");
        else
            System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name);
}
 
Example #23
Source File: SubclassingTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void testNSStringNSStringMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    final NSString orig = Utils.get().strings().nsString("foobar");
    final String expected = "foobarfoobarfoobar";

    final MsgSend sel = new MsgSend(runtime, "stringTimesThree:", IDCoder.INST, IDCoder.INST);
    sel.init(ctx, instObj);
    IDCoder.INST.push(ctx, orig);
    sel.invoke(ctx);
    NSString ret = (NSString) IDCoder.INST.pop(ctx);
    assertEquals(expected, Utils.get().strings().javaString(ret));
}
 
Example #24
Source File: SubclassingTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void testStructStructMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);

    MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
    sel2.init(ctx, instObj);
    p.getCoder().push(ctx, p);
    sel2.invoke(ctx, p);

    assertEquals(6.0, p.x());
}
 
Example #25
Source File: SubclassingTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void testVoidIntMethod(){
    final MyObject instObj = new MyObjectClass(runtime).alloc();

    MsgSend sel2 = new MsgSend(runtime, "intMethod", SIntCoder.INST);
    sel2.init(ctx, instObj);
    sel2.invoke(ctx);
    int ret = SIntCoder.INST.popInt(ctx);
    assertEquals(3, ret);
}
 
Example #26
Source File: JObjCClassClassFile.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    Set<String> written = new HashSet<String>();
    for(final Method method : this.clazz.classMethods)
        if(written.add(method.name))
            FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this");
        else
            System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name);
}
 
Example #27
Source File: SELTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void testGetBlackColor() throws Throwable {
    final MacOSXFramework appKit = TestUtils.getAppKit();
    final NSClass<? extends ID> clazz = UnsafeRuntimeAccess.getNSClass(appKit, "NSColor");
    final MsgSend sel = UnsafeRuntimeAccess.createMsgSend(clazz, "redColor", PointerCoder.INST);

    sel.init(nativeBuffer, clazz);
    sel.invoke(nativeBuffer);

    final long blackColorPtr = PrimitivePointerCoder.INST.pop(nativeBuffer);
    String dscr = UnsafeRuntimeAccess.getDescriptionForPtr(blackColorPtr);

    System.out.println("0x" + Long.toHexString(blackColorPtr) + ": " + dscr);
    assertEquals("NSCalibratedRGBColorSpace 1 0 0 1", dscr);
}
 
Example #28
Source File: JObjCClassFile.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    Set<String> written = new HashSet<String>();
    for(final Method method : this.clazz.instanceMethods)
        if(written.add(method.name))
            FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this");
        else
            System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name);
}
 
Example #29
Source File: JObjCClassClassFile.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    Set<String> written = new HashSet<String>();
    for(final Method method : this.clazz.classMethods)
        if(written.add(method.name))
            FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this");
        else
            System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name);
}
 
Example #30
Source File: JObjCClassFile.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    Set<String> written = new HashSet<String>();
    for(final Method method : this.clazz.instanceMethods)
        if(written.add(method.name))
            FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this");
        else
            System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name);
}