ETCH-243 Small fixes in code generation

Change-Id: Ie04cb8b984f9fe3cdc6979da06c9346615f868c2

git-svn-id: https://svn.apache.org/repos/asf/incubator/etch/trunk@1399122 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java b/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java
index 7441196..c8d347a 100644
--- a/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java
+++ b/binding-cpp/compiler/src/main/java/org/apache/etch/bindings/cpp/compiler/Compiler.java
@@ -1184,25 +1184,26 @@
 
   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 @@
             "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 @@
   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 @@
     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 @@
       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 @@
         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 );
diff --git a/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_cpp.vm b/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_cpp.vm
index 2845e10..1545305 100644
--- a/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_cpp.vm
+++ b/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/intf_cpp.vm
@@ -83,7 +83,7 @@
  */
 $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)
diff --git a/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm b/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm
index b93757e..d1d79e9 100644
--- a/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm
+++ b/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/stub_h.vm
@@ -80,11 +80,12 @@
     $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())
diff --git a/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm b/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm
index ca0c33e..368539a 100644
--- a/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm
+++ b/binding-cpp/compiler/src/main/resources/org/apache/etch/bindings/cpp/compiler/vf_cpp.vm
@@ -106,9 +106,16 @@
 #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 );