You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by am...@apache.org on 2006/11/30 06:56:24 UTC

svn commit: r480845 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl: codegen/emitter/CEmitter.java codegen/emitter/CTypeInfo.java databinding/CUtils.java

Author: amilas
Date: Wed Nov 29 21:56:22 2006
New Revision: 480845

URL: http://svn.apache.org/viewvc?view=rev&rev=480845
Log:
Applied the patch for AXIS2-1778.

Added:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/CUtils.java
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java?view=diff&rev=480845&r1=480844&r2=480845
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java Wed Nov 29 21:56:22 2006
@@ -18,6 +18,7 @@
 import org.apache.axis2.wsdl.codegen.CodeGenerationException;
 import org.apache.axis2.wsdl.codegen.writer.*;
 import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.wsdl.databinding.CUtils;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.Utils;
 import org.apache.axis2.util.PolicyUtil;
@@ -317,10 +318,11 @@
     protected String makeCClassName(String word) {
         //currently avoid only java key words and service names with '.' characters
 
-        if (JavaUtils.isJavaKeyword(word)) {
-            return JavaUtils.makeNonJavaKeyword(word);
+        if (CUtils.isCKeyword(word)) {
+            return CUtils.makeNonCKeyword(word);
         }
-        return word.replace('.', '_');
+        String outWord = word.replace('.', '_');
+        return outWord.replace('-','_') ;
     }
 
 
@@ -333,7 +335,7 @@
      */
     protected boolean loadOperations(Document doc, Element rootElement, String mep) {
         Element methodElement;
-        String portTypeName = makeJavaClassName(axisService.getName());
+        String portTypeName = makeCClassName(axisService.getName());
 
         Iterator operations = axisService.getOperations();
         boolean opsFound = false;

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java?view=diff&rev=480845&r1=480844&r2=480845
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CTypeInfo.java Wed Nov 29 21:56:22 2006
@@ -74,7 +74,7 @@
         //as for the base 64 encoded binary stuff we map it to a javax.
         // activation.Datahandler object
         CTypeInfo.addTypemapping(XSD_BASE64,
-                "void*");
+                "axis2_base64_binary_t*");
 
         CTypeInfo.addTypemapping(XSD_HEXBIN,
                 "void*");
@@ -92,7 +92,7 @@
                 "int");
 
         // xsd:token
-        CTypeInfo.addTypemapping(XSD_TOKEN, "axiom_node_t*");
+        CTypeInfo.addTypemapping(XSD_TOKEN, "axis2_char_t*");
 
         // a xsd:normalizedString
         CTypeInfo.addTypemapping(XSD_NORMALIZEDSTRING,
@@ -143,7 +143,7 @@
         // addTypemapping(XML_LANG,Language.class.getName());
 
         // a xsd:language
-        CTypeInfo.addTypemapping(XSD_LANGUAGE, "axiom_node_t*");
+        CTypeInfo.addTypemapping(XSD_LANGUAGE, "axis2_char_t*");
 
         // a xsd:NmToken
         CTypeInfo.addTypemapping(XSD_NMTOKEN, "axiom_node_t*");

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/CUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/CUtils.java?view=auto&rev=480845
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/CUtils.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/databinding/CUtils.java Wed Nov 29 21:56:22 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.axis2.wsdl.databinding;
+
+import java.util.Arrays;
+import java.util.Locale;
+import java.text.Collator;
+
+public class CUtils {
+
+    static final String keywords[] =
+            {
+                    "auto", "double", "int", "struct",
+                    "break", "else", "long", "switch",
+                    "case", "enum", "register", "typedef",
+                    "char", "extern", "return", "union",
+                    "const", "float", "short", "unsigned",
+                    "continue", "for", "signed", "void",
+                    "default", "goto", "sizeof", "volatile",
+                    "do", "if", "static", "while"
+            };
+
+    /**
+     * Collator for comparing the strings
+     */
+    static final Collator englishCollator = Collator.getInstance(Locale.ENGLISH);
+
+    /**
+     * Use this character as suffix
+     */
+    static final char keywordPrefix = '_';
+
+
+    /**
+     * Checks if the input string is a valid C keyword.
+     *
+     * @return Returns boolean.
+     */
+    public static boolean isCKeyword(String keyword) {
+        return (Arrays.binarySearch(keywords, keyword, englishCollator) >= 0);
+    }
+
+    /**
+     * Turns a C keyword string into a non-C keyword string.  (Right now
+     * this simply means appending an underscore.)
+     */
+    public static String makeNonCKeyword(String keyword) {
+        return keywordPrefix + keyword;
+    }
+
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org