tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robbin...@apache.org
Subject svn commit: r366157 [32/33] - in /incubator/tuscany/cpp/sca: ./ bin/ include/ include/osoa/ include/osoa/sca/ include/tuscany/ include/tuscany/sca/ include/tuscany/sca/core/ include/tuscany/sca/model/ include/tuscany/sca/util/ include/tuscany/sca/ws/ l...
Date Thu, 05 Jan 2006 10:59:14 GMT
Added: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/ServicesGenerator.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/ServicesGenerator.java?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/ServicesGenerator.java (added)
+++ incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/ServicesGenerator.java Thu Jan  5 02:54:16 2006
@@ -0,0 +1,802 @@
+/*
+ *
+ *  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
+     * <ul>
+     * <li>handleInterfaceHeader
+     * <li>createDOMofMethods
+     * <li>createProxyCPPFromDom(outputDir, dom);
+     * <li>createProxyHeaderFromDom(outputDir, dom);
+     * </ul>
+     * 
+     * plus if we are not generating for a reference element
+     * <ul>
+     * <li>createWrapperCPPFromDom(outputDir, dom);
+     * <li>createWrapperHeaderFromDom(outputDir, dom);
+     * <ul>
+     * Each of the create.... methods calls createOutputFromDom with a different
+     * style sheet.
+     *  
+     */
+    public static void handleInterfaceHeader(Map parameters,
+            boolean forReference) throws Exception {
+        boolean failed = false;
+
+        String type = null;
+        if (forReference) {
+            type = "reference";
+        } else {
+            type = "service";
+        }
+        String interfaceHeaderFilename = (String) parameters
+                .get("/componentType/" + type + "/interface.cpp/@header");
+
+        String componentTypeFileHeaderName = interfaceHeaderFilename;
+
+        String sca_module_root =  (String) Options.getOption("-dir");
+        parameters.put("module_root", sca_module_root);
+
+        if (sca_module_root != null && interfaceHeaderFilename != null
+                && interfaceHeaderFilename.length() > 0) {
+            String separator;
+            // Stick in a "/" (File.separator) if required.
+            if ((interfaceHeaderFilename.substring(0, 1).equals("/") || sca_module_root
+                    .substring(sca_module_root.length() - 1,
+                            sca_module_root.length()).equals("/"))
+                    || (interfaceHeaderFilename.substring(0, 1).equals("\\") || sca_module_root
+                            .substring(sca_module_root.length() - 1,
+                                    sca_module_root.length()).equals("\\"))
+
+            ) {
+                separator = "";
+            } else {
+                separator = File.separator;
+            }
+            interfaceHeaderFilename = sca_module_root + separator
+                    + interfaceHeaderFilename;
+        }
+
+        File outputDir = (File) parameters.get("targetDirectoryFile");
+
+        String[] args = new String[] { "-source", interfaceHeaderFilename,
+                "-target", outputDir.getPath() };
+        ServicesGenerator gen = new ServicesGenerator(args);
+        File file;
+        try {
+            if (null == interfaceHeaderFilename) {
+                gen.printUsage();
+                System.exit(-1);
+            }
+
+            file = new File(interfaceHeaderFilename);
+            if (!file.isFile()) {
+                if (file.isDirectory()) {
+                    Utils
+                            .rude("This tool works at the header file level and not for directories like "
+                                    + file);
+                }
+                Utils.rude("Bad file or directory " + file);
+            }
+            File source = file;
+            if (!outputDir.exists() && !outputDir.mkdir())
+                Utils.rude("Failed to create directory " + outputDir);
+
+            // The class below is the one that will go through the header
+            // file(s)
+            Headers headers = new Headers();
+
+            if (null != interfaceHeaderFilename) {
+                Utils.postEvent(Utils.DEPLOYMENT_ARTEFACT_ENCOUNTERED, file
+                        .getAbsolutePath());
+                Utils.postEvent(Utils.EVENT_TYPE_FILE_PARSED,
+                        "Scagen processing C++ interface header "
+                                + file.getAbsolutePath());
+                headers.actOnFile(file, outputDir, 1);
+                Utils.outputDebugString("Parsing files...");
+            }
+
+            String nameOfSorR = null;
+            String referenceName = null;
+            String serviceName = null;
+
+            if (forReference) {
+
+                Object rn = parameters.get("/componentType/reference/@name");
+
+                if (rn instanceof String) {
+                    referenceName = (String) rn;
+                    nameOfSorR = referenceName;
+                }
+            } else {
+
+                Object sn = parameters.get("/componentType/service/@name");
+
+                if (sn instanceof String) {
+                    serviceName = (String) sn;
+                    nameOfSorR = serviceName;
+                }
+            }
+
+            String moduleXmlFileHeader = null;
+            String moduleXmlFileHeaderNoExt = null;
+            Object moduleh = parameters
+                    .get("/module/component/implementation.cpp/@header");
+
+            if (moduleh == null) {
+                moduleh = parameters
+                        .get("/moduleFragment/component/implementation.cpp/@header");
+            }
+
+            if (moduleh instanceof String) {
+                File f = new File((String) moduleh);
+                moduleXmlFileHeader = (String) moduleh;
+
+                String fname = f.getName();
+                moduleXmlFileHeaderNoExt = fname.substring(0, fname
+                        .lastIndexOf('.'));
+
+            }
+
+            String implClassNameAttrFromModuleFile = (String) parameters
+                    .get("implClass");
+
+            String interfaceClassNameAttrFromComponentTypeFile;
+            if (forReference) {
+                interfaceClassNameAttrFromComponentTypeFile = (String) parameters
+                        .get("/componentType/reference/interface.cpp/@class");
+            } else {
+                interfaceClassNameAttrFromComponentTypeFile = (String) parameters
+                        .get("/componentType/service/interface.cpp/@class");
+            }
+
+            List methods = headers.getAllMethods();
+
+            // Pull out one of the methods' namespace attributes.
+            String intfNamespace = null;
+            if (methods.size() > 0) {
+                Signature method = (Signature) methods.get(0);
+                intfNamespace = method.getNamespace();
+            }
+
+            if (interfaceClassNameAttrFromComponentTypeFile != null) {
+                methods = filterToPublicMethodsOfGivenClass(methods,
+                        interfaceClassNameAttrFromComponentTypeFile, true);
+            } else {
+                //We want to filter to methods of the class whose
+                //name matches the header file name.
+                //      String intfClassName = (String) parameters.get("intfClass");
+                //
+                String headerFileBase = file.getName().replaceAll(
+                        "\\.h|\\.hpp|\\.h++", "");
+
+                methods = filterToPublicMethodsOfGivenClass(methods,
+                        headerFileBase, false);
+            }
+
+            Document dom = createDOMofMethods(methods, source, serviceName,
+                    referenceName, nameOfSorR, null,
+                    componentTypeFileHeaderName, moduleXmlFileHeader,
+                    moduleXmlFileHeaderNoExt, intfNamespace,
+                    interfaceClassNameAttrFromComponentTypeFile,
+                    implClassNameAttrFromModuleFile);
+
+            createProxyCPPFromDom(outputDir, dom);
+            createProxyHeaderFromDom(outputDir, dom);
+
+            if (!forReference) {
+                createWrapperCPPFromDom(outputDir, dom);
+                createWrapperHeaderFromDom(outputDir, dom);
+            }
+
+        } catch (Exception exception) {
+            exception.printStackTrace();
+            failed = true;
+        }
+
+        if (failed) {
+            Utils.outputDebugString("Finished! (but encountered problems)");
+            System.exit(-2);
+        }
+    }
+
+    /**
+     * This methods takes a list of methods and filters them to only contain the
+     * public methods of the given class
+     * 
+     * @param methods
+     *            a list of methods
+     * @param className
+     *            we will return a list of only this classes methods from the
+     *            methods parameter
+     * @param attrSpecified
+     *            if the user does not specify one we ignore namespaces
+     * @return
+     */
+    private static List filterToPublicMethodsOfGivenClass(List methods,
+            String className, boolean useNamespace) {
+        if (methods != null && className != null && className.length() > 0) {
+            for (Iterator iter = methods.listIterator(); iter.hasNext();) {
+                Signature method = (Signature) iter.next();
+                String scope = method.getScope();
+                String sig = method.getOriginal();
+                String namespace = method.getNamespace();
+
+                String qualifiedClassName;
+                if (useNamespace && null != namespace && 0 < namespace.length()) {
+                    qualifiedClassName = namespace + "::"
+                            + method.getTrimClassName();
+                } else {
+                    qualifiedClassName = method.getTrimClassName();
+                }
+
+                // If we are not public or the classname does not match
+                // remove...
+                if (!qualifiedClassName.equals(className)
+                        || -1 == scope.indexOf("public")) {
+                    iter.remove();
+                }
+            }
+        }
+        return methods;
+    }
+
+    /**
+     * Use an XSLT transformation to create a Proxy "view" of the DOM
+     * information
+     * 
+     * @param outputDir
+     *            where to put the C++
+     * @param dom
+     *            the DOM of semantic method information
+     * @throws TransformerException
+     */
+    private static void createProxyCPPFromDom(File outputDir, Document dom)
+            throws TransformerException {
+
+        //Create the Filename from the Service Name in the DOM
+        if (dom == null) {
+            return;
+        }
+
+        String serviceOrReferenceName = "noSorRNameDefined";
+
+        String implClass = "nomoduleXmlFileHeaderDefined";
+
+        Element topNode = dom.getDocumentElement();
+        if (null != topNode) {
+            Attr attr = topNode.getAttributeNode("nameOfSorR");
+            if (attr != null) {
+                serviceOrReferenceName = attr.getNodeValue();
+            }
+
+            attr = topNode.getAttributeNode("implClass");
+            if (attr != null) {
+                implClass = attr.getNodeValue();
+            }
+        }
+
+        File proxyCPP = new File(outputDir, implClass + "_"
+                + serviceOrReferenceName + "_Proxy.cpp");
+        if (null != proxyCPP) {
+
+            Utils.postEvent(Utils.DEPLOYMENT_ARTEFACT_GENERATED, proxyCPP
+                    .getAbsolutePath());
+            Utils.postEvent(Utils.EVENT_TYPE_FILE_CREATE,
+                    "Scagen creating SCA for C++ proxy implementation "
+                            + proxyCPP.getAbsolutePath());
+        }
+
+        createOutputFromDom(dom, proxyCPP,
+                "org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyCPP.xsl");
+
+    }
+
+    /**
+     * Use an XSLT transformation to create a Wrapper "view" of the DOM
+     * information
+     * 
+     * @param outputDir
+     *            where to put the C++
+     * @param dom
+     *            the DOM of semantic method information
+     * @throws TransformerException
+     */
+    private static void createWrapperCPPFromDom(File outputDir, Document dom)
+            throws TransformerException {
+
+        //Create the Filename from the Service Name in the DOM
+        if (dom == null) {
+            return;
+        }
+
+        String serviceName = "noServiceDefined";
+
+        String implClass = "nomoduleXmlFileHeaderDefined";
+
+        Element topNode = dom.getDocumentElement();
+        if (null != topNode) {
+            Attr attr = topNode.getAttributeNode("serviceName");
+            if (attr != null) {
+                serviceName = attr.getNodeValue();
+            }
+
+            attr = topNode.getAttributeNode("implClass");
+            if (attr != null) {
+                implClass = attr.getNodeValue();
+            }
+        }
+
+        File wrapperCPP = new File(outputDir, implClass + "_" + serviceName
+                + "_Wrapper.cpp");
+        if (null != wrapperCPP) {
+            Utils.postEvent(Utils.DEPLOYMENT_ARTEFACT_GENERATED, wrapperCPP
+                    .getAbsolutePath());
+            Utils.postEvent(Utils.EVENT_TYPE_FILE_CREATE,
+                    "Scagen creating SCA for C++ wrapper implementation "
+                            + wrapperCPP.getAbsolutePath());
+        }
+        createOutputFromDom(dom, wrapperCPP,
+                "org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperCPP.xsl");
+
+    }
+
+    /**
+     * Use an XSLT transformation to create a Proxy header "view" of the DOM
+     * information
+     * 
+     * @param outputDir
+     *            where to put the C++
+     * @param dom
+     *            the DOM of sematic method information
+     * @throws TransformerException
+     */
+    private static void createProxyHeaderFromDom(File outputDir, Document dom)
+            throws TransformerException {
+
+        //Create the Filename from the Service Name in the DOM
+        if (dom == null) {
+            return;
+        }
+
+        String serviceOrReferenceName = "noServiceDefined";
+        String intfClass = "noInterfaceClassNameOrDefaultDefined";
+        String implClass = "noImplementationClassOrDefaultDefined";
+
+        Element topNode = dom.getDocumentElement();
+        if (null != topNode) {
+            Attr attr = topNode.getAttributeNode("nameOfSorR");
+            if (attr != null) {
+                serviceOrReferenceName = attr.getNodeValue();
+            }
+            attr = topNode.getAttributeNode("intfClass");
+            if (attr != null) {
+                intfClass = attr.getNodeValue();
+            }
+            attr = topNode.getAttributeNode("implClass");
+            if (attr != null) {
+                implClass = attr.getNodeValue();
+            }
+        }
+
+        File proxyHeader = new File(outputDir, implClass + "_"
+                + serviceOrReferenceName + "_Proxy.h");
+        if (null != proxyHeader) {
+            Utils.postEvent(Utils.DEPLOYMENT_ARTEFACT_GENERATED, proxyHeader
+                    .getAbsolutePath());
+            Utils.postEvent(Utils.EVENT_TYPE_FILE_CREATE,
+                    "Scagen creating SCA for C++ proxy header "
+                            + proxyHeader.getAbsolutePath());
+        }
+
+        createOutputFromDom(dom, proxyHeader,
+                "org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyHeader.xsl");
+
+    }
+
+    /**
+     * Use an XSLT transformation to create a Wrapper header "view" of the DOM
+     * information
+     * 
+     * @param outputDir
+     *            where to put the C++
+     * @param dom
+     *            the DOM of sematic method information
+     * @throws TransformerException
+     */
+    private static void createWrapperHeaderFromDom(File outputDir, Document dom)
+            throws TransformerException {
+
+        //Create the Filename from the Service Name in the DOM
+        if (dom == null) {
+            return;
+        }
+
+        String serviceName = "noServiceDefined";
+
+        String implClass = "nomoduleXmlFileHeaderDefined";
+
+        Element topNode = dom.getDocumentElement();
+        if (null != topNode) {
+            Attr attr = topNode.getAttributeNode("serviceName");
+            if (attr != null) {
+                serviceName = attr.getNodeValue();
+            }
+
+            attr = topNode.getAttributeNode("implClass");
+            if (attr != null) {
+                implClass = attr.getNodeValue();
+            }
+        }
+
+        File wrapperHeader = new File(outputDir, implClass + "_" + serviceName
+                + "_Wrapper.h");
+
+        if (null != wrapperHeader) {
+            Utils.postEvent(Utils.DEPLOYMENT_ARTEFACT_GENERATED, wrapperHeader
+                    .getAbsolutePath());
+            Utils.postEvent(Utils.EVENT_TYPE_FILE_CREATE,
+                    "Scagen creating SCA for C++ wrapper header "
+                            + wrapperHeader.getAbsolutePath());
+        }
+        createOutputFromDom(dom, wrapperHeader,
+                "org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperHeader.xsl");
+
+    }
+
+    /**
+     * This method will return a class loader that can see the resources that
+     * are parts of "this" package.
+     */
+    private static ClassLoader getALoader() {
+
+        LittleClass lc;
+        try {
+            lc = new LittleClass();
+            return lc.getClass().getClassLoader();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * This method will generically process the DOM using a stylesheet passed
+     * in.
+     * 
+     * @param dom
+     *            the source of data (the model)
+     * @param outputFile
+     *            where to put the result
+     * @param xslTransformationFileName
+     *            the xsl file containing the "view"
+     * @throws TransformerException
+     */
+    private static void createOutputFromDom(Document dom, File outputFile,
+            String xslTransformationFileName) throws TransformerException {
+        
+        if(Options.noGenerate()){
+            return;
+        }
+        
+        InputStream stream = getALoader().getResourceAsStream(
+                xslTransformationFileName);
+        StreamSource ss = new StreamSource(stream);
+        StreamResult out = new StreamResult(outputFile);
+        try {
+            Transformer xslt = txmf.newTransformer(ss);
+
+            // Unless a width is set, there will be only line breaks but no
+            // indentation.
+            // The IBM JDK and the Sun JDK don't agree on the property name,
+            // so we set them both.
+            //
+            try {
+                xslt.setOutputProperty(
+                        "{http://xml.apache.org/xalan}indent-amount", "2");
+            } catch (Throwable t) {
+                //OK to ignore this, depends on XSLT engine and one will fail
+            }
+            try {
+                xslt.setOutputProperty(
+                        "{http://xml.apache.org/xslt}indent-amount", "2");
+            } catch (Throwable t) {
+                //OK to ignore this, depends on XSLT engine and one will fail
+            }
+
+            DOMSource from = new DOMSource(dom);
+
+            xslt.transform(from, out);
+
+        } catch (TransformerConfigurationException e) {
+            e.printStackTrace();
+            throw (e);
+        } catch (TransformerException e) {
+            e.printStackTrace();
+            throw (e);
+        } finally {
+            try {
+                stream.close();
+            } catch (IOException e1) {
+                // unlikely but if
+                // we can't close it, we can't close it
+            }
+        }
+
+    }
+
+    //TODO clear up the parameter list below to make it smaller if
+    // possible
+    /**
+     * This method will create A DOM containing all the semantic information
+     * that it can extract from a C++ header file.
+     * 
+     * @param methods
+     *            a list of methods that are going into the DOM
+     * @param source
+     *            the header file the methods came from
+     * @param serviceName
+     *            the name of the service
+     * @referenceName the name of the reference
+     * @nameOfSorR the non null one of the two parameters above
+     * @headerClassName the name of the header class
+     * @param moduleXmlFileImplHeaderNameWithPathAndExt
+     *            the source filename
+     * @param moduleXmlFileHeaderNoExtorPath
+     *            the shortname of the source file
+     * @param implClass
+     *            the implementation class
+     * @param intfClass
+     *            the interface we are turning into a service
+     * @return
+     */
+    private static Document createDOMofMethods(List methods, File source,
+            String serviceName, String referenceName, String nameOfSorR,
+            String headerClassName,
+            String componentTypeXmlFileIntfHeaderNameWithPathAndExt,
+            String moduleXmlFileImplHeaderNameWithPathAndExt,
+            String moduleXmlFileHeaderNoExtorPath, String intfNamespace,
+            String intfClass, String implClass) {
+
+        if (methods == null) {
+            return null;
+        }
+
+        // Create a DOM of the methods
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        Document document = null;
+        try {
+            DocumentBuilder builder = factory.newDocumentBuilder();
+            document = builder.newDocument();
+
+            Element root = (Element) document.createElement(CPP_HEADER);
+
+            root.setAttribute(HEADER_NAME_ATTR, source.getPath());
+
+            document.appendChild(root);
+
+            Element intf = (Element) document.createElement(SCA_SERVICE);
+            root.appendChild(intf);
+
+            // Go through all the signatures we have collected...
+            Signature s = null;
+            for (Iterator iter = methods.iterator(); iter.hasNext();) {
+                s = (Signature) iter.next();
+
+                // Each signature is an operation
+                Element op = document.createElement(SCA_OPERATION);
+                op.setAttribute(OPERATION_NAME_ATTR, s.getMethodName());
+                intf.appendChild(op);
+
+                Parameter[] parms = s.getParameters();
+                if (parms != null) {
+
+                    for (int i = 0; i < parms.length; i++) {
+                        Element parm = (Element) document
+                                .createElement(SCA_OPERATION_PARAMETER);
+                        String type_string = parms[i].getTypeWithoutConst()
+                                .toString();
+
+                        type_string = type_string.replaceAll(":: ", "::");
+
+                        Text text = document.createTextNode(type_string);
+                        parm.appendChild(text);
+                        parm.setAttribute(SCA_OPERATION_PARAMETER_NAME_ATTR,
+                                parms[i].getName());
+
+                        if (parms[i].getTypeWithoutConst().intern() != parms[i]
+                                .getType().intern()) {
+                            parm.setAttribute(
+                                    SCA_OPERATION_PARAMETER_CONST_ATTR, "true");
+                        }
+
+                        op.appendChild(parm);
+                        // TO DO only really stores the value
+                        // unsafely/temporarily
+                        // which is fine while we handle everything at the
+                        // end of parsing the "leaf" that represents that actual
+                        // interface/service but the below will cause the second
+                        // service
+                        // processed to overwite the first one in the DOM. I we
+                        // wish
+                        // to do some overall processing at the end we will have
+                        // to
+                        // use a better more XPath like key that varies by
+                        // instance
+                        // of the service.
+                        intf.setAttribute(SCA_INTERFACE_NAME_ATTR, s
+                                .getTrimClassName());
+                    }
+                }
+
+                Element rc = document.createElement(SCA_OPERATION_RETURN_TYPE);
+                rc.appendChild(document.createTextNode(s.getReturnType()
+                        .toString().replaceAll(":: ", "::")));
+                op.appendChild(rc);
+
+                root.appendChild(intf);
+            }
+
+            // Set the name of the Service
+            // here, if we are not passed one we use
+            // the classname from the last header function signature...
+            if (serviceName == null && s != null) {
+                serviceName = s.getTrimClassName();
+            }
+
+            // this is used for the proxy file name but we need to
+            // use the reference name if this is pulled in due to it
+            // being a reference!!!
+            if (serviceName != null)
+                root.setAttribute("serviceName", serviceName);
+            if (referenceName != null)
+                root.setAttribute("referenceName", referenceName);
+            if (nameOfSorR != null)
+                root.setAttribute("nameOfSorR", nameOfSorR);
+
+            if (implClass != null) {
+                root.setAttribute("implClass", implClass);
+            } else {
+                root.setAttribute("implClass", moduleXmlFileHeaderNoExtorPath);
+            }
+
+            // default class name to the name of the header...
+            if (headerClassName == null && source != null) {
+                headerClassName = source.getName().replaceAll(
+                        "\\.h|\\.hpp|\\.h++", "");
+            }
+            root.setAttribute("headerClassName", headerClassName);
+
+            if (null == intfClass) {
+                intfClass = headerClassName;
+            }
+
+            if (null != intfNamespace) {
+                root.setAttribute("namespace", intfNamespace);
+                if (null != intfClass && !intfClass.startsWith(intfNamespace)) {
+                    intfClass = intfNamespace + "::" + intfClass;
+                }
+            }
+
+            root.setAttribute("intfClass", intfClass);
+
+            if (componentTypeXmlFileIntfHeaderNameWithPathAndExt == null) {
+                componentTypeXmlFileIntfHeaderNameWithPathAndExt = "componentTypeHeader";
+            }
+            root.setAttribute("componentTypeHeader",
+                    componentTypeXmlFileIntfHeaderNameWithPathAndExt);
+
+            if (moduleXmlFileImplHeaderNameWithPathAndExt == null) {
+                moduleXmlFileImplHeaderNameWithPathAndExt = "moduleXmlFileImplHeader";
+            }
+            root.setAttribute("moduleXmlFileHeader",
+                    moduleXmlFileImplHeaderNameWithPathAndExt);
+
+            if (moduleXmlFileHeaderNoExtorPath == null) {
+                moduleXmlFileHeaderNoExtorPath = "moduleXmlFileHeaderNoExt";
+            }
+            root.setAttribute("moduleXmlFileHeaderNoExt",
+                    moduleXmlFileHeaderNoExtorPath);
+
+        } catch (ParserConfigurationException pce) {
+            // Parser with specified options can't be built
+            pce.printStackTrace();
+        }
+
+        return document;
+
+    }
+
+}
\ No newline at end of file

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/ServicesGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/ServicesGenerator.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/XMLFileActor.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/XMLFileActor.java?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/XMLFileActor.java (added)
+++ incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/XMLFileActor.java Thu Jan  5 02:54:16 2006
@@ -0,0 +1,202 @@
+/*
+ *
+ *  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.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+
+import org.apache.tuscany.sca.cpp.tools.common.FileActor;
+import org.apache.tuscany.sca.cpp.tools.common.Utils;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/**
+ * The purpose of this abstract class is to provide a home for the standard
+ * processing that is involved in turning a XML file into an internal DOM.
+ */
+public abstract class XMLFileActor implements FileActor {
+
+    protected static Map handlers = new HashMap();
+
+    protected static Map parameters = new HashMap();
+
+    public boolean failed;
+    
+    private int filesActedOn=0;
+
+    protected static TransformerFactory transformerFactory = TransformerFactory
+            .newInstance();
+
+    /**
+     * This method is the main FileActor method
+     * 
+     * @see FileActor#actOnFile(File, File, int) Here we create an initial DOM
+     *      and kick off the processing (using the handler map that has been set
+     *      up by the concrete subclass).
+     * 
+     * @param moduleXML
+     *            the sca.module or fragment file
+     * @param target
+     *            the target directory
+     * @param depth
+     *            not uesed here but in the
+     * @see FileActor#actOnFile(File, File, int) interface to allow for
+     *      recursive diving into a directory structure.
+     */
+    public void actOnFile(File moduleXML, File target, int depth)
+            throws Exception {
+
+        if (null == moduleXML || null == target) {
+            return;
+        }
+
+        filesActedOn++;
+        
+        parameters.put("sourceFile", moduleXML);
+        parameters.put("targetFile", target);
+
+        if (transformerFactory.getFeature(DOMSource.FEATURE)
+                && transformerFactory.getFeature(DOMResult.FEATURE)) {
+            Document dom = createDomFromXMLFile(moduleXML);
+            if (dom != null) {
+                parameters.put("targetDirectoryFile", target);
+                DomHandler.handleDom(dom, handlers, parameters);
+            }
+        }
+    }
+
+    /**
+     * This method builds an in memory DOM from an XML file
+     * 
+     * @param xmlSourceFile
+     *            the XML file we are handling
+     * @return the resulting document
+     */
+    protected Document createDomFromXMLFile(File xmlSourceFile) {
+        Document dom = null;
+        DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
+        //We do not validate via f.setValidating(true);
+        f.setNamespaceAware(true);
+
+        try {
+            DocumentBuilder parser = f.newDocumentBuilder();
+            dom = parser.parse(xmlSourceFile);
+        } catch (SAXException sxe) {
+            String path;
+            try {
+                path = xmlSourceFile.getCanonicalPath();
+            } catch (IOException e) {
+                path = xmlSourceFile.getPath();
+            }
+            Utils.screenMessage("There has been a SAXException of type "
+                    + sxe.getLocalizedMessage());
+            if (null != xmlSourceFile) {
+                Utils.screenMessage(" when processing file " + path);
+            } else {
+                Utils.screenMessage(" as the input file is null.");
+            }
+
+// Leave for possible future debug option
+//            Utils.screenMessage(" The returned Java exception is below.");
+//            if (sxe.getException() != null)
+//                sxe.getException().printStackTrace();
+//            else
+//                sxe.printStackTrace();
+        } catch (ParserConfigurationException pce) {
+            String path;
+            try {
+                path = xmlSourceFile.getCanonicalPath();
+            } catch (IOException e) {
+                path = xmlSourceFile.getPath();
+            }
+            Utils
+                    .screenMessage("There has been a ParserConfigurationException of type "
+                            + pce.getLocalizedMessage());
+            if (null != xmlSourceFile) {
+                Utils.screenMessage(" when processing file " + path);
+            } else {
+                Utils.screenMessage(" as the input file is null.");
+            }
+            
+//          Leave for possible future debug option
+//          Utils.screenMessage(" The returned Java exception is below.");
+//          pce.printStackTrace();
+            
+        } catch (IOException ioe) {
+            String path;
+            try {
+                path = xmlSourceFile.getCanonicalPath();
+            } catch (IOException e) {
+                path = xmlSourceFile.getPath();
+            }
+            
+            Utils.screenMessage("Unable to open file  " + path);
+            Utils.screenMessage(this.getContextMessage());
+            
+            
+            
+        }
+
+        return dom;
+    }
+
+    /**
+     * @return an error message - usually over-ridden.
+     */
+    private String getContextMessage() {
+        return "Check the file exists and can be read.";
+    }
+
+    /**
+     * Set a parameter
+     * 
+     * @param name
+     * @param value
+     */
+    public void setParameter(String name, Object value) {
+        parameters.put(name, value);
+    }
+
+    /**
+     * Get a parameter
+     * 
+     * @param name
+     * @param value
+     * @return the value of the parameter
+     */
+    public Object getParameter(String name, Object value) {
+        return parameters.get(name);
+    }
+
+
+
+    /**
+     * @return Returns the filesActedOn.
+     */
+    public int getFilesActedOn() {
+        return filesActedOn;
+    }
+}
\ No newline at end of file

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/XMLFileActor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/XMLFileActor.java
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/package.html
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/package.html?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/package.html (added)
+++ incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/package.html Thu Jan  5 02:54:16 2006
@@ -0,0 +1,140 @@
+<html>
+
+<head>
+<title>Design documentation for org\apache\tuscany\sca\cpp\tools\services</title>
+</head>
+
+<body lang=EN-GB>
+
+<div class=Section1>
+
+<h1>Overview</h1>
+
+
+
+<p>This package contains classes that generate C++ wrappers and
+proxies for C++ implementations of SCA services. </p>
+
+<h2>What the package does</h2>
+
+<p>The Scagen class main method will take in an input and
+output directory name. The input directory is taken to be the SCA module root
+directory.  The tool will generate the wrapper and proxy headers and methods
+bodies in the output directory. </p>
+
+<p>These proxies and wrappers enable the SCA for C++ runtime to
+act as a conduit for SCA C++ calls in a type free manner. Client code can call
+the type specific functions that are in the generated proxy classes. The call
+is marshalled into a generic format and a SCA for C++ runtime function with a
+standard signature is invoked. The details of the call are passed as data. </p>
+
+<p>On the other end of the runtime, a generated function with a
+standard signature is called, this function will inspect the data that
+represents the call’s method name and call the appropriate type specific
+function in the C++ implementation. </p>
+
+<h2>The Input Data Used</h2>
+
+<p>The input directory passed to the Scagen method is taken to
+be the SCA module root directory. All the sca.module and .fragment files in
+that directory are inspected to resolve all the &lt;component/&gt; elements
+within them. </p>
+
+<p>Each &lt;component/&gt; element found is inspected to see if
+it has a &lt;implementation.cpp/&gt; element within it. </p>
+
+<p>Each &lt;implementation.cpp/&gt; element should have a
+header attribute that represents a C++ header file that contains function
+prototypes for the C++ implementation of the service. An optional class
+attribute can be used to select one class if more than one that is present in
+the header file. The default class is the one with the same name as the header
+file. The tool will verify that the implementation header contains an
+appropriate class prototype. </p>
+
+
+
+<p>The directory that contains the implementation header should
+also contain a matching .componentType file for the equivalent SCA component. So
+for example, a MyServiceImpl.h file would have a corresponding MyServiceImpl.componentType
+file in the same directory. </p>
+
+
+
+<p>Each componentType file is inspected for &lt;service/&gt;
+and &lt;reference/&gt; elements. For each &lt;service/&gt; element that is
+found that contains a &lt;interface.cpp/&gt; element within it,</p>
+
+<p>the header attribute of the &lt;interface.cpp/&gt; is taken
+as the filename of the C++ interface header for the SCA service.  This C++
+header file is opened and used as a means for specifying the SCA service
+resulting in an appropriate wrapper and proxy being generated for this service
+interface. Both method bodies and headers are generated in the given output
+directory. The processing of a &lt;reference/&gt; element is the same except
+that only a proxy header and implementation are generated. </p>
+
+
+
+
+
+<h2>Outline Design: How it Works</h2>
+
+
+
+<p>The basic approach is to scan in the XML files by first
+creating a DOM document tree of them and then recursively rifling through the DOM 
+with some generic code in the XMLFileActorClass by default this processing will
+build up a map which maps the XPath location of attributes to their values.
+Additionally subclasses can add to a “handlers map” which maps from the name of
+a particular element to an object that implements the DomNodeHandler interface.
+If the XMLFileActor code comes across any element that has an equivalent handler
+in the handler map the objects handleNode method will be called. </p>
+
+<p>Typically the DomNodeHandler’s handle node interface will
+use XPath to pull out the parameters that it is interested in from the
+parameters map that is being built up by the generic code. </p>
+
+<p>This design was chosen as the Java level specified for the
+original implementation did not have direct XPath query of XML data but it was
+known that this would be available in Java 1.5 onwards. The design allows the
+DOM and parameters map handling to be replaced in the future with JRE 1.5 code
+with less impact on the rest of the code.</p>
+
+
+
+<p>The processing leads to the parsing of the C++ interface
+files using the org\apache\tuscany\sca\cpp\tools\common package. This results
+in a Headers object</p>
+
+<p>that contains a List of Signature objects, each one
+representing a function prototype found in the header. </p>
+
+
+
+<p>We are aiming to get all the semantic data we want to use
+into a DOM document (this represents the model of our input data) and then use
+XSLT to create the 4 different views of this data:</p>
+
+<p>Proxy C++ header</p>
+
+<p>Proxy C++  body</p>
+
+<p>Wrapper C++ header</p>
+
+<p>Wrapper C++ body</p>
+
+
+
+<p>So we prepopulate the DOM with parameter data that comes
+from the XML files and then iterate through the Signatures that are returned
+from the C++ header parser transferring the useful data into the DOM. </p>
+
+
+
+<p>We than use 4 XSLT stylesheets to generate the C++ output
+files as required. </p>
+
+</div>
+
+</body>
+
+</html>

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyCPP.xsl
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyCPP.xsl?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyCPP.xsl (added)
+++ incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyCPP.xsl Thu Jan  5 02:54:16 2006
@@ -0,0 +1,391 @@
+<!-- 
+/* 
+ *
+ *  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 WARRANTY
+ */ 
+
+ TODO There is duplication in the "..no_parms" templates with
+      the equivalent templates they are based on - that it would be 
+      fairly easy to factor out. 
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<!-- Part of the org.apache.tuscany.sca.cpp.tools.services packages
+  - 
+  -  This stylesheet creates the CPP implementation of the 
+  -  proxy body for a given SCA service
+  --> 
+<xsl:output method="text"/>
+ 
+<!-- Delete cppScopes -->
+<xsl:template match="cppScope"></xsl:template>
+
+<!-- Delete private methods cppScopes -->
+<xsl:template match="scaOperation[@cppScope='private']">
+</xsl:template>
+
+<!-- Delete private methods cppScopes -->
+<xsl:template match="scaOperationReturnType">
+</xsl:template>
+
+
+<!-- -->
+<!-- CPP Header/Root -->
+<!-- -->
+<xsl:template match="cppHeader">/*
+ *  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.
+ */
+
+<xsl:apply-templates select="scaService" mode="include_header"/>
+
+#include "osoa/sca/sca.h"
+using namespace osoa::sca;
+using namespace tuscany::sca;<!-- thats the prologue over nad done with
+     now continue with the scaServiceElement -->
+<xsl:apply-templates/> <!-- should go on to generic scaService -->
+</xsl:template>
+  
+<!-- -->
+<!-- Service -->
+<!-- -->
+<xsl:template match="scaService">
+<xsl:variable name="clazz">
+   <xsl:value-of select="../@implClass"/>
+   <xsl:text>_</xsl:text>
+   <xsl:value-of select="../@nameOfSorR"/>
+   <xsl:text>_Proxy</xsl:text>
+</xsl:variable>
+<xsl:text>
+extern "C"
+{
+
+    #if defined(WIN32) || defined(_WINDOWS)
+    __declspec(dllexport) 
+    #endif
+    </xsl:text><xsl:value-of select="$clazz"/>
+<xsl:text>* </xsl:text>
+<xsl:value-of select="$clazz"/>
+<xsl:text>_Factory(ServiceWrapper* target)
+    {
+        return new </xsl:text><xsl:value-of select="$clazz"/><xsl:text>(target);
+    }
+
+    #if defined(WIN32) || defined(_WINDOWS)
+    __declspec(dllexport) 
+    #endif
+    void </xsl:text>
+<xsl:value-of select="$clazz"/>
+<xsl:text>_Destructor(void* proxy)
+    {
+        delete (</xsl:text><xsl:value-of select="$clazz"/><xsl:text>*)proxy;
+    }
+}
+
+</xsl:text>
+<xsl:value-of select="$clazz"/><xsl:text>::</xsl:text><xsl:value-of select="$clazz"/>(ServiceWrapper* targ) : target(targ)
+{
+}
+
+<xsl:value-of select="$clazz"/><xsl:text>::~</xsl:text><xsl:value-of select="$clazz"/>()
+{
+    if (target)
+        delete target;
+}
+<xsl:apply-templates/>
+<!-- Always make sure we have a (visible) final newline -->
+<xsl:text>
+
+</xsl:text>
+</xsl:template>  
+
+<xsl:template match="scaService" mode="include_header">
+<xsl:variable name="clazz">
+   <xsl:value-of select="../@implClass"/>
+   <xsl:text>_</xsl:text>
+   <xsl:value-of select="../@nameOfSorR"/>
+   <xsl:text>_Proxy</xsl:text>
+</xsl:variable>
+<xsl:text>#include "</xsl:text>
+<xsl:value-of select="$clazz"/>
+<xsl:text>.h"</xsl:text>
+</xsl:template>
+
+
+
+<!-- -->
+<!-- Operation -->
+<!-- -->
+<xsl:template match="scaOperation">
+<xsl:variable name="clazz">
+   <xsl:value-of select="../../@implClass"/>
+   <xsl:text>_</xsl:text>
+   <xsl:value-of select="../../@nameOfSorR"/>
+   <xsl:text>_Proxy</xsl:text>
+</xsl:variable>
+
+<xsl:if test="@operationNameAttr != $clazz
+             and @operationNameAttr != concat('~', $clazz)" >
+<xsl:text>
+</xsl:text>
+<xsl:value-of select="scaOperationReturnType"/>
+<xsl:text> </xsl:text>
+<xsl:value-of select="$clazz"/><xsl:text>::</xsl:text>
+<xsl:value-of select="@operationNameAttr"/><xsl:text>(</xsl:text>
+<xsl:if test="count(scaOperationParameter)=0">
+<xsl:text>)
+{</xsl:text>
+<xsl:call-template name="proxy_method_body_no_parms"/>
+<xsl:text>
+}
+</xsl:text> 
+</xsl:if>
+
+<xsl:for-each select="scaOperationParameter">
+
+<xsl:if test=".='void'"> 
+<xsl:text>)
+{</xsl:text>
+<xsl:call-template name="proxy_method_body"/>
+<xsl:text>
+}
+</xsl:text>
+</xsl:if>
+
+<xsl:if test=".!='void'"> 
+    <xsl:variable name="scaOperationParameterNameAttr">
+                <xsl:value-of select="concat('arg', position()-1 )"/>
+    </xsl:variable>
+    <xsl:variable name="isConst">
+       <xsl:value-of select="@scaOperationParameterConstAttr"/>
+    </xsl:variable>
+    <xsl:if test="contains($isConst,'true')">const</xsl:if><xsl:text> </xsl:text>
+    <xsl:value-of select="."/> <!-- get the actual type -->
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="$scaOperationParameterNameAttr"/>
+  <xsl:choose>
+     <xsl:when test="position()=last()"><xsl:text>)
+{</xsl:text>
+<xsl:call-template name="proxy_method_body"/>
+<xsl:text>
+}
+</xsl:text> 
+</xsl:when>
+     <xsl:otherwise>
+        <xsl:text>, </xsl:text>
+     </xsl:otherwise>
+  </xsl:choose>
+</xsl:if>
+
+</xsl:for-each>      
+</xsl:if>
+</xsl:template>
+
+
+
+
+<xsl:template name="proxy_method_body">
+   <xsl:variable name="noOfParms">
+      <xsl:choose>
+        <xsl:when test=".='void'">
+<xsl:text>0</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:value-of select="last()"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+<xsl:text>
+    Operation operation("</xsl:text>
+    <xsl:value-of select="../@operationNameAttr"/>
+    <xsl:text>", </xsl:text>
+    <xsl:value-of select="$noOfParms"/>
+    <xsl:text>);</xsl:text>
+    <xsl:if test="$noOfParms!=0">
+    <xsl:for-each select="../scaOperationParameter">
+        <xsl:call-template name="proxy_method_body_set_parameter"/>
+    </xsl:for-each>
+    </xsl:if>
+<xsl:text>
+ </xsl:text>
+    <xsl:call-template name="proxy_method_body_prepare_return_var"/>
+    <xsl:text>
+    target-&gt;invoke(operation);
+</xsl:text>
+    <xsl:call-template name="proxy_method_body_return"/>
+</xsl:template>
+
+<xsl:template name="proxy_method_body_no_parms">
+   <xsl:variable name="noOfParms">
+       <xsl:value-of select="0"/>
+    </xsl:variable>
+<xsl:text>
+    Operation operation("</xsl:text>
+    <xsl:value-of select="@operationNameAttr"/>
+    <xsl:text>", </xsl:text>
+    <xsl:value-of select="$noOfParms"/>
+    <xsl:text>);
+ </xsl:text>
+    <xsl:call-template name="proxy_method_body_prepare_return_var_no_parms"/>
+    <xsl:text>
+    target-&gt;invoke(operation);
+</xsl:text>
+    <xsl:call-template name="proxy_method_body_return_no_parms"/>
+</xsl:template>
+
+
+<xsl:template name="proxy_method_body_return">
+    <xsl:variable name="type">
+        <xsl:value-of select="../scaOperationReturnType/text()"/>
+    </xsl:variable>
+    <xsl:choose>
+        <xsl:when test="$type='void'"><!-- nothing -->
+            <xsl:text>    return;
+</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, '&amp;')"><!-- reference -->
+            <xsl:variable name="type_no_amp">
+                <xsl:value-of select="substring-before($type, '&amp;')"/>
+            </xsl:variable>
+            <xsl:text>    return *(</xsl:text><xsl:value-of select="$type_no_amp"/><xsl:text>*)operation.getReturnValue();
+</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, '*')"><!-- pointer -->
+            <xsl:text>    return (</xsl:text><xsl:value-of select="$type"/><xsl:text>)operation.getReturnValue();
+</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, 'DataObjectPtr')"><!-- DataObjectPtr -->
+        <xsl:text>    return ret; 
+</xsl:text>
+        </xsl:when>
+        <xsl:otherwise><!-- simple type -->
+        <xsl:text>    return ret;
+</xsl:text>
+        </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<xsl:template name="proxy_method_body_return_no_parms">
+    <xsl:variable name="type">
+        <xsl:value-of select="scaOperationReturnType/text()"/>
+    </xsl:variable>
+    <xsl:choose>
+        <xsl:when test="$type='void'"><!-- nothing -->
+            <xsl:text>    return;
+</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, '&amp;')"><!-- reference -->
+            <xsl:variable name="type_no_amp">
+                <xsl:value-of select="substring-before($type, '&amp;')"/>
+            </xsl:variable>
+            <xsl:text>    return *(</xsl:text><xsl:value-of select="$type_no_amp"/><xsl:text>*)operation.getReturnValue();
+</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, '*')"><!-- pointer -->
+            <xsl:text>    return (</xsl:text><xsl:value-of select="$type"/><xsl:text>)operation.getReturnValue();
+</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, 'DataObjectPtr')"><!-- DataObjectPtr -->
+        <xsl:text>    return ret; 
+</xsl:text>
+        </xsl:when>
+        <xsl:otherwise><!-- simple type -->
+        <xsl:text>    return ret;
+</xsl:text>
+        </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+
+<xsl:template name="proxy_method_body_prepare_return_var">
+    <xsl:variable name="type">
+        <xsl:value-of select="../scaOperationReturnType/text()"/>
+    </xsl:variable>
+    <xsl:choose>
+        <xsl:when test="$type='void'"><!-- nothing -->
+        <!--  nothing -->
+        </xsl:when>
+        <xsl:when test="contains($type, '&amp;')"><!-- reference -->
+        </xsl:when>
+        <xsl:when test="contains($type, '*')"><!-- pointer -->
+        <!-- nothing to do -->
+        </xsl:when>
+        <xsl:when test="contains($type, 'DataObjectPtr')"><!-- DataObjectPtr -->
+        <xsl:text>    commonj::sdo::DataObjectPtr ret = 0;
+    operation.setReturnValue((void*)&amp;ret);
+</xsl:text>
+        </xsl:when>
+        <xsl:otherwise><!-- simple type - for some reason the inital tab does not appear -->
+<xml:text>
+    </xml:text><xml:text>
+    </xml:text><xsl:value-of select="$type"/><xsl:text> ret;
+</xsl:text>
+<xsl:text>    operation.setReturnValue((void*)&amp;ret);</xsl:text>
+        </xsl:otherwise>
+    </xsl:choose>
+
+</xsl:template>
+ 
+<xsl:template name="proxy_method_body_prepare_return_var_no_parms">
+    <xsl:variable name="type">
+        <xsl:value-of select="scaOperationReturnType/text()"/>
+    </xsl:variable>
+    <xsl:choose>
+        <xsl:when test="$type='void'"><!-- nothing -->
+        <!--  nothing -->
+        </xsl:when>
+        <xsl:when test="contains($type, '&amp;')"><!-- reference -->
+        </xsl:when>
+        <xsl:when test="contains($type, '*')"><!-- pointer -->
+        <!-- nothing to do -->
+        </xsl:when>
+        <xsl:when test="contains($type, 'DataObjectPtr')"><!-- DataObjectPtr -->
+        <xsl:text>    commonj::sdo::DataObjectPtr ret = 0;
+    operation.setReturnValue((void*)&amp;ret);
+</xsl:text>
+        </xsl:when>
+        <xsl:otherwise><!-- simple type - for some reason the inital tab does not appear -->
+<xml:text>
+    </xml:text><xml:text>
+    </xml:text><xsl:value-of select="$type"/><xsl:text> ret;
+</xsl:text>
+<xsl:text>    operation.setReturnValue((void*)&amp;ret);</xsl:text>
+        </xsl:otherwise>
+    </xsl:choose>
+
+</xsl:template>
+
+<xsl:template name="proxy_method_body_set_parameter">
+    <xsl:variable name="scaOperationParameterNameAttrInner">
+                <xsl:value-of select="concat('arg', position()-1 )"/>
+    </xsl:variable>
+    <xsl:variable name="type">
+        <xsl:value-of select="."/>
+    </xsl:variable>
+    operation.setParameter(<xsl:value-of select="position()-1"/><xsl:text>, (void*)</xsl:text>
+<xsl:if test="not(contains($type, '*'))">&amp;</xsl:if>
+<xsl:value-of select="$scaOperationParameterNameAttrInner"/>
+<xsl:text>);
+</xsl:text>
+</xsl:template>
+</xsl:stylesheet>

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyCPP.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyCPP.xsl
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyHeader.xsl
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyHeader.xsl?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyHeader.xsl (added)
+++ incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyHeader.xsl Thu Jan  5 02:54:16 2006
@@ -0,0 +1,215 @@
+<!-- 
+/* 
+ *
+ *  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 WARRANTY
+ */ 
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<!-- Part of the org.apache.tuscany.sca.cpp.tools.services packages
+  - 
+  -  This stylesheet creates the CPP implementation of the 
+  -  proxy header for a given SCA service
+  -->
+
+    <xsl:output method="text" />
+
+    <!-- Delete cppScopes -->
+    <xsl:template match="cppScope"></xsl:template>
+
+    <!-- Delete private methods cppScopes -->
+    <xsl:template match="scaOperation[@cppScope='private']">
+    </xsl:template>
+
+    <!-- Delete private methods cppScopes -->
+    <xsl:template match="scaOperationReturnType"></xsl:template>
+
+
+    <!-- -->
+    <!-- CPP Header/Root -->
+    <!-- -->
+    <xsl:template match="cppHeader">
+        <xsl:variable name="class">
+               <xsl:value-of select="concat(@implClass, '_', @nameOfSorR, '_Proxy')"/>    
+        </xsl:variable>
+<xsl:text>/* 
+ *  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.
+ */
+
+</xsl:text>
+        <xsl:call-template name="ifndef_start">
+            <xsl:with-param name="class" 
+                            select="$class"/>
+        </xsl:call-template>
+
+
+        <xsl:call-template name="include_headers">
+            <xsl:with-param name="componentTypeHeader" 
+                            select="@componentTypeHeader"/>
+        </xsl:call-template>
+
+        <xsl:apply-templates select="scaService" mode="class_body"/>
+
+        <xsl:call-template name="ifndef_end">
+            <xsl:with-param name="class" 
+                            select="$class"/>
+        </xsl:call-template>
+<!-- Always make sure we have a (visible) final newline -->
+<xsl:text>
+
+</xsl:text>
+</xsl:template>
+
+
+<!-- Here are the subroutine templates in order -->
+
+    <xsl:template name="ifndef_start">
+        <!--For example,  
+            #ifndef CustomerInfoImpl_CustomerInfoService_Proxy_h
+            #define CustomerInfoImpl_CustomerInfoService_Proxy_h
+        -->
+        <xsl:param name="class"/>
+        <xsl:text>#ifndef </xsl:text><xsl:value-of select="$class"/><xsl:text>_h</xsl:text>
+<!-- newline -->
+<xsl:text>
+</xsl:text>
+        <xsl:text>#define </xsl:text><xsl:value-of select="$class"/><xsl:text>_h</xsl:text>
+<!-- newline -->
+<xsl:text>
+
+</xsl:text>
+    </xsl:template>
+
+    <xsl:template name="include_headers">
+        <!--For example,  
+            #include "CustomerInfo.h"
+            #include "tuscany/sca/core/ServiceWrapper.h"
+        -->
+        <xsl:param name="componentTypeHeader"/>
+        <xsl:text>#include "</xsl:text><xsl:value-of select="translate($componentTypeHeader,'\','/')"/><xsl:text>"</xsl:text>
+<!-- newline -->
+<xsl:text>
+</xsl:text>
+        <xsl:text>#include "tuscany/sca/core/ServiceWrapper.h"</xsl:text>
+    </xsl:template>
+
+    <xsl:template match="scaService" mode="class_body">
+        <!--For example
+            class proxyclassname : public interface_class
+            {
+             constructor
+             destructor
+                 then apply operation templates for operations
+            };
+
+            E.g. Specifically
+
+            class CustomerInfoImpl_CustomerInfoService_Proxy : public CustomerInfo
+            {
+            public:
+                CustomerInfoImpl_CustomerInfoService_Proxy(tuscany::sca::ServiceWrapper*);
+                virtual ~CustomerInfoImpl_CustomerInfoService_Proxy();
+                virtual const char* getCustomerInformation(const char* customerID);
+            private:
+                tuscany::sca::ServiceWrapper* target;
+            };                 
+        -->
+        <!-- TODO second definition, remove? -->
+        <xsl:variable name="class">
+               <xsl:value-of select="concat(../@implClass, '_', ../@nameOfSorR, '_Proxy')"/>    
+        </xsl:variable>
+<xsl:text>
+
+class </xsl:text>
+<xsl:value-of select="$class"/>
+<xsl:text> : public </xsl:text><xsl:value-of select="../@intfClass"/>
+<xsl:text>
+{
+public:
+    </xsl:text><xsl:value-of select="$class"/><xsl:text>(tuscany::sca::ServiceWrapper*);</xsl:text>
+    <xsl:text>
+    virtual ~</xsl:text><xsl:value-of select="$class"/><xsl:text>();
+</xsl:text>
+    <!-- operations -->
+    <xsl:apply-templates/>
+<xsl:text>private:
+    tuscany::sca::ServiceWrapper* target;
+};
+</xsl:text>
+    </xsl:template>
+
+    <xsl:template name="ifndef_end">
+        <!--For example,  
+            #endif // CustomerInfoImpl_CustomerInfoService_Proxy_h          
+        -->
+        <xsl:param name="class"/>
+        <xsl:text>
+#endif // </xsl:text><xsl:value-of select="$class"/><xsl:text>_h</xsl:text>
+    </xsl:template>
+
+
+
+
+
+
+<!-- Operation -->
+<!--For example 
+    virtual const char* getCustomerInformation(const char* customerID);
+-->
+<xsl:template match="scaOperation">
+<xsl:variable name="class">
+    <xsl:value-of select="concat(../../@implClass, '_', ../../@nameOfSorR, '_Proxy')"/>    
+</xsl:variable>
+<xsl:if test="@operationNameAttr != $class
+             and @operationNameAttr != concat('~', $class)" >
+<xsl:text>    virtual </xsl:text>
+<xsl:value-of select="scaOperationReturnType"/>
+<xsl:text> </xsl:text>
+<xsl:value-of select="@operationNameAttr"/><xsl:text>(</xsl:text>
+<xsl:for-each select="scaOperationParameter">
+     <xsl:variable name="isConst">
+        <xsl:value-of select="@scaOperationParameterConstAttr"/>
+     </xsl:variable>
+     <xsl:variable name="noOfParms">
+        <xsl:value-of select="last()"/>
+     </xsl:variable>
+     <xsl:if test="contains($isConst,'true')">const</xsl:if><xsl:text> </xsl:text>
+          <xsl:value-of select="."/> <!-- get the actual type -->
+     <xsl:text> </xsl:text>
+     <xsl:value-of select="@scaOperationParameterNameAttr"/>
+  <xsl:choose>
+     <xsl:when test="position()=last()"></xsl:when>
+     <xsl:otherwise>
+        <xsl:text>, </xsl:text>
+     </xsl:otherwise>
+  </xsl:choose>
+  </xsl:for-each> 
+<xsl:text>);
+</xsl:text>
+</xsl:if>
+</xsl:template>
+</xsl:stylesheet>
+
+
+

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyHeader.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfProxyHeader.xsl
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperCPP.xsl
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperCPP.xsl?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperCPP.xsl (added)
+++ incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperCPP.xsl Thu Jan  5 02:54:16 2006
@@ -0,0 +1,278 @@
+<!-- 
+/* 
+ *
+ *  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 WARRANTY
+ */ 
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<!-- Part of the org.apache.tuscany.sca.cpp.tools.services packages
+  - 
+  -  This stylesheet creates the CPP implementation of the 
+  -  wrapper body for a given SCA service
+  --> 
+<xsl:output method="text"/>
+ 
+<!-- Delete cppScopes -->
+<xsl:template match="cppScope"></xsl:template>
+
+<!-- Delete private methods cppScopes -->
+<xsl:template match="scaOperation[@cppScope='private']">
+</xsl:template>
+
+<!-- Don't act on return types -->
+<xsl:template match="scaOperationReturnType">
+</xsl:template>
+
+
+<!-- -->
+<!-- CPP Header/Root -->
+<!-- -->
+<xsl:template match="cppHeader">/* 
+ *  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.
+ */
+
+<xsl:apply-templates select="scaService" mode="include_header"/>
+
+#include "osoa/sca/sca.h"
+using namespace osoa::sca;
+using namespace tuscany::sca;
+<!-- thats the prologue over and done with
+     now continue with the scaServiceElement -->
+<xsl:apply-templates/> <!-- will be applied to scaService -->
+<!-- Always make sure we have a final newline -->
+<xsl:text>
+
+</xsl:text>
+</xsl:template>
+  
+<!-- -->
+<!-- Service -->
+<!-- -->
+<xsl:template match="scaService">
+<xsl:variable name="class">
+   <xsl:value-of select="../@implClass"/>
+   <xsl:text>_</xsl:text>
+   <xsl:value-of select="../@serviceName"/>
+   <xsl:text>_Wrapper</xsl:text>
+</xsl:variable>
+<xsl:text>extern "C"
+{
+
+    #if defined(WIN32) || defined(_WINDOWS)
+    __declspec(dllexport) 
+    #endif
+    </xsl:text><xsl:value-of select="$class"/>
+<xsl:text>* </xsl:text>
+<xsl:value-of select="$class"/>
+<xsl:text>_Factory(tuscany::sca::model::Service* target)
+    {
+        return new </xsl:text><xsl:value-of select="$class"/><xsl:text>(target);
+    }
+}
+
+</xsl:text>
+<xsl:value-of select="$class"/><xsl:text>::</xsl:text><xsl:value-of select="$class"/><xsl:text>(Service* target) : ComponentServiceWrapper(target)
+{
+    impl = (</xsl:text><xsl:value-of select="../@implClass"/><xsl:text>*)getImplementation();
+}
+
+</xsl:text>
+<xsl:value-of select="$class"/><xsl:text>::~</xsl:text><xsl:value-of select="$class"/><xsl:text>()
+{
+    releaseImplementation();
+}
+
+void* </xsl:text>
+<xsl:value-of select="$class"/><xsl:text>::newImplementation()
+{
+    return new </xsl:text><xsl:value-of select="../@implClass"/><xsl:text>;
+}
+
+void </xsl:text>
+<xsl:value-of select="$class"/><xsl:text>::deleteImplementation()
+{
+    delete impl;
+}
+
+void </xsl:text><xsl:value-of select="$class"/><xsl:text>::invokeService(Operation&amp; operation)
+{
+    const string&amp; operationName = operation.getName();
+
+</xsl:text>
+<xsl:apply-templates/><!-- an if statment for each operation -->
+<xsl:text>        
+
+    throw ServiceRuntimeException("Invalid operation");
+    
+}</xsl:text>
+</xsl:template>  
+
+<xsl:template match="scaService" mode="include_header">
+<xsl:variable name="class">
+   <xsl:value-of select="../@implClass"/>
+   <xsl:text>_</xsl:text>
+   <xsl:value-of select="../@serviceName"/>
+   <xsl:text>_Wrapper</xsl:text>
+</xsl:variable>
+<xsl:text>#include "</xsl:text>
+<xsl:value-of select="$class"/>
+<xsl:text>.h"</xsl:text>
+</xsl:template>
+
+<!-- -->
+<!-- Operation -->
+<!-- -->
+<xsl:template match="scaOperation">
+<!--For example
+    if (operationName == "getCustomerInformation")
+    {
+        operation.setReturnValue(impl->getCustomerInformation((const char*)parms[0]));
+        return;
+    }
+-->
+<xsl:if test="@operationNameAttr != ../../@intfClass
+             and @operationNameAttr != concat('~', ../../@intfClass)" >
+<xsl:text>    if (operationName == "</xsl:text>
+<xsl:value-of select="@operationNameAttr"/>
+<xsl:text>")
+    {
+</xsl:text>
+            <xsl:call-template name="this_operation_body"/>
+<xsl:text>
+    }
+</xsl:text>
+
+</xsl:if>
+</xsl:template>
+
+<xsl:template name="this_operation_body">
+<xsl:if test="./scaOperationParameter/text() != 'void' ">
+  <xsl:if test="normalize-space(./scaOperationParameter/text()) != ' ' ">
+    <xsl:if test="./scaOperationParameter/text() != '' ">
+    <xsl:for-each select="scaOperationParameter">
+            <xsl:call-template name="prepare_parameter_n"/>
+    </xsl:for-each> 
+  </xsl:if>
+  </xsl:if>
+</xsl:if>
+<xsl:call-template name="invoke_for_return_type"/>
+<xsl:text>
+        return;</xsl:text>
+</xsl:template>
+
+<xsl:template name="prepare_parameter_n">
+     <xsl:variable name="isConst">
+        <xsl:value-of select="@scaOperationParameterConstAttr"/>
+     </xsl:variable>
+    <xsl:variable name="type">
+        <xsl:value-of select="."/>
+    </xsl:variable>
+<xsl:text>        </xsl:text>
+    <xsl:choose>
+        <xsl:when test="contains($type, '&amp;')"><!-- reference -->
+            <xsl:variable name="type_no_amp">
+                <xsl:value-of select="substring-before($type, '&amp;')"/>
+            </xsl:variable>
+            <xsl:value-of select="$type"/><xsl:text> p</xsl:text><xsl:value-of select="position()-1"/><xsl:text> = *(</xsl:text><xsl:value-of select="$type_no_amp"/>
+             <xsl:text>*)operation.getParameter(</xsl:text><xsl:value-of select="position()-1"/><xsl:text>);
+</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, '*')"><!-- pointer -->
+            <xsl:if test="contains($isConst,'true')">const </xsl:if>
+            <xsl:value-of select="."/><xsl:text> p</xsl:text><xsl:value-of select="position()-1"/><xsl:text> = (</xsl:text>
+             <xsl:if test="contains($isConst,'true')">const</xsl:if><xsl:text> </xsl:text>
+              <xsl:value-of select="$type"/>
+             <xsl:text>)operation.getParameter(</xsl:text><xsl:value-of select="position()-1"/><xsl:text>);
+</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, 'DataObjectPtr')"><!-- DataObjectPtr -->
+            <xsl:text>DataObjectPtr&amp; p</xsl:text><xsl:value-of select="position()-1"/><xsl:text> = *(DataObjectPtr*)operation.getParameter(</xsl:text><xsl:value-of select="position()-1"/><xsl:text>);</xsl:text>
+        </xsl:when>
+        <xsl:otherwise><!-- simple type -->
+    <xsl:if test="contains($isConst,'true')">const </xsl:if><xsl:value-of select="$type"/><xsl:text>&amp; p</xsl:text><xsl:value-of select="position()-1"/><xsl:text> = *(</xsl:text>
+    <xsl:if test="contains($isConst,'true')">const</xsl:if><xsl:text> </xsl:text>
+          <xsl:value-of select="$type"/>
+     <xsl:text>*)operation.getParameter(</xsl:text><xsl:value-of select="position()-1"/><xsl:text>);
+</xsl:text>
+
+        </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<xsl:template name="invoke_for_return_type">
+    <xsl:variable name="type">
+        <xsl:value-of select="./scaOperationReturnType/text()"/>
+    </xsl:variable>
+    <xsl:choose>
+        <!-- VOID -->
+        <xsl:when test="$type='void'">
+<xsl:text>            </xsl:text>
+            <xsl:call-template name="impl_arrow_op_brackets_and_parms"/><xsl:text>;</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, '&amp;')"><!-- reference -->
+        <xsl:text>        </xsl:text><xsl:value-of select="$type"/><xsl:text> ret = </xsl:text><xsl:call-template name="impl_arrow_op_brackets_and_parms"/><xsl:text>;</xsl:text>
+        <xsl:text>
+        operation.setReturnValue((void*)&amp;ret);</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, '*')"><!-- pointer -->
+        <xsl:text>
+        operation.setReturnValue((void*) </xsl:text><xsl:call-template name="impl_arrow_op_brackets_and_parms"/><xsl:text>);</xsl:text>
+        </xsl:when>
+        <xsl:when test="contains($type, 'DataObjectPtr')"><!-- DataObjectPtr -->
+        <xsl:text>        *(DataObjectPtr*)operation.getReturnValue() = </xsl:text><xsl:call-template name="impl_arrow_op_brackets_and_parms"/><xsl:text>;</xsl:text>
+        </xsl:when>
+        <xsl:otherwise><!-- simple type -->
+            <xml:text>        *(</xml:text><xsl:value-of select="$type"/><xsl:text>*)operation.getReturnValue() = </xsl:text><xsl:call-template name="impl_arrow_op_brackets_and_parms"/><xsl:text>;</xsl:text>
+        </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
+
+<xsl:template name="impl_arrow_op_brackets_and_parms"><!-- context is "scaOperation" -->
+        <xml:text>impl-></xml:text><xsl:value-of select="./@operationNameAttr"/><xml:text>(</xml:text>
+<xsl:if test="./scaOperationParameter/text() != 'void' ">
+  <xsl:if test="./scaOperationParameter/text() != '' ">
+    <xsl:if test="normalize-space(./scaOperationParameter/text()) != ' ' ">
+    <xsl:for-each select="scaOperationParameter">
+            <xsl:call-template name="parameter_for_parameter_list"/>
+    </xsl:for-each>
+</xsl:if>
+</xsl:if>
+</xsl:if>
+<xsl:text>)</xsl:text>
+</xsl:template>
+
+<xsl:template name="parameter_for_parameter_list">
+<xsl:text>p</xsl:text><xsl:value-of select="position()-1"/>
+  <xsl:choose>
+     <xsl:when test="position()=last()"></xsl:when>
+     <xsl:otherwise>
+        <xsl:text>, </xsl:text>
+     </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+
+
+</xsl:stylesheet>

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperCPP.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperCPP.xsl
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperHeader.xsl
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperHeader.xsl?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperHeader.xsl (added)
+++ incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperHeader.xsl Thu Jan  5 02:54:16 2006
@@ -0,0 +1,178 @@
+<!-- 
+/* 
+ *
+ *  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 WARRANTY
+ */ 
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<!-- Part of the org.apache.tuscany.sca.cpp.tools.services packages
+  - 
+  -  This stylesheet creates the CPP implementation of the 
+  -  wrapper header for a given SCA service
+  -->
+    <xsl:output method="text" />
+
+    <!-- Delete cppScopes -->
+    <xsl:template match="cppScope"></xsl:template>
+
+    <!-- Delete private methods cppScopes -->
+    <xsl:template match="scaOperation[@cppScope='private']">
+    </xsl:template>
+
+    <!-- Delete private methods cppScopes -->
+    <xsl:template match="scaOperationReturnType"></xsl:template>
+
+
+    <!-- -->
+    <!-- CPP Header/Root -->
+    <!-- -->
+    <xsl:template match="cppHeader">
+        <xsl:variable name="class">
+               <xsl:value-of select="concat(@implClass, '_', @serviceName, '_Wrapper')"/>    
+        </xsl:variable>
+<xsl:text>/* 
+ *  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.
+ */
+
+</xsl:text>
+        <xsl:call-template name="ifndef_start">
+            <xsl:with-param name="class" 
+                            select="$class"/>
+        </xsl:call-template>
+
+
+        <xsl:call-template name="include_headers">
+            <xsl:with-param name="header" 
+                            select="@moduleXmlFileHeader"/>
+        </xsl:call-template>
+
+        <xsl:apply-templates select="scaService" mode="class_body"/>
+
+        <xsl:call-template name="ifndef_end">
+            <xsl:with-param name="class" 
+                            select="$class"/>
+        </xsl:call-template>
+<!-- Always make sure we have a (visible) final return -->
+<xsl:text>
+
+</xsl:text>
+</xsl:template>
+
+
+<!-- Here are the subroutine templates in order -->
+
+    <xsl:template name="ifndef_start">
+        <!--For example,  
+            #ifndef CustomerInfoImpl_CustomerInfoService_Wrapper_h
+            #define CustomerInfoImpl_CustomerInfoService_Wrapper_h
+        -->
+        <xsl:param name="class"/>
+        <xsl:text>#ifndef </xsl:text><xsl:value-of select="$class"/><xsl:text>_h</xsl:text>
+<!-- newline -->
+<xsl:text>
+</xsl:text>
+        <xsl:text>#define </xsl:text><xsl:value-of select="$class"/><xsl:text>_h</xsl:text>
+<!-- newline -->
+<xsl:text>
+
+</xsl:text>
+    </xsl:template>
+
+    <xsl:template name="include_headers">
+        <!--For example,  
+            #include "CustomerInfoImpl.h"
+            #include "tuscany/sca/core/ComponentServiceWrapper.h"
+        -->
+        <xsl:param name="header"/>
+        <xsl:text>#include "</xsl:text><xsl:value-of select="translate($header,'\','/')"/><xsl:text>"</xsl:text>
+<!-- newline -->
+<xsl:text>
+</xsl:text>
+        <xsl:text>#include "tuscany/sca/core/ComponentServiceWrapper.h"</xsl:text>
+    </xsl:template>
+
+    <xsl:template match="scaService" mode="class_body">
+        <!--For example
+            class wrapperclassname : public tuscany::sca::ComponentServiceWrapper
+            {
+             constructor
+             destructor
+                 then apply operation templates for operations
+            };
+
+            E.g. Specifically
+
+        class CustomerInfoImpl_CustomerInfoService_Wrapper : public tuscany::sca::ComponentServiceWrapper
+        {
+        public:
+            CustomerInfoImpl_CustomerInfoService_Wrapper(tuscany::sca::model::Component*);
+            virtual ~CustomerInfoImpl_CustomerInfoService_Wrapper();
+            virtual void invoke(tuscany::sca::Operation& operation);
+    
+        private:
+            CustomerInfoImpl* impl;
+        };
+        -->
+        <!-- TODO second definition, remove? -->
+        <xsl:variable name="class">
+               <xsl:value-of select="concat(../@implClass, '_', ../@serviceName, '_Wrapper')"/>    
+        </xsl:variable>
+<xsl:text>
+
+class </xsl:text>
+<xsl:value-of select="$class"/>
+<xsl:text> : public tuscany::sca::ComponentServiceWrapper
+{
+public:
+    </xsl:text><xsl:value-of select="$class"/><xsl:text>(tuscany::sca::model::Service* target);</xsl:text>
+    <xsl:text>
+    virtual ~</xsl:text><xsl:value-of select="$class"/><xsl:text>();
+    virtual void invokeService(tuscany::sca::Operation&amp; operation);
+    virtual void* newImplementation();
+    virtual void deleteImplementation();
+</xsl:text>
+<xsl:text>private:
+    </xsl:text>
+    <xsl:value-of select="../@implClass"/><xsl:text>* impl;
+};
+</xsl:text>
+    </xsl:template>
+
+    <xsl:template name="ifndef_end">
+        <!--For example,  
+            #endif // CustomerInfoImpl_CustomerInfoService_Wrapper_h          
+        -->
+        <xsl:param name="class"/>
+        <xsl:text>
+#endif // </xsl:text><xsl:value-of select="$class"/><xsl:text>_h</xsl:text>
+    </xsl:template>
+
+<xsl:template match="scaOperation">
+</xsl:template>
+
+</xsl:stylesheet>
+
+
+

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperHeader.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/tools/scagen/src/org/apache/tuscany/sca/cpp/tools/services/xsl/SCA4CPPIntfWrapperHeader.xsl
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/xsd/readme.txt
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/xsd/readme.txt?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/xsd/readme.txt (added)
+++ incubator/tuscany/cpp/sca/xsd/readme.txt Thu Jan  5 02:54:16 2006
@@ -0,0 +1,2 @@
+The XSDs describing the SCA model
+

