qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ai...@apache.org
Subject svn commit: r886946 - in /qpid/trunk/qpid/dotnet/client-010/gentool: Composite.tpl Enum.tpl Invoker.tpl MethodDelegate.tpl build.xml codegen dotnetgenutil.py
Date Thu, 03 Dec 2009 22:13:23 GMT
Author: aidan
Date: Thu Dec  3 22:13:22 2009
New Revision: 886946

URL: http://svn.apache.org/viewvc?rev=886946&view=rev
Log:
QPID-1987: make code generation match .Net conventions.

Patch from julien.lavigne

Modified:
    qpid/trunk/qpid/dotnet/client-010/gentool/Composite.tpl
    qpid/trunk/qpid/dotnet/client-010/gentool/Enum.tpl
    qpid/trunk/qpid/dotnet/client-010/gentool/Invoker.tpl
    qpid/trunk/qpid/dotnet/client-010/gentool/MethodDelegate.tpl
    qpid/trunk/qpid/dotnet/client-010/gentool/build.xml
    qpid/trunk/qpid/dotnet/client-010/gentool/codegen
    qpid/trunk/qpid/dotnet/client-010/gentool/dotnetgenutil.py

Modified: qpid/trunk/qpid/dotnet/client-010/gentool/Composite.tpl
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/gentool/Composite.tpl?rev=886946&r1=886945&r2=886946&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/gentool/Composite.tpl (original)
+++ qpid/trunk/qpid/dotnet/client-010/gentool/Composite.tpl Thu Dec  3 22:13:22 2009
@@ -74,19 +74,19 @@
 
     public const int TYPE = $typecode;
 
