private static Method findMarshaler0(Class<?> findClass, Class<?> inClass) { org.robovm.rt.bro.annotation.Marshaler anno1 = inClass.getAnnotation(org.robovm.rt.bro.annotation.Marshaler.class); org.robovm.rt.bro.annotation.Marshalers anno2 = inClass.getAnnotation(org.robovm.rt.bro.annotation.Marshalers.class); if (anno1 != null) { Method method = find(findClass, inClass, anno1); if (method != null) { return method; } } if (anno2 != null) { for (org.robovm.rt.bro.annotation.Marshaler m : anno2.value()) { Method method = find(findClass, inClass, m); if (method != null) { return method; } } } return null; }
private static Method findMarshaler(Class<?> findClass, Class<?> inClass) { // Search for a marshaler on the class and its superclasses. Class<?> c = inClass; while (c != null) { Method marshaler = findMarshaler0(findClass, c); if (marshaler != null) { return marshaler; } c = c.getSuperclass(); } for (Class<?> intf : inClass.getInterfaces()) { Method marshaler = findMarshaler(findClass, intf); if (marshaler != null) { return marshaler; } } Method marshaler = findMarshaler0(findClass, BuiltinMarshalers.class); if (marshaler != null) { return marshaler; } throw new Error("No marshaler found for class " + findClass.getName()); }
/** * Casts this {@link NativeObject} to another {@link NativeObject} type. * * @param type the type to cast to. * @return a {@link NativeObject} that points to the same memory * location as this {@link NativeObject}. */ @SuppressWarnings("unchecked") public <U extends NativeObject> U as(Class<U> type) { if (getClass() == type || type.isAssignableFrom(getClass())) { return (U) this; } return MarshalerLookup.toObject(type, handle); }
/** * Finds a {@code T toObject(Class<?>, long, long)} marshaler method which can * convert handles into the specified type. * * @return the {@link Method} * @throws {@link Error} if no such method could be found. */ public static Method findMarshaler(Class<? extends NativeObject> type) { Method toObject = TO_OBJECT_CACHE.get(type); if (toObject == null) { toObject = findMarshaler(type, type); TO_OBJECT_CACHE.put(type, toObject); } return toObject; }
/** * Convenience method which finds a marshaler method and runs it * converting the specified handle to the specified type. * * @param type the type to convert to. * @param handle the handle (pointer). * @return the marshaled instance. * @throws {@link Error} if no marshaler method could be found. */ @SuppressWarnings("unchecked") public static <S extends NativeObject> S toObject(Class<S> type, long handle) { try { Method toObject = findMarshaler(type); return (S) toObject.invoke(null, type, handle, MarshalerFlags.CALL_TYPE_PTR); } catch (InvocationTargetException e) { throw new Error(e); } catch (IllegalAccessException e) { throw new Error(e); } }
private static Method findMarshaler(Class<?> findClass, Class<?> inClass) { // Search for a marshaler on the class and its superclasses. Class<?> c = inClass; while (c != null) { Method marshaler = findMarshaler0(findClass, c); if (marshaler != null) { return marshaler; } c = c.getSuperclass(); } for (Class<?> intf : inClass.getInterfaces()) { Method marshaler = findMarshaler(findClass, intf); if (marshaler != null) { return marshaler; } } Method marshaler = findMarshaler0(findClass, BuiltinMarshalers.class); if (marshaler != null) { return marshaler; } throw new Error("No marshaler found for class " + findClass.getName()); }
@SuppressWarnings("unchecked") private S toObject(long handle) { Class<S> type = (Class<S>) TYPE_CACHE.get(getClass()); if (type == null) { type = (Class<S>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; TYPE_CACHE.put(getClass(), type); } return MarshalerLookup.toObject(type, handle); } }
/** * Finds a {@code T toObject(Class<?>, long, long)} marshaler method which can * convert handles into the specified type. * * @return the {@link Method} * @throws {@link Error} if no such method could be found. */ public static Method findMarshaler(Class<? extends NativeObject> type) { Method toObject = TO_OBJECT_CACHE.get(type); if (toObject == null) { toObject = findMarshaler(type, type); TO_OBJECT_CACHE.put(type, toObject); } return toObject; }
private static Method findMarshaler0(Class<?> findClass, Class<?> inClass) { org.robovm.rt.bro.annotation.Marshaler anno1 = inClass.getAnnotation(org.robovm.rt.bro.annotation.Marshaler.class); org.robovm.rt.bro.annotation.Marshalers anno2 = inClass.getAnnotation(org.robovm.rt.bro.annotation.Marshalers.class); if (anno1 != null) { Method method = find(findClass, inClass, anno1); if (method != null) { return method; } } if (anno2 != null) { for (org.robovm.rt.bro.annotation.Marshaler m : anno2.value()) { Method method = find(findClass, inClass, m); if (method != null) { return method; } } } return null; }
private static Method findMarshaler(Class<?> findClass, Class<?> inClass) { // Search for a marshaler on the class and its superclasses. Class<?> c = inClass; while (c != null) { Method marshaler = findMarshaler0(findClass, c); if (marshaler != null) { return marshaler; } c = c.getSuperclass(); } for (Class<?> intf : inClass.getInterfaces()) { Method marshaler = findMarshaler(findClass, intf); if (marshaler != null) { return marshaler; } } Method marshaler = findMarshaler0(findClass, BuiltinMarshalers.class); if (marshaler != null) { return marshaler; } throw new Error("No marshaler found for class " + findClass.getName()); }
/** * Casts this {@link NativeObject} to another {@link NativeObject} type. * * @param type the type to cast to. * @return a {@link NativeObject} that points to the same memory * location as this {@link NativeObject}. */ @SuppressWarnings("unchecked") public <U extends NativeObject> U as(Class<U> type) { if (getClass() == type || type.isAssignableFrom(getClass())) { return (U) this; } return MarshalerLookup.toObject(type, handle); }
/** * Finds a {@code T toObject(Class<?>, long, long)} marshaler method which can * convert handles into the specified type. * * @return the {@link Method} * @throws {@link Error} if no such method could be found. */ public static Method findMarshaler(Class<? extends NativeObject> type) { Method toObject = TO_OBJECT_CACHE.get(type); if (toObject == null) { toObject = findMarshaler(type, type); TO_OBJECT_CACHE.put(type, toObject); } return toObject; }
private static Method findMarshaler0(Class<?> findClass, Class<?> inClass) { org.robovm.rt.bro.annotation.Marshaler anno1 = inClass.getAnnotation(org.robovm.rt.bro.annotation.Marshaler.class); org.robovm.rt.bro.annotation.Marshalers anno2 = inClass.getAnnotation(org.robovm.rt.bro.annotation.Marshalers.class); if (anno1 != null) { Method method = find(findClass, inClass, anno1); if (method != null) { return method; } } if (anno2 != null) { for (org.robovm.rt.bro.annotation.Marshaler m : anno2.value()) { Method method = find(findClass, inClass, m); if (method != null) { return method; } } } return null; }
private static Method findMarshaler(Class<?> findClass, Class<?> inClass) { // Search for a marshaler on the class and its superclasses. Class<?> c = inClass; while (c != null) { Method marshaler = findMarshaler0(findClass, c); if (marshaler != null) { return marshaler; } c = c.getSuperclass(); } for (Class<?> intf : inClass.getInterfaces()) { Method marshaler = findMarshaler(findClass, intf); if (marshaler != null) { return marshaler; } } Method marshaler = findMarshaler0(findClass, BuiltinMarshalers.class); if (marshaler != null) { return marshaler; } throw new Error("No marshaler found for class " + findClass.getName()); }
/** * Casts this {@link NativeObject} to another {@link NativeObject} type. * * @param type the type to cast to. * @return a {@link NativeObject} that points to the same memory * location as this {@link NativeObject}. */ @SuppressWarnings("unchecked") public <U extends NativeObject> U as(Class<U> type) { if (getClass() == type || type.isAssignableFrom(getClass())) { return (U) this; } return MarshalerLookup.toObject(type, handle); }
/** * Finds a {@code T toObject(Class<?>, long, long)} marshaler method which can * convert handles into the specified type. * * @return the {@link Method} * @throws {@link Error} if no such method could be found. */ public static Method findMarshaler(Class<? extends NativeObject> type) { Method toObject = TO_OBJECT_CACHE.get(type); if (toObject == null) { toObject = findMarshaler(type, type); TO_OBJECT_CACHE.put(type, toObject); } return toObject; }
private static Method findMarshaler0(Class<?> findClass, Class<?> inClass) { org.robovm.rt.bro.annotation.Marshaler anno1 = inClass.getAnnotation(org.robovm.rt.bro.annotation.Marshaler.class); org.robovm.rt.bro.annotation.Marshalers anno2 = inClass.getAnnotation(org.robovm.rt.bro.annotation.Marshalers.class); if (anno1 != null) { Method method = find(findClass, inClass, anno1); if (method != null) { return method; } } if (anno2 != null) { for (org.robovm.rt.bro.annotation.Marshaler m : anno2.value()) { Method method = find(findClass, inClass, m); if (method != null) { return method; } } } return null; }
private static Method findMarshaler(Class<?> findClass, Class<?> inClass) { // Search for a marshaler on the class and its superclasses. Class<?> c = inClass; while (c != null) { Method marshaler = findMarshaler0(findClass, c); if (marshaler != null) { return marshaler; } c = c.getSuperclass(); } for (Class<?> intf : inClass.getInterfaces()) { Method marshaler = findMarshaler(findClass, intf); if (marshaler != null) { return marshaler; } } Method marshaler = findMarshaler0(findClass, BuiltinMarshalers.class); if (marshaler != null) { return marshaler; } throw new Error("No marshaler found for class " + findClass.getName()); }
@SuppressWarnings("unchecked") private S toObject(long handle) { Class<S> type = (Class<S>) TYPE_CACHE.get(getClass()); if (type == null) { type = (Class<S>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; TYPE_CACHE.put(getClass(), type); } return MarshalerLookup.toObject(type, handle); } }
/** * Finds a {@code T toObject(Class<?>, long, long)} marshaler method which can * convert handles into the specified type. * * @return the {@link Method} * @throws {@link Error} if no such method could be found. */ public static Method findMarshaler(Class<? extends NativeObject> type) { Method toObject = TO_OBJECT_CACHE.get(type); if (toObject == null) { toObject = findMarshaler(type, type); TO_OBJECT_CACHE.put(type, toObject); } return toObject; }