Propchange: incubator/tuscany/cpp/sca/xsd/readme.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tuscany/cpp/sca/xsd/sca-binding-sca.xsd
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/xsd/sca-binding-sca.xsd?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/xsd/sca-binding-sca.xsd (added)
+++ incubator/tuscany/cpp/sca/xsd/sca-binding-sca.xsd Thu Jan  5 02:54:16 2006
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+ -->
+
+<schema	xmlns="http://www.w3.org/2001/XMLSchema" 
+		targetNamespace="http://www.osoa.org/xmlns/sca/0.9" 
+		xmlns:sca="http://www.osoa.org/xmlns/sca/0.9"
+		xmlns:sdo="commonj.sdo/XML"
+		elementFormDefault="qualified">
+
+	<include schemaLocation="sca-core.xsd"/>
+
+	<element name="binding.sca" type="sca:SCABinding" substitutionGroup="sca:binding" sdo:name="bindingSca"/>
+	<complexType name="SCABinding">
+		<complexContent>
+			<extension base="sca:Binding">
+				<sequence>
+					<any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+				</sequence>
+				<anyAttribute namespace="##any" processContents="lax"/>
+			</extension>
+		</complexContent>
+	</complexType>
+</schema>
\ No newline at end of file

Propchange: incubator/tuscany/cpp/sca/xsd/sca-binding-sca.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/xsd/sca-binding-sca.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev,Date



Mime
View raw message