7181501: Add some GenerateNativeHeader annotations and misc Mac adjustments to makefiles

Reviewed-by: ohair
This commit is contained in:
Erik Joelsson 2012-07-03 16:01:59 -07:00
parent f51d607e9f
commit d85c0b6f6f
23 changed files with 157 additions and 8 deletions

@ -140,8 +140,16 @@
<!-- Compile PrimitiveCoder first to work around javac bug. --> <!-- Compile PrimitiveCoder first to work around javac bug. -->
<javac srcdir="${core.src}" destdir="${core.bin}" source="1.5" target="1.5" debug="${compile.debug}" <javac srcdir="${core.src}" destdir="${core.bin}" source="1.5" target="1.5" debug="${compile.debug}"
includes="**/PrimitiveCoder.java" includes="**/PrimitiveCoder.java"
includeantruntime="false" /> includeantruntime="false">
<javac srcdir="${core.src}" destdir="${core.bin}" source="1.5" target="1.5" debug="${compile.debug}" includeantruntime="false" /> <classpath>
<path location="${obj}/../langtools/dist/lib/classes.jar"/>
</classpath>
</javac>
<javac srcdir="${core.src}" destdir="${core.bin}" source="1.5" target="1.5" debug="${compile.debug}" includeantruntime="false">
<classpath>
<path location="${obj}/../langtools/dist/lib/classes.jar"/>
</classpath>
</javac>
<exec executable="/usr/bin/perl" outputproperty="core.classes" failonerror="true"> <exec executable="/usr/bin/perl" outputproperty="core.classes" failonerror="true">
<arg value="${src}/extract_classes.pl"/> <arg value="${src}/extract_classes.pl"/>

