@Override protected void fillLibraryMapping(Result result, SourceFiles sourceFiles, DeclarationsHolder declarations, DeclarationsHolder implementations, String library, Identifier javaPackage, Expression nativeLibFieldExpr) throws IOException { super.fillLibraryMapping(result, sourceFiles, declarations, implementations, library, javaPackage, nativeLibFieldExpr); if (implementations instanceof ModifiableElement) { ModifiableElement minterf = (ModifiableElement) implementations; List<String> deps = result.config.dependencies.get(library); Map<String, Expression> namedArguments = null; if (deps != null) { List<Expression> depExprs = new ArrayList<Expression>(); for (String dep : deps) depExprs.add(expr(dep)); namedArguments = ImmutableMap.<String, Expression>of( "dependencies", NewArray.newAnnotationArrayValue(depExprs)); } minterf.addAnnotation(new Annotation(typeRef(org.bridj.ann.Library.class), expr(library), namedArguments)); minterf.addAnnotation(new Annotation(typeRef(org.bridj.ann.Runtime.class), classLiteral(result.hasCPlusPlus ? CPPRuntime.class : CRuntime.class))); } }
@Override protected void fillLibraryMapping(Result result, SourceFiles sourceFiles, DeclarationsHolder declarations, DeclarationsHolder implementations, String library, Identifier javaPackage, Expression nativeLibFieldExpr) throws IOException { super.fillLibraryMapping(result, sourceFiles, declarations, implementations, library, javaPackage, nativeLibFieldExpr); if (implementations instanceof ModifiableElement) { ModifiableElement minterf = (ModifiableElement) implementations; List<String> deps = result.config.dependencies.get(library); Map<String, Expression> namedArguments = null; if (deps != null) { List<Expression> depExprs = new ArrayList<Expression>(); for (String dep : deps) depExprs.add(expr(dep)); namedArguments = ImmutableMap.<String, Expression>of( "dependencies", NewArray.newAnnotationArrayValue(depExprs)); } minterf.addAnnotation(new Annotation(typeRef(org.bridj.ann.Library.class), expr(library), namedArguments)); minterf.addAnnotation(new Annotation(typeRef(org.bridj.ann.Runtime.class), classLiteral(result.hasCPlusPlus ? CPPRuntime.class : CRuntime.class))); } }
private void addParentNamespaceAnnotation(ModifiableElement dest, Identifier parentNamespace) { if (parentNamespace != null) { dest.addAnnotation(new Annotation(typeRef(org.bridj.ann.Namespace.class), expr(parentNamespace.toString()))); } } }
void toDirectFakePointer(Result result, Declaration decl) { decl.setValueType(typeRef(long.class)); decl.addAnnotation(new Annotation(typeRef(Ptr.class))); }
private void addParentNamespaceAnnotation(ModifiableElement dest, Identifier parentNamespace) { if (parentNamespace != null) { dest.addAnnotation(new Annotation(typeRef(org.bridj.ann.Namespace.class), expr(parentNamespace.toString()))); } } }
public <M extends ModifiableElement> M annotateRawType(M element) throws UnsupportedConversionException { element.addAnnotations(annotations); if (type != null) { switch (type) { case Enum: case Primitive: case Void: break; case NativeLong: element.addAnnotation(new Annotation(typeRef(CLong.class))); break; case NativeSize: element.addAnnotation(new Annotation(typeRef(Ptr.class))); break; case Pointer: element.addAnnotation(new Annotation(typeRef(Ptr.class))); break; case Struct: case ComplexDouble: case FunctionSignature: case Default: case NativeTime: //throw new UnsupportedConversionException(typeRef, "Struct by value not supported yet"); break; default: throw new UnsupportedConversionException(typeRef, "Not supported"); } } return element; }
void toDirectFakePointer(Result result, Declaration decl) { decl.setValueType(typeRef(long.class)); decl.addAnnotation(new Annotation(typeRef(Ptr.class))); }
private void annotateActualName(ModifiableElement e, Identifier name) { e.addAnnotation(new Annotation(result.config.runtime.typeRef(JNAeratorConfig.Runtime.Ann.Name), expr(name.toString()))); }
private void annotateActualName(ModifiableElement e, Identifier name) { e.addAnnotation(new Annotation(result.config.runtime.typeRef(JNAeratorConfig.Runtime.Ann.Name), expr(name.toString()))); }
public void annotateActualName(ModifiableElement e, Identifier name) { e.addAnnotation(new Annotation(typeRef(org.bridj.ann.Name.class), expr(name.toString()))); }
public <M extends ModifiableElement> M annotateRawType(M element) throws UnsupportedConversionException { element.addAnnotations(annotations); if (type != null) { switch (type) { case Enum: case Primitive: case Void: break; case NativeLong: element.addAnnotation(new Annotation(typeRef(CLong.class))); break; case NativeSize: element.addAnnotation(new Annotation(typeRef(Ptr.class))); break; case Pointer: element.addAnnotation(new Annotation(typeRef(Ptr.class))); break; case Struct: case ComplexDouble: case FunctionSignature: case Default: case NativeTime: //throw new UnsupportedConversionException(typeRef, "Struct by value not supported yet"); break; default: throw new UnsupportedConversionException(typeRef, "Not supported"); } } return element; }
public void annotateActualName(ModifiableElement e, Identifier name) { e.addAnnotation(new Annotation(typeRef(org.bridj.ann.Name.class), expr(name.toString()))); }
void addCallingConventionAnnotation(Function originalFunction, ModifiableElement target) { Convention.Style cc = null; if (originalFunction.hasModifier(ModifierType.__stdcall)) { cc = Convention.Style.StdCall; } else if (originalFunction.hasModifier(ModifierType.__fastcall)) { cc = Convention.Style.FastCall; } else if (originalFunction.hasModifier(ModifierType.__thiscall)) { cc = Convention.Style.ThisCall; } else if (originalFunction.hasModifier(ModifierType.__pascal)) { cc = Convention.Style.Pascal; } if (cc != null) { target.addAnnotation(new Annotation(typeRef(Convention.class), enumRef(cc))); } }
void addCallingConventionAnnotation(Function originalFunction, ModifiableElement target) { Convention.Style cc = null; if (originalFunction.hasModifier(ModifierType.__stdcall)) { cc = Convention.Style.StdCall; } else if (originalFunction.hasModifier(ModifierType.__fastcall)) { cc = Convention.Style.FastCall; } else if (originalFunction.hasModifier(ModifierType.__thiscall)) { cc = Convention.Style.ThisCall; } else if (originalFunction.hasModifier(ModifierType.__pascal)) { cc = Convention.Style.Pascal; } if (cc != null) { target.addAnnotation(new Annotation(typeRef(Convention.class), enumRef(cc))); } }
protected void outputConvertedStruct(Struct struct, Signatures signatures, DeclarationsHolder out, String callerLibrary, boolean onlyFields) throws IOException { Struct structJavaClass = convertStruct(struct, signatures, out.getResolvedJavaIdentifier(), callerLibrary, onlyFields); if (structJavaClass == null) { return; } if (result.config.putTopStructsInSeparateFiles && struct.findParentOfType(Struct.class) == null) { String library = result.getLibrary(struct); Identifier javaPackage = result.getLibraryPackage(library); Identifier fullClassName = ident(javaPackage, structJavaClass.getTag().clone()); if (result.config.runtime == JNAeratorConfig.Runtime.BridJ) { structJavaClass.addAnnotation(new Annotation(typeRef(org.bridj.ann.Library.class), expr(library))); } structJavaClass.removeModifiers(ModifierType.Static); structJavaClass = result.notifyBeforeWritingClass(fullClassName, structJavaClass, signatures, library); if (structJavaClass != null) { PrintWriter pout = result.classOutputter.getClassSourceWriter(fullClassName.toString()); result.printJavaClass(javaPackage, structJavaClass, pout); pout.close(); } } else { out.addDeclaration(decl(structJavaClass)); } }
if (vs.getBits() > 0) { for (Declaration vd : vds) { vd.addAnnotation(new Annotation(result.config.runtime.typeRef(JNAeratorConfig.Runtime.Ann.Bits), expr(vs.getBits())));
if (vs.getBits() > 0) { for (Declaration vd : vds) { vd.addAnnotation(new Annotation(result.config.runtime.typeRef(JNAeratorConfig.Runtime.Ann.Bits), expr(vs.getBits())));
protected void outputConvertedStruct(Struct struct, Signatures signatures, DeclarationsHolder out, String callerLibrary, boolean onlyFields) throws IOException { Struct structJavaClass = convertStruct(struct, signatures, out.getResolvedJavaIdentifier(), callerLibrary, onlyFields); if (structJavaClass == null) { return; } if (result.config.putTopStructsInSeparateFiles && struct.findParentOfType(Struct.class) == null) { String library = result.getLibrary(struct); Identifier javaPackage = result.getLibraryPackage(library); Identifier fullClassName = ident(javaPackage, structJavaClass.getTag().clone()); if (result.config.runtime == JNAeratorConfig.Runtime.BridJ) { structJavaClass.addAnnotation(new Annotation(typeRef(org.bridj.ann.Library.class), expr(library))); } structJavaClass.removeModifiers(ModifierType.Static); structJavaClass = result.notifyBeforeWritingClass(fullClassName, structJavaClass, signatures, library); if (structJavaClass != null) { PrintWriter pout = result.classOutputter.getClassSourceWriter(fullClassName.toString()); result.printJavaClass(javaPackage, structJavaClass, pout); pout.close(); } } else { out.addDeclaration(decl(structJavaClass)); } }
vd.addAnnotation(new Annotation(result.config.runtime.typeRef(JNAeratorConfig.Runtime.Ann.Bits), expr(bits))); String st = vd.getValueType().toString(), mst = st; if (st.equals("int") || st.equals("long") || st.equals("short") || st.equals("long")) {
vd.addAnnotation(new Annotation(result.config.runtime.typeRef(JNAeratorConfig.Runtime.Ann.Bits), expr(bits))); String st = vd.getValueType().toString(), mst = st; if (st.equals("int") || st.equals("long") || st.equals("short") || st.equals("long")) {