-    public override int getStructType() {
+    public override int GetStructType() {
         return TYPE;
     }
 
-    public override int getSizeWidth() {
+    public override int GetSizeWidth() {
         return $size;
     }
 
-    public override int getPackWidth() {
+    public override int GetPackWidth() {
         return $pack;
     }
 
-    public $override bool hasPayload() {
+    public $override bool HasPayload() {
         return $payload;
     }
 
@@ -131,8 +131,8 @@
 
 if options or base == "Method":
   out("""
-        for (int i=0; i < _options.Length; i++) {
-            switch (_options[i]) {
+        for (int i=0; i < options.Length; i++) {
+            switch (options[i]) {
 """)
 
   for f in options:
@@ -143,26 +143,26 @@
             case Option.BATCH: Batch = true; break;
 """)
   out("""            case Option.NONE: break;
-            default: throw new Exception("invalid option: " + _options[i]);
+            default: throw new Exception("invalid option: " + options[i]);
             }
         }
 """)
 }
     }
 
-    public $override void dispatch<C>(C context, MethodDelegate<C> mdelegate)
{
-        mdelegate.$(dromedary(name))(context, this);
+    public $override void Dispatch<C>(C context, MethodDelegate<C> mdelegate)
{
+        mdelegate.$(name)(context, this);
     }
 
 ${
 for f in fields:
   if pack > 0:
     out("""
-    public  bool $(f.has)() {
+    public bool $(f.has)() {
         return (packing_flags & $(f.flag_mask(pack))) != 0;
     }
 
-    public  $name $(f.clear)() {
+    public $name $(f.clear)() {
         packing_flags = (byte) (packing_flags & ~$(f.flag_mask(pack)));       
 ${
 if (not f.empty and not (f.default == "null")):
@@ -174,7 +174,7 @@
 """)
 
   out("""
-    public  $(f.type) $(f.get)() {
+    public $(f.type) $(f.get)() {
 ${
 if f.empty:
   out("        return $(f.has)();")
@@ -183,7 +183,7 @@
 }
     }
 
-    public  $name $(f.set)($(f.type) value) {
+    public $name $(f.set)($(f.type) value) {
 ${
 if not f.empty:
   out("        _$(f.name) = value;")
@@ -196,9 +196,6 @@
         return this;
     }
 
-    public  $name $(f.name)($(f.type) value) {
-        return $(f.set)(value);
-    }
 """)
 }
 
@@ -209,18 +206,18 @@
         set { _header = value;}
 	      }
 	      
-    public  $name header(Header header) {
+    public $name SetHeader(Header header) {
         Header = header;
         return this;
     }
 
-    public  override MemoryStream Body
+    public override MemoryStream Body
     {
        get{ return _body;}
        set{ _body = value;}
     }
 
-    public  $name  body(MemoryStream body)
+    public $name  SetBody(MemoryStream body)
     {
         Body = body;
         return this;
@@ -228,11 +225,11 @@
 """)
 }
 
-    public override void write(Encoder enc)
+    public override void Write(IEncoder enc)
     {
 ${
 if pack > 0:
-  out("        enc.writeUint%s(packing_flags);\n" % (pack*8));
+  out("        enc.WriteUint%s(packing_flags);\n" % (pack*8));
 
 for f in fields:
   if f.empty:
@@ -246,15 +243,15 @@
   elif f.type_node.name == "domain":
     post = ""
     pre = "(short)"
-  out("        enc.write$(f.coder)($(pre)_$(f.name)$(post));\n")
+  out("        enc.Write$(f.coder)($(pre)_$(f.name)$(post));\n")
 }
     }
 
-    public override void read(Decoder dec)
+    public override void Read(IDecoder dec)
     {
 ${
 if pack > 0:
-   out("        packing_flags = ($(PACK_TYPES[pack])) dec.readUint%s();\n" % (pack*8));
+   out("        packing_flags = ($(PACK_TYPES[pack])) dec.ReadUint%s();\n" % (pack*8));
 
 for f in fields:
   if f.empty:
@@ -268,25 +265,25 @@
     pre = "(%s)" % cname(f.type_node)
     arg = "%s.TYPE" % cname(f.type_node)
   elif f.type_node.name == "domain":
-    pre = "%sGetter.get(" % cname(f.type_node)
+    pre = "%sGetter.Get(" % cname(f.type_node)
     post = ")"
-  out("        _$(f.name) = $(pre)dec.read$(f.coder)($(arg))$(post);\n")
+  out("        _$(f.name) = $(pre)dec.Read$(f.coder)($(arg))$(post);\n")
 }
     }
 
     public override Dictionary<String,Object> Fields
     {
-    get{
-        Dictionary<String,Object> result = new Dictionary<String,Object>();
+		get
+		{
+			Dictionary<String,Object> result = new Dictionary<String,Object>();
 
 ${
 for f in fields:
   if pack > 0:
-    out("        if ((packing_flags & $(f.flag_mask(pack))) != 0)\n    ")
-  out('        result.Add("_$(f.name)", $(f.get)());\n')
+    out("        	if ((packing_flags & $(f.flag_mask(pack))) != 0)\n    ")
+  out('        	result.Add("_$(f.name)", $(f.get)());\n')
 }
-
-        return result;
+			return result;
         }
     }
 

Modified: qpid/trunk/qpid/dotnet/client-010/gentool/Enum.tpl
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/gentool/Enum.tpl?rev=886946&r1=886945&r2=886946&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/gentool/Enum.tpl (original)
+++ qpid/trunk/qpid/dotnet/client-010/gentool/Enum.tpl Thu Dec  3 22:13:22 2009
@@ -21,7 +21,7 @@
 out("Getter")
 }
    {
-    public static $name get($vtype value)
+    public static $name Get($vtype value)
     {
         switch (value)
         {

Modified: qpid/trunk/qpid/dotnet/client-010/gentool/Invoker.tpl
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/gentool/Invoker.tpl?rev=886946&r1=886945&r2=886946&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/gentool/Invoker.tpl (original)
+++ qpid/trunk/qpid/dotnet/client-010/gentool/Invoker.tpl Thu Dec  3 22:13:22 2009
@@ -27,10 +27,10 @@
 namespace org.apache.qpid.transport
 {
 
-public abstract class Invoker {
+public abstract class Invoker : IInvoker {
 
-    protected abstract void invoke(Method method);
-    public abstract Future invoke(Method method, Future resultClass);
+    protected abstract void Invoke(Method method);
+    public abstract IFuture Invoke(Method method, IFuture resultClass);
 
 ${
 from dotnetgenutil import *
@@ -46,18 +46,18 @@
       rname = cname(result["struct"])
     else:
       rname = cname(result, "@type")
-    jresult = "Future" 
+    jresult = "IFuture" 
     jreturn = "return "
     jclass = ", new ResultFuture()" 
-    jinvoke = "invoke"
+    jinvoke = "Invoke"
   else:
-    jinvoke = "invoke"
+    jinvoke = "Invoke"
     jresult = "void"
     jreturn = ""
     jclass = ""
 
   out("""
-    public $jresult $(dromedary(name))($(", ".join(params))) {
+    public $jresult $(name)($(", ".join(params))) {
         $(jreturn)$jinvoke(new $name($(", ".join(args)))$jclass);
     }
 """)

Modified: qpid/trunk/qpid/dotnet/client-010/gentool/MethodDelegate.tpl
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/gentool/MethodDelegate.tpl?rev=886946&r1=886945&r2=886946&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/gentool/MethodDelegate.tpl (original)
+++ qpid/trunk/qpid/dotnet/client-010/gentool/MethodDelegate.tpl Thu Dec  3 22:13:22 2009
@@ -29,7 +29,7 @@
 
 for c in composites:
   name = cname(c)
-  out("    public virtual void $(dromedary(name))(C context, $name mystruct) {}\n")
+  out("    public virtual void $(name)(C context, $name mystruct) {}\n")
 }
 }
 }

Modified: qpid/trunk/qpid/dotnet/client-010/gentool/build.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/gentool/build.xml?rev=886946&r1=886945&r2=886946&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/gentool/build.xml (original)
+++ qpid/trunk/qpid/dotnet/client-010/gentool/build.xml Thu Dec  3 22:13:22 2009
@@ -43,7 +43,7 @@
       <arg value="${xml.spec.dir}/amqp.0-10-qpid-errata.xml"/>
       <arg value="${basedir}"/>
       <classpath>
-        <pathelement location="${java.basedir}/../lib/jython-2.2-rc2.jar"/>
+        <pathelement location="../../../java/lib/jython-2.5.0.jar"/>
       </classpath>
     </java>
     <touch file="${jython.timestamp}" />

Modified: qpid/trunk/qpid/dotnet/client-010/gentool/codegen
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/gentool/codegen?rev=886946&r1=886945&r2=886946&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/gentool/codegen (original)
+++ qpid/trunk/qpid/dotnet/client-010/gentool/codegen Thu Dec  3 22:13:22 2009
@@ -72,6 +72,7 @@
 execute("MethodDelegate.cs", "MethodDelegate.tpl", composites = composites)
 execute("Option.cs", "Option.tpl", composites = composites)
 execute("Invoker.cs", "Invoker.tpl", composites = controls + commands)
+execute("IInvoker.cs", "IInvoker.tpl", composites = controls + commands)
 execute("StructFactory.cs", "StructFactory.tpl", composites = composites)
 
 def is_enum(nd):

Modified: qpid/trunk/qpid/dotnet/client-010/gentool/dotnetgenutil.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/gentool/dotnetgenutil.py?rev=886946&r1=886945&r2=886946&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/gentool/dotnetgenutil.py (original)
+++ qpid/trunk/qpid/dotnet/client-010/gentool/dotnetgenutil.py Thu Dec  3 22:13:22 2009
@@ -20,14 +20,12 @@
 #
 
 
-def camel(offset, *args):
+def pascal(offset, *args):
   parts = []
   for a in args:
     parts.extend(a.split("-"))
-  return "".join(parts[:offset] + [p[0].upper() + p[1:] for p in parts[offset:]])
+  return "".join([p[0].upper() + p[1:] for p in parts[:offset]] + [p[0].upper() + p[1:] for
p in parts[offset:]])
 
-def dromedary(s):
-  return s[0].lower() + s[1:]
 
 def scream(*args):
   return "_".join([a.replace("-", "_").upper() for a in args])
@@ -132,11 +130,11 @@
     if (nd.name in ("struct", "result") and
         cls["@name"] != "session" and
         nd[field] != "header"):
-      return camel(0, nd[field])
+      return pascal(0, nd[field])
     else:
-      return camel(0, cls["@name"], nd[field])
+      return pascal(0, cls["@name"], nd[field])
   else:
-    return camel(0, nd[field])
+    return pascal(0, nd[field])
 
 def jtype(nd):
   if nd.name == "struct" or nd["enum"]:
@@ -178,7 +176,7 @@
 
   def __init__(self, index, nd):
     self.index = index
-    self.name = camel(1, nd["@name"])
+    self.name = pascal(1, nd["@name"])
     self.type_node = resolve_type(nd)
     if self.type_node.name == "domain":
       self.prim_type = resolve_type(self.type_node)
@@ -189,23 +187,23 @@
     self.empty = self.variable_width == 0 and self.fixed_width == 0 and self.prim_type.name
!= "struct"
     tname = cname(self.type_node)
     if self.type_node.name == "struct":
-      self.read = "(%s) dec.readStruct(%s.TYPE)" % (tname, tname)
-      self.write = "enc.writeStruct(%s.TYPE, check(struct).%s)" % (tname, self.name)
+      self.read = "(%s) dec.ReadStruct(%s.TYPE)" % (tname, tname)
+      self.write = "enc.WriteStruct(%s.TYPE, check(struct).%s)" % (tname, self.name)
       self.coder = "Struct"
     elif self.type_node.name == "domain":
-      self.coder = camel(0, self.prim_type["@name"])
-      self.read = "%s.get(dec.read%s())" % (tname, self.coder)
-      self.write = "enc.write%s(check(struct).%s.getValue())" % (self.coder, self.name)
-    else:
-      self.coder = camel(0, self.type_node["@name"])
-      self.read = "dec.read%s()" % self.coder
-      self.write = "enc.write%s(check(struct).%s)" % (self.coder, self.name)
+      self.coder = pascal(0, self.prim_type["@name"])
+      self.read = "%s.Get(dec.Read%s())" % (tname, self.coder)
+      self.write = "enc.Write%s(check(struct).%s.GetValue())" % (self.coder, self.name)
+    else:
+      self.coder = pascal(0, self.type_node["@name"])
+      self.read = "dec.Read%s()" % self.coder
+      self.write = "enc.Write%s(check(struct).%s)" % (self.coder, self.name)
     self.type = jtype(self.type_node)
     self.default = DEFAULTS.get(self.type, "null")
-    self.has = camel(1, "has", self.name)
-    self.get = camel(1, "get", self.name)
-    self.set = camel(1, "set", self.name)
-    self.clear = camel(1, "clear", self.name)
+    self.has = pascal(1, "Has", self.name)
+    self.get = pascal(1, "Get", self.name)
+    self.set = pascal(1, "Set", self.name)
+    self.clear = pascal(1, "clear", self.name)
     if self.type == "bool":
       self.option = scream(nd["@name"])
     else:
@@ -236,7 +234,7 @@
     params.append("Header header")
     params.append("MemoryStream body")
   if options or type.name in ("control", "command"):
-    params.append("Option ... _options")
+    params.append("Option ... options")
   return params
 
 def get_arguments(type, fields):
@@ -251,7 +249,7 @@
     args.append("header")
     args.append("body")
   if options or type.name in ("control", "command"):
-    args.append("_options")
+    args.append("options")
   return args
 
 def get_options(fields):
@@ -269,5 +267,5 @@
     params.append("Header header")
     params.append("MemoryStream body")
   if options or type.name in ("control", "command"):
-    params.append("params Option[] _options")
+    params.append("params Option[] options")
   return params



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message