/** * Get the signature of the given interface * * @param itf the interface * @return the signature */ public static String getSignature(final Node itf) { if (itf instanceof TypeInterface) { return ((TypeInterface) itf).getSignature(); } return null; }
/** * Tell if the given interface is a client one * * @param node the interface * @return true if it is a client interface */ public static boolean isClientInterface(final Node node) { if (node instanceof TypeInterface) { return ((TypeInterface) node).getRole().equals("client"); } return false; }
private static List<Node> improveInterfaceContainer( final InterfaceContainer arg) { /* set sub-interfaces parent */ for (final Interface i : arg.getInterfaces()) { i.astSetDecoration("parent", arg); i.astSetDecoration("export", new HashSet<Binding>()); if (TypeInterfaceUtil.isCollection(i)) { i.astSetDecoration("bind", new HashSet<Binding>()); } } return null; }
@Override protected String processSourceCode() throws Exception { final CodeWriter cw = new CodeWriter( "Client Interfaces Descriptor Builder (extern references to server components.)"); final String name = typeNameProviderItf.getCTypeName(); final String structName = name + "_importeds_desc"; final StringBuilder offset = new StringBuilder(name.toUpperCase()); offset.append("_IMPORTEDS_BASE_OFFSET"); cw.append("static required_interface_desc_t ").append(structName).append( "[] = {").endl(); for (final TypeInterface itf : clientInterfaces) { cw.append("{").endl(); cw.append("\"").append(itf.getName()).append("\", // name").endl(); cw.append("(").append(offset.toString()).append(")").endl(); cw.append("},").endl(); offset.append("\n + sizeof(R").append( itf.getSignature().replace('.', '_')).append(" *)"); } cw.append("};").endl(); return cw.toString(); } }
@Override protected String processSourceCode() throws Exception { final CodeWriter cw = new CodeWriter("Server Interfaces Descriptor"); final String name = typeNameProviderItf.getCTypeName(); final String structName = name + "_exporteds_desc"; // Build provided_interface_desc_t structures final StringBuilder offset = new StringBuilder(); offset.append(name.toUpperCase()).append("_EXPORTEDS_BASE_OFFSET"); cw.append("static provided_interface_desc_t ").append(structName).append( "[] = {").endl(); for (final TypeInterface itf : exportedItfNodes) { cw.append("{").endl(); cw.append("\"").append(itf.getName()).append("\", // name").endl(); cw.append("&(").append(name).append("_").append( itf.getName().replace('-', '_')).append("meth), // vtable").endl(); cw.append("(").append(offset.toString()).append(")").endl(); /* Add the signature */ cw.append("#if defined(TYPEDINTERFACE)").endl(); cw.append(", \"").append(itf.getSignature()).append("\"").endl(); cw.append("#endif").endl(); cw.append("},").endl(); offset.append("\n + sizeof(R").append( itf.getSignature().replace('.', '_')).append(")"); } cw.append("};").endl().endl(); return cw.toString(); } }
itfDefs.put(tItf.getSignature(), InterfaceDefinitionDecorationHelper .getResolvedInterfaceDefinition(tItf, null, null));
/** * Get an interface from its name * * @param parent the component from which the interface must be searched * @param name the name of the interface * @return the interface */ public static Interface getInterface(final Node parent, final String name) { if (parent instanceof InterfaceContainer) { for (final Interface i : ((InterfaceContainer) parent).getInterfaces()) { if (TypeInterfaceUtil.isCollection(i)) { if (name.indexOf(i.getName()) == 0) return i; } else { if (i.getName().equals(name)) return i; } } } return null; }
/** * Tell if the given interface is a server one * * @param node the interface * @return true if it is a server interface */ public static boolean isServerInterface(final Node node) { if (node instanceof TypeInterface) { return ((TypeInterface) node).getRole().equals("server"); } return false; } }
itfDefs.put(tItf.getSignature(), InterfaceDefinitionDecorationHelper .getResolvedInterfaceDefinition(tItf, null, null));
if (!TypeInterfaceUtil.isCollection(serverItf)) { bindings = new HashSet<Binding>(); bindings.add((Binding) serverItf.astGetDecoration("bind"));
@SuppressWarnings("unchecked") private static List<Node> improveBinding(final Binding arg) { /* improve binding iterfaces */ Node parent; Node from, to; Interface ifrom, ito; parent = AstUtil.getParent(arg); // Add the server interface to the client interface decorations from = AstUtil.getComponent(parent, arg.getFrom().split("\\.")[0]); ifrom = AstUtil.getInterface(from, arg.getFrom().split("\\.")[1]); if (TypeInterfaceUtil.isCollection(ifrom)) { final Set<Binding> bs = (Set<Binding>) ifrom.astGetDecoration("bind"); bs.add(arg); } else { ifrom.astSetDecoration("bind", arg); } // Add the client interface to the server interface decorations to = AstUtil.getComponent(parent, arg.getTo().split("\\.")[0]); ito = AstUtil.getInterface(to, arg.getTo().split("\\.")[1]); final Set<Binding> bs = (Set<Binding>) ito.astGetDecoration("export"); bs.add(arg); arg.astSetDecoration("client", ifrom); arg.astSetDecoration("server", ito); return null; }
if (!TypeInterfaceUtil.isCollection(itf)) { bindings = new HashSet<Binding>(); bindings.add((Binding) itf.astGetDecoration("bind"));
compositeStruct.addBinding(binding.getBinding().getFrom(), binding .getBinding().getTo(), binding.getBinding().getProtocol(), TypeInterfaceUtil.isCollection(fromItf));