/* * * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tuscany.sca.cpp.tools.services; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import org.apache.tuscany.sca.cpp.tools.common.CParsingTool; import org.apache.tuscany.sca.cpp.tools.common.Headers; import org.apache.tuscany.sca.cpp.tools.common.Options; import org.apache.tuscany.sca.cpp.tools.common.Parameter; import org.apache.tuscany.sca.cpp.tools.common.Signature; import org.apache.tuscany.sca.cpp.tools.common.Utils; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; /** * This class is the main class that handles the function that parses a C++ * interface header file into a DOM that holds all the semantic information * about the interface - method names, parameters and return values. It then * uses XSLT to generate different "views" of this data plus the parameter map * from other sources that are the C++ programs for the proxy and wrapper * implementations and headers. */ public class ServicesGenerator extends CParsingTool { private static final String OPERATION_NAME_ATTR = "operationNameAttr"; private static final String HEADER_NAME_ATTR = "headerNameAttr"; private static final String SCA_OPERATION = "scaOperation"; private static final String SCA_SERVICE = "scaService"; private static final String SCA_OPERATION_RETURN_TYPE = "scaOperationReturnType"; private static final String SCA_OPERATION_PARAMETER = "scaOperationParameter"; private static final String SCA_OPERATION_PARAMETER_NAME_ATTR = "scaOperationParameterNameAttr"; private static final String SCA_OPERATION_PARAMETER_CONST_ATTR = "scaOperationParameterConstAttr"; private static final String SCA_INTERFACE_NAME_ATTR = "scaInterfaceNameAttr"; private static final String CPP_HEADER = "cppHeader"; private static boolean TESTING = true; private static TransformerFactory txmf = null; private static ServicesGenerator instance = null; public ServicesGenerator(String[] args) throws Exception { super(args); txmf = TransformerFactory.newInstance(); } /** * * @param parameters * @param forReference * true if we are creating a proxy for a reference (rather than * for a service) * @throws Exception * * The design is * * * plus if we are not generating for a reference element *