public Identifier getActualTaggedTypeName(TaggedTypeRef struct) { Identifier structName = null; Identifier tag = struct.getTag(); if (tag == null || tag.isPlain() && tag.toString().startsWith("_")) { TypeDef parentDef = as(struct.getParentElement(), TypeDef.class); if (parentDef != null) { structName = new Identifier.SimpleIdentifier(JNAeratorUtils.findBestPlainStorageName(parentDef)); } else if (tag != null) { String better = tag.toString().substring(1); Pair<TypeDef, Declarator> pair = result.typeDefs.get(better); if (pair != null && pair.getFirst().getValueType() != null && pair.getSecond() instanceof DirectDeclarator) { TypeRef tr = pair.getFirst().getValueType(); DirectDeclarator dd = (DirectDeclarator) pair.getSecond(); if (tr instanceof SimpleTypeRef) { if (tag.equals(((SimpleTypeRef) tr).getName())) structName = ident(dd.resolveName()); } else if (tr instanceof TaggedTypeRef) { if (tag.equals(((TaggedTypeRef) tr).getTag())) structName = ident(dd.resolveName()); } } } } if (structName == null || structName.toString().equals("")) structName = tag; return structName == null ? null : structName.clone(); }
private static Vector<Identifier> _s(Identifier t1, Identifier t2) { Vector<Identifier> hash = new Vector<Identifier>(); if (!t1.toString().equals("")) { hash.add(t1); } if (!t2.toString().equals("")) { hash.add(t2); } return hash; }
/** * Required for making object Parcelable. If you override this class, you must override this * method if you add any additional fields. */ public void writeToParcel(Parcel out, int flags) { out.writeInt(mIdentifiers.size()); LogManager.d(TAG, "serializing identifiers of size %s", mIdentifiers.size()); for (Identifier identifier : mIdentifiers) { out.writeString(identifier == null ? null : identifier.toString()); } out.writeDouble(getDistance()); out.writeInt(mRssi); out.writeInt(mTxPower); out.writeString(mBluetoothAddress); out.writeInt(mBeaconTypeCode); out.writeInt(mServiceUuid); out.writeInt(mDataFields.size()); for (Long dataField : mDataFields) { out.writeLong(dataField); } if (LogManager.isVerboseLoggingEnabled()) { LogManager.d(TAG, "writing " + mExtraDataFields.size() + " extra data fields to parcel"); } out.writeInt(mExtraDataFields.size()); for (Long dataField : mExtraDataFields) { out.writeLong(dataField); } out.writeInt(mManufacturer); out.writeString(mBluetoothName); }
protected void outputConvertedStruct( Struct struct, Signatures signatures, DeclarationsHolder out, Identifier callerLibraryClass, String callerLibrary, boolean onlyFields) throws IOException { Struct structJavaClass = convertStruct(struct, signatures, callerLibraryClass, 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(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)); }
public void writeToParcel(Parcel out, int flags) { out.writeString(mUniqueId); out.writeString(mBluetoothAddress); out.writeInt(mIdentifiers.size()); for (Identifier identifier : mIdentifiers) { if (identifier != null) { out.writeString(identifier.toString()); } else { out.writeString(null); } } }
protected String chooseJavaArgName(String name, int iArg, Set<String> names) { Identifier jan = result.typeConverter.getValidJavaArgumentName(ident(name)); String baseArgName = jan == null ? null : jan.toString(); int i = 1; if (baseArgName == null) baseArgName = "arg"; String argName; do { argName = baseArgName + (i == 1 ? "" : i + ""); i++; } while (names.contains(argName) || result.typeConverter.isJavaKeyword(argName)); names.add(argName); return argName; }
/** * Creates a qualified name reference. * * @param schema The in which the object is defined (optional) * @param catalog The catalog in which the object is defined (optional) * @param name The name (required) */ public ObjectName(Identifier schema, Identifier catalog, Identifier name) { if (name == null) { // Identifier cannot be constructed with an 'empty' name throw new IllegalIdentifierException("Object name must be specified"); } this.name = name; this.schema = schema; this.catalog = catalog; StringBuilder buff = new StringBuilder(name.toString()); if (catalog != null) { buff.insert(0, catalog.toString() + '.'); } if (schema != null) { buff.insert(0, schema.toString() + '.'); } this.identifier = buff.toString(); int tmpHashCode = schema != null ? schema.hashCode() : 0; tmpHashCode = 31 * tmpHashCode + (catalog != null ? catalog.hashCode() : 0); tmpHashCode = 31 * tmpHashCode + name.hashCode(); this.hashCode = tmpHashCode; }
public String toString() { StringBuilder sb = new StringBuilder(); int i = 1; for (Identifier identifier : mIdentifiers) { if (i > 1) { sb.append(" "); } sb.append("id"); sb.append(i); sb.append(": "); sb.append(identifier == null ? "null" : identifier.toString()); i++; } return sb.toString(); }
/** * Calculate a hashCode for this beacon * * @return */ @Override public int hashCode() { StringBuilder sb = new StringBuilder(); int i = 1; for (Identifier identifier : mIdentifiers) { sb.append("id"); sb.append(i); sb.append(": "); sb.append(identifier.toString()); sb.append(" "); i++; } if (sHardwareEqualityEnforced) { sb.append(mBluetoothAddress); } return sb.toString().hashCode(); }
public void toString(StringBuffer buffer, String tab) { buffer.append(tab).append("<StaticConstantAccess"); // $NON-NLS-1$ appendInterval(buffer); buffer.append(">\n"); // $NON-NLS-1$ buffer.append(TAB).append(tab).append("<ClassName>\n"); // $NON-NLS-1$ getClassName().toString(buffer, TAB + TAB + tab); buffer .append("\n") .append(TAB) .append(tab) .append("</ClassName>\n"); // $NON-NLS-1$ //$NON-NLS-2$ buffer.append(TAB).append(tab).append("<Constant>\n"); // $NON-NLS-1$ constant.toString(buffer, TAB + TAB + tab); buffer .append("\n") .append(TAB) .append(tab) .append("</Constant>\n"); // $NON-NLS-1$ //$NON-NLS-2$ buffer.append(tab).append("</StaticConstantAccess>"); // $NON-NLS-1$ }
public Struct convertCallback( FunctionSignature functionSignature, Signatures signatures, Identifier callerLibraryName) { Identifier name = result.typeConverter.inferCallBackName(functionSignature, true, false, callerLibraryName); if (name == null) return null; name = result.typeConverter.getValidJavaArgumentName(name); Function function = functionSignature.getFunction(); int i = 1; Identifier chosenName = name; while (!(signatures.addClass(chosenName))) { chosenName = ident(name.toString() + (++i)); } Element parent = functionSignature.getParentElement(); Element comel = parent != null && parent instanceof TypeDef ? parent : functionSignature; Struct callbackStruct = new Struct(); configureCallbackStruct(callbackStruct); // callbackStruct.setParents(Arrays.asList(getCallbackType(functionSignature, chosenName))); callbackStruct.setTag(ident(chosenName)); if (!result.config.noComments) callbackStruct.addToCommentBefore( comel.getCommentBefore(), comel.getCommentAfter(), getFileCommentContent(comel)); convertFunction(function, new Signatures(), true, callbackStruct, callerLibraryName, -1); for (Declaration d : callbackStruct.getDeclarations()) { if (d instanceof Function) { callbackStruct.addAnnotations(callbackStruct.getAnnotations()); callbackStruct.setAnnotations(null); break; } } return callbackStruct; }
public void convertFunction( Function function, Signatures signatures, boolean isCallback, final DeclarationsHolder out, final Identifier libraryClassName, int iConstructor) { if (result.config.functionsAccepter != null && !result.config.functionsAccepter.adapt(function)) return; // if (function.findParentOfType(Template)) String library = result.getLibrary(function); Identifier functionName = function.getName(); boolean isMethod = function.getParentElement() instanceof Struct; if (functionName == null || isCallback) { if (function.getParentElement() instanceof FunctionSignature) functionName = ident(result.config.callbackInvokeMethodName); else return; } if (function.getParentElement() instanceof FriendDeclaration) return; String n = functionName.toString(); if (n.contains("<") || n.startsWith("~")) return; if (result.config.beautifyNames) functionName = ident(result.typeConverter.beautify(n, false)); functionName = result.typeConverter.getValidJavaMethodName(functionName); if (functionName == null) return; // if (functionName.equals("operator")) // functionName String sig = function.computeSignature(SignatureType.JavaStyle); DeclarationsHolder objOut = result.config.reification && !isCallback && !isMethod ? new DeclarationsHolder() { @Override public void addDeclaration(Declaration d) { out.addDeclaration(d); if (d instanceof Function) { Function f = (Function) d; List<Arg> args = f.getArgs(); List<TypeRef> trs = new ArrayList<TypeRef>(2); trs.add(f.getValueType()); if (!args.isEmpty()) trs.add(args.get(0).getValueType()); for (TypeRef tr : trs) { if (tr instanceof SimpleTypeRef) { Identifier id = ((SimpleTypeRef) tr).getName(); if (result.isFakePointer(id)) { result.addFunctionReifiableInFakePointer(id, libraryClassName, f); } } } } } @Override public List<Declaration> getDeclarations() { return out.getDeclarations(); } } : out; try { convertFunction( function, signatures, isCallback, objOut, libraryClassName, sig, functionName, library, iConstructor); } catch (UnsupportedConversionException ex) { Declaration d = skipDeclaration(function); if (d != null) { d.addToCommentBefore(ex.toString()); out.addDeclaration(d); } } }
public String toString() { if (name != null) { return name.toString(); } return numval.toString(); }