public static boolean isPointerToArray(final Type type) { if (type instanceof PointerOf && getContainedType((PointerOf) type) instanceof ComplexType) { final IDLDefinition pointedDefinition = ((ComplexType) getContainedType((PointerOf) type)) .getIDLDefinition(); return pointedDefinition instanceof RecordDefinition && (getArrayCType(type) != null); } else { return false; } }
/** * Returns the equivalent in C of the given return type. * * @param type the type * @return the equivalent in C of the given return type. */ public static String buildType(Type type) { final StringBuffer result = new StringBuffer(); int nbPointer = 0; // A return type is an [ArrayOf](PointerOf)*(PrimitiveType|ComplexType) while (type instanceof ArrayOf) { nbPointer++; type = getContainedType((ArrayOf) type); } while (type instanceof PointerOf) { nbPointer++; type = getContainedType((PointerOf) type); } result.append(buildComplexOrPrimitiveType(type)); for (int i = 0; i < nbPointer; i++) result.append('*'); return result.toString(); }
/** * Returns <code>true</code> if the given type node is a complex type or * either an array or pointer of complex type. * * @param type a type node. * @return <code>true</code> if the given type node is a complex type or * either an array or pointer of complex type. */ public static boolean isComplexType(final Type type) { if (type instanceof ComplexType) { return true; } else if ((type instanceof ArrayOf) || (type instanceof PointerOf)) { return isComplexType(getContainedType((TypeContainer) type)); } else { return false; } }
public static String getArrayCType(final Type type) { if (type instanceof PointerOf && getContainedType((PointerOf) type) instanceof ComplexType) { final IDLDefinition pointedDefinition = ((ComplexType) getContainedType((PointerOf) type)) .getIDLDefinition(); final String name = ((RecordDefinition) pointedDefinition).getName(); if (BYTE_ARRAY_TYPE.equals(name)) return "minus_bare_generic_api_ByteArray"; else if (SHORT_ARRAY_TYPE.equals(name)) return "minus_bare_generic_api_ShortArray"; else if (USHORT_ARRAY_TYPE.equals(name)) return "minus_bare_generic_api_UShortArray"; else if (INT_ARRAY_TYPE.equals(name)) return "minus_bare_generic_api_IntArray"; else if (UINT_ARRAY_TYPE.equals(name)) return "minus_bare_generic_api_UIntArray"; else if (STRING_ARRAY_TYPE.equals(name)) return "minus_bare_generic_api_StringArray"; } return null; }
/** * Returns the complex type node contained by the given type. More precisely, * if the given <code>type</code> is a {@link ComplexType} this method * simply return it; if the given <code>type</code> is an {@link ArrayOf} of * a {@link PointerOf}, returns the complex type it contains; else, throws an * {@link IllegalArgumentException} * * @param type a {@link ComplexType} or a container of {@link ComplexType} * @return the complex type node contained by the given type. * @throws IllegalArgumentException if * <code>{@link #isComplexType(Type)}(type)</code> is * <code>false</code>. */ public static ComplexType getComplexType(final Type type) { if (type instanceof ComplexType) { return (ComplexType) type; } else if ((type instanceof ArrayOf) || (type instanceof PointerOf)) { return getComplexType(getContainedType((TypeContainer) type)); } else { throw new IllegalArgumentException( "The given type is not a complex type."); } }
private static String buildSizeableArray(Type type, final ParseArrayMode What) { final StringBuffer result = new StringBuffer(); String arraySpec = ""; while (type instanceof ArrayOf) { final String size = ((ArrayOf) type).getSize(); if (size != null) { arraySpec = "[" + size + "]" + arraySpec; } else { arraySpec = "[]" + arraySpec; } type = getContainedType((ArrayOf) type); } if (What == ParseArrayMode.TYPE) result.append(buildComplexOrPrimitiveType(type)); if (What == ParseArrayMode.SIZEOF) result.append(arraySpec); return result.toString(); }
private static String buildSizeableArray(Type type, final ParseArrayMode What) { final StringBuffer result = new StringBuffer(); String arraySpec = ""; while (type instanceof ArrayOf) { final String size = ((ArrayOf) type).getSize(); if (size != null) { arraySpec = "[" + size + "]" + arraySpec; } else { arraySpec = "[]" + arraySpec; } type = getContainedType((ArrayOf) type); } if (What == ParseArrayMode.TYPE) result.append(buildComplexOrPrimitiveType(type)); if (What == ParseArrayMode.SIZEOF) result.append(arraySpec); return result.toString(); }
private static String buildSizeableArray(Type type, final ParseArrayMode What) { final StringBuffer result = new StringBuffer(); String arraySpec = ""; while (type instanceof ArrayOf) { final String size = ((ArrayOf) type).getSize(); if (size != null) { arraySpec = "[" + size + "]" + arraySpec; } else { arraySpec = "[]" + arraySpec; } type = getContainedType((ArrayOf) type); } if (What == ParseArrayMode.TYPE) result.append(buildComplexOrPrimitiveType(type)); if (What == ParseArrayMode.SIZEOF) result.append(arraySpec); return result.toString(); }
private static String buildSizeableArray(Type type, final ParseArrayMode What) { final StringBuffer result = new StringBuffer(); String arraySpec = ""; while (type instanceof ArrayOf) { final String size = ((ArrayOf) type).getSize(); if (size != null) { arraySpec = "[" + size + "]" + arraySpec; } else { arraySpec = "[]" + arraySpec; } type = getContainedType((ArrayOf) type); } if (What == ParseArrayMode.TYPE) result.append(buildComplexOrPrimitiveType(type)); if (What == ParseArrayMode.SIZEOF) result.append(arraySpec); return result.toString(); }
public static String getArrayElementCType(final Type type) { if (type instanceof PointerOf && getContainedType((PointerOf) type) instanceof ComplexType) { final IDLDefinition pointedDefinition = ((ComplexType) getContainedType((PointerOf) type)) .getIDLDefinition(); final String name = ((RecordDefinition) pointedDefinition).getName(); if (BYTE_ARRAY_TYPE.equals(name)) return PrimitiveTypeEnum.BYTE.getCType(); else if (SHORT_ARRAY_TYPE.equals(name)) return PrimitiveTypeEnum.SHORT.getCType(); else if (USHORT_ARRAY_TYPE.equals(name)) return PrimitiveTypeEnum.UNSIGNED_SHORT.getCType(); else if (INT_ARRAY_TYPE.equals(name)) return PrimitiveTypeEnum.INT.getCType(); else if (UINT_ARRAY_TYPE.equals(name)) return PrimitiveTypeEnum.UNSIGNED_INT.getCType(); else if (STRING_ARRAY_TYPE.equals(name)) return PrimitiveTypeEnum.STRING.getCType(); } return null; }
@Override protected Component createTask(final ComponentContainer container, final Attributes attributes) throws TaskException { final Map<String, Type> fieldTypes = new HashMap<String, Type>(); for (final Field field : ((FieldContainer) ((IDLDefinitionContainer) attributes) .getIDLDefinition()).getFields()) { fieldTypes.put(field.getName(), Util.getContainedType(field)); } return taskFactoryItf.newPrimitiveTask(new AttributeDefinitionTask( attributes.getAttributes(), fieldTypes), container); }
@Override protected void checkRemoteInterface( final RemoteInterfaceDefinition definition, final Map<Object, Object> context) throws ADLException { for (final Method m : ((MethodContainer) definition).getMethods()) { final Type returnType = Util.getContainedType((m)); /* The return value must be serializable */ if (!isSerializable(returnType)) throw new ADLException(EXBErrors.IDL_INVALID_TYPE, "The return type of the method is not serializable", returnType); /* Each parameter must be serializable */ for (final Parameter p : ((ParameterContainer) m).getParameters()) { final Type paramType = Util.getContainedType((p)); if (!isSerializable(paramType)) throw new ADLException(EXBErrors.IDL_INVALID_TYPE, "The type of the parameter '" + p.getName() + "' is not serializable", paramType); } } } }
@Override protected void checkRemoteInterface( final RemoteInterfaceDefinition definition, final Map<Object, Object> context) throws ADLException { for (final Method m : ((MethodContainer) definition).getMethods()) { final Type returnType = Util.getContainedType((m)); /* The method must return void */ final boolean isVoidMethod = (returnType instanceof PrimitiveType) && getPrimitiveType((PrimitiveType) returnType) == PrimitiveTypeEnum.VOID; if (!isVoidMethod) throw new ADLException(EXBErrors.IDL_INVALID_TYPE, "Each method in MP stubs and skeletons must return void"); ; /* Each parameter must be serializable and must not be in or in/out */ for (final Parameter p : ((ParameterContainer) m).getParameters()) { final Type paramType = Util.getContainedType((p)); if (!isSerializable(paramType)) throw new ADLException(EXBErrors.IDL_INVALID_TYPE, "The type of the parameter '" + p.getName() + "' is not serializable", paramType); if (Util.isOutParameter(p) || Util.isInOutParameter(p)) throw new ADLException(EXBErrors.IDL_INVALID_TYPE, "The parameter '" + p.getName() + "' must be IN", paramType); } } } }
final Type type = getContainedType(p); if (!isPointerToArray(type)) { boolean pointer = false; final Type type = getContainedType(p);
public void visitMethod(final Method method) throws Exception { final Type returnType = Util.getContainedType((method)); final Parameter[] parameters = ((ParameterContainer) method) .getParameters(); .getContainedType(p), p.getName(), cw, localVars); paramContext.put(p, ctx); writeDeserialization(Util.getContainedType(p), p.getName(), data, cw, paramContext.get(p), true);
public void visitMethod(final Method method) throws Exception { final Type returnType = Util.getContainedType((method)); final boolean isVoidMethod = (returnType instanceof PrimitiveType) && getPrimitiveType((PrimitiveType) returnType) == PrimitiveTypeEnum.VOID;
public void visitMethod(final Method method) throws Exception { final Type returnType = Util.getContainedType((method)); final Parameter[] parameters = ((ParameterContainer) method) .getParameters(); Util.getContainedType(p), p.getName(), cw, localVars); paramContext.put(p, ctx); CSerializationHelper.writeSizeOf(Util.getContainedType(p), p.getName(), msgSize, cw, paramContext.get(p)); CSerializationHelper.writeSerialization(Util.getContainedType(p), p .getName(), data, cw, paramContext.get(p), true);
final Type type = getContainedType(p);
final Type type = getContainedType(p);
final IDLDefinition pointedDefinition = ((ComplexType) getContainedType((PointerOf) varType)) .getIDLDefinition(); final String name = ((RecordDefinition) pointedDefinition).getName();