@ -2,7 +2,7 @@
{- {-
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011,2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -196,6 +196,8 @@ sizeofRet nt =
c2java ntype = c2java ntype =
unlines [ unlines [
"// native " ++ ntypeS ++ " -> java " ++ jprimS, "// native " ++ ntypeS ++ " -> java " ++ jprimS,
"/* No native methods here, but the constants are needed in the supporting JNI code */",
"@GenerateNativeHeader",
"public static final class " ++ className ++ " extends PrimitiveCoder<" ++ jclassS ++ ">{", "public static final class " ++ className ++ " extends PrimitiveCoder<" ++ jclassS ++ ">{",
"\tpublic static final " ++ className ++ " INST = new " ++ className ++ "();", "\tpublic static final " ++ className ++ " INST = new " ++ className ++ "();",
"\tpublic " ++ className ++ "(){ super("++ffitypeVal ntype++", \"" ++ [encoding ntype] ++ "\", "++jclassS++".class, "++jprimS++".class); }", "\tpublic " ++ className ++ "(){ super("++ffitypeVal ntype++", \"" ++ [encoding ntype] ++ "\", "++jclassS++".class, "++jprimS++".class); }",
@ -246,10 +248,13 @@ main = do
putStrLn "package com.apple.jobjc;" putStrLn "package com.apple.jobjc;"
putStrLn "import com.apple.jobjc.JObjCRuntime.Width;" putStrLn "import com.apple.jobjc.JObjCRuntime.Width;"
putStrLn "import javax.tools.annotation.GenerateNativeHeader;"
putStrLn "// Auto generated by PrimitiveCoder.hs" putStrLn "// Auto generated by PrimitiveCoder.hs"
putStrLn "// Do not edit by hand." putStrLn "// Do not edit by hand."
putStrLn "/* No native methods here, but the constants are needed in the supporting JNI code */"
putStrLn "@GenerateNativeHeader"
putStrLn "public abstract class PrimitiveCoder<T> extends Coder<T>{" putStrLn "public abstract class PrimitiveCoder<T> extends Coder<T>{"
putStrLn "\tpublic PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){" putStrLn "\tpublic PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){"

@ -24,6 +24,10 @@
*/ */
package com.apple.jobjc; package com.apple.jobjc;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public class CFType extends Pointer<Void> { public class CFType extends Pointer<Void> {
protected CFType(long ptr) { super(ptr); } protected CFType(long ptr) { super(ptr); }
protected CFType(Pointer<?> ptr) { super(ptr.ptr); } protected CFType(Pointer<?> ptr) { super(ptr.ptr); }

@ -35,6 +35,7 @@ import com.apple.jobjc.PrimitiveCoder.SCharCoder;
import com.apple.jobjc.PrimitiveCoder.SIntCoder; import com.apple.jobjc.PrimitiveCoder.SIntCoder;
import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; import com.apple.jobjc.PrimitiveCoder.SLongLongCoder;
import com.apple.jobjc.PrimitiveCoder.SShortCoder; import com.apple.jobjc.PrimitiveCoder.SShortCoder;
import javax.tools.annotation.GenerateNativeHeader;
public abstract class Coder<T> { public abstract class Coder<T> {
private static native long getNativeFFITypePtrForCode(final int code); private static native long getNativeFFITypePtrForCode(final int code);
@ -142,6 +143,8 @@ public abstract class Coder<T> {
// //
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class VoidCoder extends Coder<Object>{ public static final class VoidCoder extends Coder<Object>{
public static final VoidCoder INST = new VoidCoder(); public static final VoidCoder INST = new VoidCoder();
public VoidCoder(){ super(FFI_VOID, "v", Void.class, void.class); } public VoidCoder(){ super(FFI_VOID, "v", Void.class, void.class); }
@ -150,6 +153,8 @@ public abstract class Coder<T> {
@Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Trying to push a Void."); } @Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Trying to push a Void."); }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class UnknownCoder extends Coder<Object> { public static final class UnknownCoder extends Coder<Object> {
public static final UnknownCoder INST = new UnknownCoder(); public static final UnknownCoder INST = new UnknownCoder();
public UnknownCoder(){ super(-1, "?", null, null); } public UnknownCoder(){ super(-1, "?", null, null); }
@ -158,6 +163,8 @@ public abstract class Coder<T> {
@Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Coder not implemented"); } @Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Coder not implemented"); }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class PrimitivePointerCoder extends Coder<Long> { public static final class PrimitivePointerCoder extends Coder<Long> {
public static final PrimitivePointerCoder INST = new PrimitivePointerCoder(); public static final PrimitivePointerCoder INST = new PrimitivePointerCoder();
public PrimitivePointerCoder(){ super(Coder.FFI_PTR, "^?", Long.class, long.class); } public PrimitivePointerCoder(){ super(Coder.FFI_PTR, "^?", Long.class, long.class); }
@ -187,6 +194,8 @@ public abstract class Coder<T> {
@Override public void push(JObjCRuntime runtime, long addr, Long x) { push(runtime, addr, (long) x); } @Override public void push(JObjCRuntime runtime, long addr, Long x) { push(runtime, addr, (long) x); }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class PointerCoder extends Coder<Pointer> { public static final class PointerCoder extends Coder<Pointer> {
public static final PointerCoder INST = new PointerCoder(); public static final PointerCoder INST = new PointerCoder();
public PointerCoder(){ super(FFI_PTR, "^?", Pointer.class); } public PointerCoder(){ super(FFI_PTR, "^?", Pointer.class); }
@ -200,6 +209,8 @@ public abstract class Coder<T> {
} }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class SELCoder extends Coder<SEL> { public static final class SELCoder extends Coder<SEL> {
public static final SELCoder INST = new SELCoder(); public static final SELCoder INST = new SELCoder();
public SELCoder(){ super(FFI_PTR, ":", SEL.class); } public SELCoder(){ super(FFI_PTR, ":", SEL.class); }
@ -213,6 +224,8 @@ public abstract class Coder<T> {
} }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static abstract class StructCoder extends Coder<Struct> { public static abstract class StructCoder extends Coder<Struct> {
private final FFIType ffiType; private final FFIType ffiType;
final int sizeof; final int sizeof;
@ -254,6 +267,8 @@ public abstract class Coder<T> {
} }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class IDCoder extends Coder<ID>{ public static final class IDCoder extends Coder<ID>{
public static final IDCoder INST = new IDCoder(); public static final IDCoder INST = new IDCoder();
public IDCoder(){ super(FFI_PTR, "@", ID.class); } public IDCoder(){ super(FFI_PTR, "@", ID.class); }
@ -272,6 +287,8 @@ public abstract class Coder<T> {
} }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class NSClassCoder extends Coder<NSClass>{ public static final class NSClassCoder extends Coder<NSClass>{
public static final NSClassCoder INST = new NSClassCoder(); public static final NSClassCoder INST = new NSClassCoder();
public NSClassCoder(){ super(FFI_PTR, "#", NSClass.class); } public NSClassCoder(){ super(FFI_PTR, "#", NSClass.class); }

@ -26,6 +26,10 @@ package com.apple.jobjc;
import com.apple.jobjc.Coder.PrimitivePointerCoder; import com.apple.jobjc.Coder.PrimitivePointerCoder;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
class FFIType{ class FFIType{
private static native void makeFFIType(long ffi_type_buf, long elements_buf); private static native void makeFFIType(long ffi_type_buf, long elements_buf);
private static native int getFFITypeSizeof(); private static native int getFFITypeSizeof();

@ -24,6 +24,10 @@
*/ */
package com.apple.jobjc; package com.apple.jobjc;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public class Function { public class Function {
private static native long getFxnPtrForFunctionName(final String functionName); private static native long getFxnPtrForFunctionName(final String functionName);
private static native long getFxnPtrForFunctionNameAndLib(final long libPtr, final String functionName); private static native long getFxnPtrForFunctionNameAndLib(final long libPtr, final String functionName);

@ -29,6 +29,10 @@ import java.lang.reflect.Constructor;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public class ID extends Pointer<Void>{ public class ID extends Pointer<Void>{
static native String getNativeDescription(final long objPtr); static native String getNativeDescription(final long objPtr);

@ -30,12 +30,18 @@ import com.apple.jobjc.Coder.PrimitivePointerCoder;
import com.apple.jobjc.Coder.SELCoder; import com.apple.jobjc.Coder.SELCoder;
import com.apple.jobjc.Coder.StructCoder; import com.apple.jobjc.Coder.StructCoder;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public abstract class Invoke { public abstract class Invoke {
public abstract void invoke(NativeArgumentBuffer argBuf); public abstract void invoke(NativeArgumentBuffer argBuf);
public abstract void invoke(NativeArgumentBuffer buffer, Struct retvalStruct); public abstract void invoke(NativeArgumentBuffer buffer, Struct retvalStruct);
// //
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class FunCall extends Invoke{ public static final class FunCall extends Invoke{
static native void invoke(long cifPtr, long fxnPtr, long retValPtr, long argsPtr); static native void invoke(long cifPtr, long fxnPtr, long retValPtr, long argsPtr);
@ -72,6 +78,8 @@ public abstract class Invoke {
} }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class MsgSend extends Invoke{ public static final class MsgSend extends Invoke{
static{ System.load("/usr/lib/libobjc.dylib"); } static{ System.load("/usr/lib/libobjc.dylib"); }
@ -157,6 +165,8 @@ public abstract class Invoke {
} }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class MsgSendSuper extends Invoke{ public static final class MsgSendSuper extends Invoke{
static{ System.load("/usr/lib/libobjc.dylib"); } static{ System.load("/usr/lib/libobjc.dylib"); }

@ -31,10 +31,16 @@ import java.util.List;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public final class JObjCRuntime { public final class JObjCRuntime {
static { System.loadLibrary("JObjC"); } static { System.loadLibrary("JObjC"); }
@GenerateNativeHeader
public static enum Arch{ ppc, i386, x86_64 }; public static enum Arch{ ppc, i386, x86_64 };
@GenerateNativeHeader
public static enum Width{ W32, W64 }; public static enum Width{ W32, W64 };
public static final Arch ARCH = getArch(); public static final Arch ARCH = getArch();

@ -25,6 +25,10 @@
package com.apple.jobjc; package com.apple.jobjc;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public class MacOSXFramework { public class MacOSXFramework {
private static native long retainFramework(final String frameworkName); private static native long retainFramework(final String frameworkName);
private static native void releaseFramework(final long frameworkPtr); private static native void releaseFramework(final long frameworkPtr);

@ -27,7 +27,13 @@ package com.apple.jobjc;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public class NSClass<T extends ID> extends ID { public class NSClass<T extends ID> extends ID {
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static class NSClassNotFoundException extends RuntimeException{ public static class NSClassNotFoundException extends RuntimeException{
public NSClassNotFoundException(String m){ super(m); } public NSClassNotFoundException(String m){ super(m); }
public NSClassNotFoundException(String m, Throwable cause){ super(m, cause); } public NSClassNotFoundException(String m, Throwable cause){ super(m, cause); }

@ -28,6 +28,10 @@ import java.nio.ByteOrder;
import com.apple.jobjc.Coder.PrimitivePointerCoder; import com.apple.jobjc.Coder.PrimitivePointerCoder;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public final class NativeArgumentBuffer{ public final class NativeArgumentBuffer{
private static final ThreadLocal<NativeArgumentBuffer> threadLocal = new ThreadLocal<NativeArgumentBuffer>(); private static final ThreadLocal<NativeArgumentBuffer> threadLocal = new ThreadLocal<NativeArgumentBuffer>();

@ -27,9 +27,13 @@ package com.apple.jobjc;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import javax.tools.annotation.GenerateNativeHeader;
/** /**
* A wrapper around a direct ByteBuffer and its native pointer. For documentation, @see java.nio.ByteBuffer * A wrapper around a direct ByteBuffer and its native pointer. For documentation, @see java.nio.ByteBuffer
*/ */
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public class NativeBuffer { public class NativeBuffer {
static native long getPtrOfBuffer(final ByteBuffer byteBuffer); static native long getPtrOfBuffer(final ByteBuffer byteBuffer);

@ -24,6 +24,10 @@
*/ */
package com.apple.jobjc; package com.apple.jobjc;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public abstract class NativeObjectLifecycleManager { public abstract class NativeObjectLifecycleManager {
private static native void retainNativeObject(final long ptr); private static native void retainNativeObject(final long ptr);
private static native void releaseNativeObject(final long ptr); private static native void releaseNativeObject(final long ptr);
@ -33,6 +37,8 @@ public abstract class NativeObjectLifecycleManager {
abstract void end(final long ptr); abstract void end(final long ptr);
boolean shouldPreRetain() { return false; } boolean shouldPreRetain() { return false; }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static class CFRetainRelease extends NativeObjectLifecycleManager { public static class CFRetainRelease extends NativeObjectLifecycleManager {
public static final NativeObjectLifecycleManager INST = new CFRetainRelease(); public static final NativeObjectLifecycleManager INST = new CFRetainRelease();
@Override void begin(final long ptr) { retainNativeObject(ptr); } @Override void begin(final long ptr) { retainNativeObject(ptr); }
@ -40,12 +46,16 @@ public abstract class NativeObjectLifecycleManager {
@Override boolean shouldPreRetain() { return true; } @Override boolean shouldPreRetain() { return true; }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static class Free extends NativeObjectLifecycleManager { public static class Free extends NativeObjectLifecycleManager {
public static final NativeObjectLifecycleManager INST = new Free(); public static final NativeObjectLifecycleManager INST = new Free();
@Override void begin(final long ptr) { } @Override void begin(final long ptr) { }
@Override void end(final long ptr) { freeNativeObject(ptr); } @Override void end(final long ptr) { freeNativeObject(ptr); }
} }
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static class Nothing extends NativeObjectLifecycleManager { public static class Nothing extends NativeObjectLifecycleManager {
public static final NativeObjectLifecycleManager INST = new Nothing(); public static final NativeObjectLifecycleManager INST = new Nothing();
@Override void begin(final long ptr) { } @Override void begin(final long ptr) { }

@ -24,6 +24,10 @@
*/ */
package com.apple.jobjc; package com.apple.jobjc;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public class Opaque extends Pointer<Void> { public class Opaque extends Pointer<Void> {
protected Opaque(long ptr) { super(ptr); } protected Opaque(long ptr) { super(ptr); }
protected Opaque(Pointer<?> ptr) { super(ptr.ptr); } protected Opaque(Pointer<?> ptr) { super(ptr.ptr); }

@ -24,6 +24,10 @@
*/ */
package com.apple.jobjc; package com.apple.jobjc;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public class Pointer <T> implements Comparable<Pointer<T>>{ public class Pointer <T> implements Comparable<Pointer<T>>{
long ptr; long ptr;

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011,2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,8 +24,11 @@
*/ */
package com.apple.jobjc; package com.apple.jobjc;
import com.apple.jobjc.JObjCRuntime.Width; import com.apple.jobjc.JObjCRuntime.Width;
import javax.tools.annotation.GenerateNativeHeader;
// Auto generated by PrimitiveCoder.hs // Auto generated by PrimitiveCoder.hs
// Do not edit by hand. // Do not edit by hand.
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public abstract class PrimitiveCoder<T> extends Coder<T>{ public abstract class PrimitiveCoder<T> extends Coder<T>{
public PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){ public PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){
super(ffiTypeCode, objCEncoding, jclass, jprim); super(ffiTypeCode, objCEncoding, jclass, jprim);
@ -127,6 +130,8 @@ public abstract class PrimitiveCoder<T> extends Coder<T>{
// native BOOL -> java boolean // native BOOL -> java boolean
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class BoolCoder extends PrimitiveCoder<Boolean>{ public static final class BoolCoder extends PrimitiveCoder<Boolean>{
public static final BoolCoder INST = new BoolCoder(); public static final BoolCoder INST = new BoolCoder();
public BoolCoder(){ super(FFI_SINT8, "B", Boolean.class, boolean.class); } public BoolCoder(){ super(FFI_SINT8, "B", Boolean.class, boolean.class); }
@ -170,6 +175,8 @@ public static final class BoolCoder extends PrimitiveCoder<Boolean>{
} }
// native schar -> java byte // native schar -> java byte
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class SCharCoder extends PrimitiveCoder<Byte>{ public static final class SCharCoder extends PrimitiveCoder<Byte>{
public static final SCharCoder INST = new SCharCoder(); public static final SCharCoder INST = new SCharCoder();
public SCharCoder(){ super(FFI_SINT8, "c", Byte.class, byte.class); } public SCharCoder(){ super(FFI_SINT8, "c", Byte.class, byte.class); }
@ -213,6 +220,8 @@ public static final class SCharCoder extends PrimitiveCoder<Byte>{
} }
// native uchar -> java byte // native uchar -> java byte
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class UCharCoder extends PrimitiveCoder<Byte>{ public static final class UCharCoder extends PrimitiveCoder<Byte>{
public static final UCharCoder INST = new UCharCoder(); public static final UCharCoder INST = new UCharCoder();
public UCharCoder(){ super(FFI_UINT8, "C", Byte.class, byte.class); } public UCharCoder(){ super(FFI_UINT8, "C", Byte.class, byte.class); }
@ -256,6 +265,8 @@ public static final class UCharCoder extends PrimitiveCoder<Byte>{
} }
// native sshort -> java short // native sshort -> java short
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class SShortCoder extends PrimitiveCoder<Short>{ public static final class SShortCoder extends PrimitiveCoder<Short>{
public static final SShortCoder INST = new SShortCoder(); public static final SShortCoder INST = new SShortCoder();
public SShortCoder(){ super(FFI_SINT16, "s", Short.class, short.class); } public SShortCoder(){ super(FFI_SINT16, "s", Short.class, short.class); }
@ -299,6 +310,8 @@ public static final class SShortCoder extends PrimitiveCoder<Short>{
} }
// native ushort -> java short // native ushort -> java short
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class UShortCoder extends PrimitiveCoder<Short>{ public static final class UShortCoder extends PrimitiveCoder<Short>{
public static final UShortCoder INST = new UShortCoder(); public static final UShortCoder INST = new UShortCoder();
public UShortCoder(){ super(FFI_UINT16, "S", Short.class, short.class); } public UShortCoder(){ super(FFI_UINT16, "S", Short.class, short.class); }
@ -342,6 +355,8 @@ public static final class UShortCoder extends PrimitiveCoder<Short>{
} }
// native sint -> java int // native sint -> java int
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class SIntCoder extends PrimitiveCoder<Integer>{ public static final class SIntCoder extends PrimitiveCoder<Integer>{
public static final SIntCoder INST = new SIntCoder(); public static final SIntCoder INST = new SIntCoder();
public SIntCoder(){ super(FFI_SINT32, "i", Integer.class, int.class); } public SIntCoder(){ super(FFI_SINT32, "i", Integer.class, int.class); }
@ -385,6 +400,8 @@ public static final class SIntCoder extends PrimitiveCoder<Integer>{
} }
// native uint -> java int // native uint -> java int
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class UIntCoder extends PrimitiveCoder<Integer>{ public static final class UIntCoder extends PrimitiveCoder<Integer>{
public static final UIntCoder INST = new UIntCoder(); public static final UIntCoder INST = new UIntCoder();
public UIntCoder(){ super(FFI_UINT32, "I", Integer.class, int.class); } public UIntCoder(){ super(FFI_UINT32, "I", Integer.class, int.class); }
@ -428,6 +445,8 @@ public static final class UIntCoder extends PrimitiveCoder<Integer>{
} }
// native slong -> java long // native slong -> java long
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class SLongCoder extends PrimitiveCoder<Long>{ public static final class SLongCoder extends PrimitiveCoder<Long>{
public static final SLongCoder INST = new SLongCoder(); public static final SLongCoder INST = new SLongCoder();
public SLongCoder(){ super((JObjCRuntime.IS64 ? (FFI_SINT64) : (FFI_SINT32)), "l", Long.class, long.class); } public SLongCoder(){ super((JObjCRuntime.IS64 ? (FFI_SINT64) : (FFI_SINT32)), "l", Long.class, long.class); }
@ -477,6 +496,8 @@ public static final class SLongCoder extends PrimitiveCoder<Long>{
} }
// native ulong -> java long // native ulong -> java long
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class ULongCoder extends PrimitiveCoder<Long>{ public static final class ULongCoder extends PrimitiveCoder<Long>{
public static final ULongCoder INST = new ULongCoder(); public static final ULongCoder INST = new ULongCoder();
public ULongCoder(){ super((JObjCRuntime.IS64 ? (FFI_UINT64) : (FFI_UINT32)), "L", Long.class, long.class); } public ULongCoder(){ super((JObjCRuntime.IS64 ? (FFI_UINT64) : (FFI_UINT32)), "L", Long.class, long.class); }
@ -526,6 +547,8 @@ public static final class ULongCoder extends PrimitiveCoder<Long>{
} }
// native slonglong -> java long // native slonglong -> java long
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class SLongLongCoder extends PrimitiveCoder<Long>{ public static final class SLongLongCoder extends PrimitiveCoder<Long>{
public static final SLongLongCoder INST = new SLongLongCoder(); public static final SLongLongCoder INST = new SLongLongCoder();
public SLongLongCoder(){ super(FFI_SINT64, "q", Long.class, long.class); } public SLongLongCoder(){ super(FFI_SINT64, "q", Long.class, long.class); }
@ -569,6 +592,8 @@ public static final class SLongLongCoder extends PrimitiveCoder<Long>{
} }
// native ulonglong -> java long // native ulonglong -> java long
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class ULongLongCoder extends PrimitiveCoder<Long>{ public static final class ULongLongCoder extends PrimitiveCoder<Long>{
public static final ULongLongCoder INST = new ULongLongCoder(); public static final ULongLongCoder INST = new ULongLongCoder();
public ULongLongCoder(){ super(FFI_UINT64, "Q", Long.class, long.class); } public ULongLongCoder(){ super(FFI_UINT64, "Q", Long.class, long.class); }
@ -612,6 +637,8 @@ public static final class ULongLongCoder extends PrimitiveCoder<Long>{
} }
// native float -> java float // native float -> java float
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class FloatCoder extends PrimitiveCoder<Float>{ public static final class FloatCoder extends PrimitiveCoder<Float>{
public static final FloatCoder INST = new FloatCoder(); public static final FloatCoder INST = new FloatCoder();
public FloatCoder(){ super(FFI_FLOAT, "f", Float.class, float.class); } public FloatCoder(){ super(FFI_FLOAT, "f", Float.class, float.class); }
@ -655,6 +682,8 @@ public static final class FloatCoder extends PrimitiveCoder<Float>{
} }
// native double -> java double // native double -> java double
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public static final class DoubleCoder extends PrimitiveCoder<Double>{ public static final class DoubleCoder extends PrimitiveCoder<Double>{
public static final DoubleCoder INST = new DoubleCoder(); public static final DoubleCoder INST = new DoubleCoder();
public DoubleCoder(){ super(FFI_DOUBLE, "d", Double.class, double.class); } public DoubleCoder(){ super(FFI_DOUBLE, "d", Double.class, double.class); }

@ -24,6 +24,10 @@
*/ */
package com.apple.jobjc; package com.apple.jobjc;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public class SEL { public class SEL {
static native long getSelectorPtr(String selectorName); static native long getSelectorPtr(String selectorName);
static native String getSelectorName(long ptr); static native String getSelectorName(long ptr);

@ -24,9 +24,13 @@
*/ */
package com.apple.jobjc; package com.apple.jobjc;
import javax.tools.annotation.GenerateNativeHeader;
/** /**
* A struct is malloced on the C heap and accessed in Java through a ByteBuffer. * A struct is malloced on the C heap and accessed in Java through a ByteBuffer.
*/ */
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
public abstract class Struct{ public abstract class Struct{
protected final NativeBuffer raw; protected final NativeBuffer raw;
private final JObjCRuntime runtime; private final JObjCRuntime runtime;

@ -33,6 +33,10 @@ import com.apple.jobjc.Coder.PrimitivePointerCoder;
import com.apple.jobjc.Coder.VoidCoder; import com.apple.jobjc.Coder.VoidCoder;
import com.apple.jobjc.Invoke.MsgSend; import com.apple.jobjc.Invoke.MsgSend;
import javax.tools.annotation.GenerateNativeHeader;
/* No native methods here, but the constants are needed in the supporting JNI code */
@GenerateNativeHeader
final class Subclassing { final class Subclassing {
static native long allocateClassPair(long superClass, String name); static native long allocateClassPair(long superClass, String name);
static native boolean addIVarForJObj(long clazz); static native boolean addIVarForJObj(long clazz);

@ -28,6 +28,7 @@ import java.io.File;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.TreeSet;
import com.apple.internal.jobjc.generator.FunctionGenerator; import com.apple.internal.jobjc.generator.FunctionGenerator;
import com.apple.internal.jobjc.generator.Utils; import com.apple.internal.jobjc.generator.Utils;
@ -130,7 +131,11 @@ public class FrameworkClassFile extends GeneratedClassFile {
} }
} }
for (final Clazz clazz : framework.classes) { /**
* Order classes to get stable output
*/
TreeSet<Clazz> sortedClasses = new TreeSet<Clazz>(framework.classes);
for (final Clazz clazz : sortedClasses) {
final String classClassName = clazz.name + "Class"; final String classClassName = clazz.name + "Class";
out.println(JavaLang.makeSingleton("_" + classClassName, clazz.name, classClassName, "getRuntime()")); out.println(JavaLang.makeSingleton("_" + classClassName, clazz.name, classClassName, "getRuntime()"));
} }

@ -147,4 +147,8 @@ public class Clazz extends Element<Framework> implements OutputFileGenerator {
return null; return null;
} }
int compareTo(Clazz o) {
return toString().compareTo(o.toString());
}
} }

@ -25,7 +25,7 @@
package com.apple.internal.jobjc.generator.model.coders; package com.apple.internal.jobjc.generator.model.coders;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.TreeSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -40,7 +40,7 @@ import com.apple.jobjc.JObjCRuntime;
*/ */
public class ComplexCoderDescriptor extends CoderDescriptor { public class ComplexCoderDescriptor extends CoderDescriptor {
static Map<Pair<NType,NType>, ComplexCoderDescriptor> cache = new HashMap<Pair<NType,NType>, ComplexCoderDescriptor>(); static Map<Pair<NType,NType>, ComplexCoderDescriptor> cache = new HashMap<Pair<NType,NType>, ComplexCoderDescriptor>();
static Set<MixedEncodingDescriptor> mixedEncodingDescriptors = new HashSet<MixedEncodingDescriptor>(); static Set<MixedEncodingDescriptor> mixedEncodingDescriptors = new TreeSet<MixedEncodingDescriptor>();
public static Set<MixedEncodingDescriptor> getMixedEncoders() { return mixedEncodingDescriptors; } public static Set<MixedEncodingDescriptor> getMixedEncoders() { return mixedEncodingDescriptors; }
@ -76,7 +76,7 @@ public class ComplexCoderDescriptor extends CoderDescriptor {
// ** Subclasses // ** Subclasses
// ------------- // -------------
public static class MixedEncodingDescriptor extends ComplexCoderDescriptor { public static class MixedEncodingDescriptor extends ComplexCoderDescriptor implements java.lang.Comparable {
protected final PrimitiveCoderDescriptor desc32; protected final PrimitiveCoderDescriptor desc32;
public MixedEncodingDescriptor(final PrimitiveCoderDescriptor desc32, final PrimitiveCoderDescriptor desc64) { public MixedEncodingDescriptor(final PrimitiveCoderDescriptor desc32, final PrimitiveCoderDescriptor desc64) {
@ -97,5 +97,6 @@ public class ComplexCoderDescriptor extends CoderDescriptor {
} }
static String getBaseNameOfCoder(final String coderName) { return coderName.substring(0, coderName.indexOf("Coder")); } static String getBaseNameOfCoder(final String coderName) { return coderName.substring(0, coderName.indexOf("Coder")); }
public int compareTo(Object _o) { MixedEncodingDescriptor o = (MixedEncodingDescriptor)_o; return getMixedName().compareTo(o.getMixedName()); }
} }
} }