You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@etch.apache.org by ve...@apache.org on 2012/10/17 08:51:30 UTC

svn commit: r1399122 - in /incubator/etch/trunk/binding-cpp/compiler/src/main: java/org/apache/etch/bindings/cpp/compiler/ resources/org/apache/etch/bindings/cpp/compiler/

Author: veithm
Date: Wed Oct 17 06:51:30 2012
New Revision: 1399122

URL: http://svn.apache.org/viewvc?rev=1399122&view=rev
Log:
ETCH-243 Small fixes in code generation

Change-Id: Ie04cb8b984f9fe3cdc6979da06c9346615f868c2

Modified:
    incubator/etch/trunk/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java
    incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_cpp.vm
    incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm
    incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm

Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java?rev=1399122&r1=1399121&r2=1399122&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java Wed Oct 17 06:51:30 2012
@@ -1184,25 +1184,26 @@ public class Compiler extends Backend {
 
   private String getNativeArrayTypeName(TypeRef type) {
     Token t = type.type();
+    String nativeArrayName = "EtchNativeArray";
     switch (t.kind) {
     case EtchGrammarConstants.BOOLEAN:
-      return "Bool";
+      return nativeArrayName + "Bool";
     case EtchGrammarConstants.BYTE:
-      return "Byte";
+      return nativeArrayName + "Byte";
     case EtchGrammarConstants.SHORT:
-      return "Short";
+      return nativeArrayName + "Short";
     case EtchGrammarConstants.INT:
-      return "Int";
+      return nativeArrayName + "Int";
     case EtchGrammarConstants.LONG:
-      return "Long";
+      return nativeArrayName + "Long";
     case EtchGrammarConstants.FLOAT:
-      return "Float";
+      return nativeArrayName + "Float";
     case EtchGrammarConstants.DOUBLE:
-      return "Double";
+      return nativeArrayName + "Double";
     case EtchGrammarConstants.STRING:
-      return "String";
+      return nativeArrayName + "String";
     case EtchGrammarConstants.OBJECT:
-      return "Object";
+      return nativeArrayName + "Object";
     default: {
       // we have to use a fully qualified name here.
       // find the actual type...
@@ -1213,12 +1214,12 @@ public class Compiler extends Backend {
             "undefined or ambiguous name at line %d: %s", t.beginLine, t.image));
       if (n.isBuiltin()) {
         Builtin b = (Builtin) n;
-        return b.className().substring(4);
+        return nativeArrayName + b.className().substring(4);
       }
       if (n.isEnumx()) {
-        return n.efqname(this);
+        return nativeArrayName + n.efqname(this);
       } else {
-        return type.intf().name() + "::" + n.efqname(this);
+        return type.intf().name() + "::" + nativeArrayName + n.efqname(this);
       }
     }
     }
@@ -1257,9 +1258,9 @@ public class Compiler extends Backend {
   private String getArrayTypeName(TypeRef type, boolean pointer) {
     // TODO Auto-generated method stub
     if(pointer)
-      return "EtchNativeArray" + this.getNativeArrayTypeName( type ) + "Ptr";
+      return this.getNativeArrayTypeName( type ) + "Ptr";
     if (type.type().kind == EtchGrammarConstants.BYTE) {
-      return "EtchNativeArray<" + this.getNativeTypeName( type, true ) + "> ";
+      return "EtchNativeArray<" + this.getNativeTypeName( type, false ) + "> ";
     } else {
       return "EtchNativeArray<" + this.getNativeTypeName( type, true ) + "Ptr> ";
     }
@@ -1273,7 +1274,7 @@ public class Compiler extends Backend {
     case EtchGrammarConstants.BOOLEAN:
       return (etch_type ? "EtchBool" : "capu::bool_t");
     case EtchGrammarConstants.BYTE:
-      return (etch_type ? "capu::int8_t" : "capu::int8_t");
+      return (etch_type ? "EtchByte" : "capu::int8_t");
     case EtchGrammarConstants.SHORT:
       return (etch_type ? "EtchShort" : "capu::int16_t");
     case EtchGrammarConstants.INT:
@@ -1299,6 +1300,7 @@ public class Compiler extends Backend {
       if (n.isBuiltin()) {
         Builtin b = (Builtin) n;
         if (n.efqname(this).equals("EtchDate")) return b.className();
+        if (n.efqname(this).equals("EtchList")) return b.className()+"<EtchObjectPtr> ";
         if (n.efqname(this).equals("EtchHashTable")) return b.className()+"<EtchObjectPtr, EtchObjectPtr> ";
         if (n.efqname(this).equals("EtchHashSet")) return b.className()+"<EtchObjectPtr> ";
         throw new IllegalArgumentException(String.format(
@@ -1507,7 +1509,9 @@ public class Compiler extends Backend {
         if (n.efqname(this).equals("EtchHashSet")) {
           cn += "<EtchObjectPtr>";
         }
-
+        if (n.efqname(this).equals("EtchList")) {
+          cn += "<EtchObjectPtr>";
+        }
 
         /*
          * int i = cn.indexOf( '<' ); if (i >= 0) cn = cn.substring( 0, i );

Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_cpp.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_cpp.vm?rev=1399122&r1=1399121&r2=1399122&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_cpp.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_cpp.vm Wed Oct 17 06:51:30 2012
@@ -83,7 +83,7 @@ $class::$n.name()::$n.name()()
  */
 $class::$n.name()::$n.name()(#set($sep = "")#foreach($i in $n.getAllParameters())$sep$helper.getEtchTypeName($i.type(), true) $i.name() #set( $sep = ", " )#end)
 #if($n.hasExtends())
-  : $n.name()(#set($sep = "")#foreach($i in $n.getExtends().getAllParameters())$sep$i.name()#set( $sep = ", " ))#end
+  : $n.getExtends().name()(#set($sep = "")#foreach($i in $n.getExtends().getAllParameters())$sep$i.name()#set( $sep = ", " )#end)
 #else
 #if($n.isExcept())
   : EtchException("${n.name()}", ETCH_ERROR, EXCPTYPE_USERDEFINED)

Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm?rev=1399122&r1=1399121&r2=1399122&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm Wed Oct 17 06:51:30 2012
@@ -80,11 +80,12 @@ public:
     $helper.getEtchTypeName($param.type(), true) val$count = capu::smartpointer_cast<$helper.getEtchTypeName($param.type(), false)>(obj$count);
 
 #end
+## TODO: ADD AUTHENTICATION CODE HERE! ############################
     $intfname::$mthd.name()AsyncResultPtr ar;
 #set($sep = "")
 #set($count = 0)
     CAPU_LOG_TRACE(mRuntime->getLogger(), "Stub$i$suffix", "${namespace}: Calling implementation of \"$mthd.name()\" function.");
-    ar = _obj->$mthd.name()(#foreach($param in $mthd.iterator())#if($mthd.hasAuth())${sep}$param.name()#else#set($count = $count + 1)${sep}val$count#end#set($sep = ", ")#end);
+    ar = _obj->$mthd.name()(#foreach($param in $mthd.iterator())#set($count = $count + 1)${sep}val$count#set($sep = ", ")#end);
 
     // create result message
 #if($mthd.hasReturn())

Modified: incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm
URL: http://svn.apache.org/viewvc/incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm?rev=1399122&r1=1399121&r2=1399122&view=diff
==============================================================================
--- incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm (original)
+++ incubator/etch/trunk/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm Wed Oct 17 06:51:30 2012
@@ -106,9 +106,16 @@ public:
 #elseif ($n.isEnumx())
 #set( $tname = $n.efqname( $helper ) )
     
-class ImportExportHelper$n.vname( $helper )
-  : public EtchImportExportHelper {
-  public:
+class ImportExportHelper$n.vname( $helper ) 
+: public EtchImportExportHelper {  
+public:
+  ImportExportHelper$n.vname($helper)(EtchRuntime* runtime) 
+  : EtchImportExportHelper(runtime) {
+  }
+
+  virtual ~ImportExportHelper$n.vname($helper)() {
+  }
+
   status_t exportValue(EtchValueFactory* vf, EtchObjectPtr value, EtchStructValue *&result)
   {
      EtchStructValue* _struct = new EtchStructValue( $vf::${n.vname( $helper )}, vf );