From 70df32f9fdfd6b390bb655229f33976f879a4085 Mon Sep 17 00:00:00 2001
From: Anders Blomdell <anders.blomdell@control.lth.se>
Date: Tue, 3 Mar 2015 18:03:26 +0100
Subject: [PATCH] Renamed python library to labcomm2014

---
 compiler/2014/Python_CodeGen.jrag             | 31 ++++++-------
 examples/duck_typing/duck_typing.py           |  6 +--
 examples/simple/example_encoder.py            |  4 +-
 examples/tcp/example_tcp_client_decoder.py    |  6 +--
 examples/user_types/example_encoder.py        |  4 +-
 examples/wiki_example/example_decoder.py      |  4 +-
 lib/python/labcomm/__init__.py                | 35 --------------
 .../{labcomm => labcomm2014}/LabComm.py       |  0
 .../{labcomm => labcomm2014}/StreamReader.py  |  2 -
 .../{labcomm => labcomm2014}/StreamWriter.py  |  2 -
 lib/python/labcomm2014/__init__.py            | 31 +++++++++++++
 packaging/make_srpm                           | 25 ++++------
 test/test_encoder_decoder.py                  | 44 +++++++++---------
 tools/lc2csv.py                               | 46 +++++++++----------
 tools/lc_to_matlab_coder.py                   | 28 +++++------
 15 files changed, 125 insertions(+), 143 deletions(-)
 delete mode 100644 lib/python/labcomm/__init__.py
 rename lib/python/{labcomm => labcomm2014}/LabComm.py (100%)
 rename lib/python/{labcomm => labcomm2014}/StreamReader.py (95%)
 rename lib/python/{labcomm => labcomm2014}/StreamWriter.py (95%)
 create mode 100644 lib/python/labcomm2014/__init__.py

diff --git a/compiler/2014/Python_CodeGen.jrag b/compiler/2014/Python_CodeGen.jrag
index 68b9b95..f780c96 100644
--- a/compiler/2014/Python_CodeGen.jrag
+++ b/compiler/2014/Python_CodeGen.jrag
@@ -80,8 +80,7 @@ aspect Python_CodeGen {
     env.println("#!/usr/bin/python");
     env.println("# Auto generated " + baseName);
     env.println();
-    env.println("import labcomm");
-    env.println("import StringIO");
+    env.println("import labcomm2014");
     env.println();
     Python_genTypes(env);
     env.println("typedef = tuple([");
@@ -119,7 +118,7 @@ aspect PythonTypes {
   public void TypeDecl.Python_genSignature(Python_env env) {
     env.println("class " + getName() + "(object):");
     env.indent();
-    env.println("signature = labcomm.typedef('" + getName() + "',");
+    env.println("signature = labcomm2014.typedef('" + getName() + "',");
     env.indent();
     getType().Python_genSignature(env);
     env.unindent();
@@ -131,7 +130,7 @@ aspect PythonTypes {
   public void SampleDecl.Python_genSignature(Python_env env) {
     env.println("class " + getName() + "(object):");
     env.indent();
-    env.println("signature = labcomm.sample('" + getName() + "', ");
+    env.println("signature = labcomm2014.sample('" + getName() + "', ");
     env.indent();
     getType().Python_genSignature(env);
     env.unindent();
@@ -153,20 +152,20 @@ aspect PythonTypes {
 
   public void PrimType.Python_genSignature(Python_env env) {
     switch (getToken()) {
-      case LABCOMM_BOOLEAN: { env.print("labcomm.BOOLEAN()"); } break;
-      case LABCOMM_BYTE: { env.print("labcomm.BYTE()"); } break;
-      case LABCOMM_SHORT: { env.print("labcomm.SHORT()"); } break;
-      case LABCOMM_INT: { env.print("labcomm.INTEGER()"); } break;
-      case LABCOMM_LONG: { env.print("labcomm.LONG()"); } break;
-      case LABCOMM_FLOAT: { env.print("labcomm.FLOAT()"); } break;
-      case LABCOMM_DOUBLE: { env.print("labcomm.DOUBLE()"); } break;
-      case LABCOMM_STRING: { env.print("labcomm.STRING()"); } break;
-      case LABCOMM_SAMPLE: { env.print("labcomm.SAMPLE()"); } break;
+      case LABCOMM_BOOLEAN: { env.print("labcomm2014.BOOLEAN()"); } break;
+      case LABCOMM_BYTE: { env.print("labcomm2014.BYTE()"); } break;
+      case LABCOMM_SHORT: { env.print("labcomm2014.SHORT()"); } break;
+      case LABCOMM_INT: { env.print("labcomm2014.INTEGER()"); } break;
+      case LABCOMM_LONG: { env.print("labcomm2014.LONG()"); } break;
+      case LABCOMM_FLOAT: { env.print("labcomm2014.FLOAT()"); } break;
+      case LABCOMM_DOUBLE: { env.print("labcomm2014.DOUBLE()"); } break;
+      case LABCOMM_STRING: { env.print("labcomm2014.STRING()"); } break;
+      case LABCOMM_SAMPLE: { env.print("labcomm2014.SAMPLE()"); } break;
     }
   }
 
   public void ArrayType.Python_genSignature(Python_env env) {
-    env.print("labcomm.array([");
+    env.print("labcomm2014.array([");
     for (int i = 0 ; i < getNumExp() ; i++) {
       if (i > 0) { env.print(", "); }
       env.print(getExp(i).Python_getValue());
@@ -179,7 +178,7 @@ aspect PythonTypes {
   }
 
   public void StructType.Python_genSignature(Python_env env) {
-    env.println("labcomm.struct([");
+    env.println("labcomm2014.struct([");
     env.indent();
     for (int i = 0 ; i < getNumField() ; i++) {
       if (i > 0) { env.println(","); }
@@ -190,7 +189,7 @@ aspect PythonTypes {
   }
 
   public void VoidType.Python_genSignature(Python_env env) {
-    env.println("labcomm.struct([])");
+    env.println("labcomm2014.struct([])");
   }
 
   public void Field.Python_genSignature(Python_env env) {
diff --git a/examples/duck_typing/duck_typing.py b/examples/duck_typing/duck_typing.py
index 3138e47..c918ab5 100755
--- a/examples/duck_typing/duck_typing.py
+++ b/examples/duck_typing/duck_typing.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import labcomm
+import labcomm2014
 import animal
 import StringIO
 
@@ -10,7 +10,7 @@ class Animal:
 
 if __name__ == '__main__':
     buf = StringIO.StringIO()
-    encoder = labcomm.Encoder(labcomm.StreamWriter(buf))
+    encoder = labcomm2014.Encoder(labcomm2014.StreamWriter(buf))
     encoder.add_decl(animal.cow.signature)
     encoder.add_decl(animal.dog.signature)
     encoder.add_decl(animal.duck.signature)
@@ -22,7 +22,7 @@ if __name__ == '__main__':
     theAnimal.says = 'Quack'
     encoder.encode(theAnimal, animal.duck.signature)
     buf.seek(0)
-    decoder = labcomm.Decoder(labcomm.StreamReader(buf))
+    decoder = labcomm2014.Decoder(labcomm2014.StreamReader(buf))
     try:
         while True:
             value,decl = decoder.decode()
diff --git a/examples/simple/example_encoder.py b/examples/simple/example_encoder.py
index c89f134..49063c8 100755
--- a/examples/simple/example_encoder.py
+++ b/examples/simple/example_encoder.py
@@ -1,12 +1,12 @@
 #!/usr/bin/python
 
-import labcomm
+import labcomm2014
 import sys
 import simple
 
 if __name__ == '__main__':
     version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2014"
-    encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w')), version)
+    encoder = labcomm2014.Encoder(labcomm2014.StreamWriter(open(sys.argv[1], 'w')), version)
     encoder.add_decl(simple.theTwoInts.signature)
     encoder.add_decl(simple.IntString.signature)
     foo = simple.theTwoInts()
diff --git a/examples/tcp/example_tcp_client_decoder.py b/examples/tcp/example_tcp_client_decoder.py
index bf4f921..99d305c 100755
--- a/examples/tcp/example_tcp_client_decoder.py
+++ b/examples/tcp/example_tcp_client_decoder.py
@@ -5,9 +5,9 @@ import sys
 import socket
 import rwsocket
 
-if not any('labcomm' in p for p in sys.path):
+if not any('labcomm2014' in p for p in sys.path):
     sys.path.append('../../lib/python')
-import labcomm
+import labcomm2014
 
 
 if __name__ == "__main__":
@@ -19,7 +19,7 @@ if __name__ == "__main__":
     sock.connect(addr)
     print "Connected!"
 
-    d = labcomm.Decoder(labcomm.StreamReader(sock))
+    d = labcomm2014.Decoder(labcomm2014.StreamReader(sock))
 
     while True:
         try:
diff --git a/examples/user_types/example_encoder.py b/examples/user_types/example_encoder.py
index cdd2135..9ef2886 100755
--- a/examples/user_types/example_encoder.py
+++ b/examples/user_types/example_encoder.py
@@ -1,12 +1,12 @@
 #!/usr/bin/python
 
-import labcomm
+import labcomm2014
 import sys
 import test
 
 if __name__ == '__main__':
     version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2014"
-    encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w')), version)
+    encoder = labcomm2014.Encoder(labcomm2014.StreamWriter(open(sys.argv[1], 'w')), version)
     encoder.add_decl(test.twoLines.signature)
     tl = dict(
         l1=dict(
diff --git a/examples/wiki_example/example_decoder.py b/examples/wiki_example/example_decoder.py
index 03b01c7..b9ab942 100755
--- a/examples/wiki_example/example_decoder.py
+++ b/examples/wiki_example/example_decoder.py
@@ -1,11 +1,11 @@
 #!/usr/bin/python
 
-import labcomm
+import labcomm2014
 import sys
 
 if __name__ == "__main__":
     version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2014"
-    d = labcomm.Decoder(labcomm.StreamReader(open(sys.argv[1])), version)
+    d = labcomm2014.Decoder(labcomm2014.StreamReader(open(sys.argv[1])), version)
 
     while True:
         try:
diff --git a/lib/python/labcomm/__init__.py b/lib/python/labcomm/__init__.py
deleted file mode 100644
index fb2c085..0000000
--- a/lib/python/labcomm/__init__.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import labcomm.LabComm
-    
-from labcomm.StreamReader import StreamReader
-from labcomm.StreamWriter import StreamWriter
-
-Decoder = labcomm.LabComm.Decoder
-Encoder = labcomm.LabComm.Encoder
-
-sample = labcomm.LabComm.sample_def
-sample_def = labcomm.LabComm.sample_def
-sample_ref = labcomm.LabComm.sample_ref
-typedef = labcomm.LabComm.typedef
-
-array = labcomm.LabComm.array
-struct = labcomm.LabComm.struct
-primitive = labcomm.LabComm.primitive
-
-BOOLEAN = labcomm.LabComm.BOOLEAN
-BYTE = labcomm.LabComm.BYTE
-SHORT = labcomm.LabComm.SHORT
-INTEGER = labcomm.LabComm.INTEGER
-LONG = labcomm.LabComm.LONG
-FLOAT = labcomm.LabComm.FLOAT
-DOUBLE = labcomm.LabComm.DOUBLE
-STRING = labcomm.LabComm.STRING
-SAMPLE = labcomm.LabComm.SAMPLE
-
-decl_from_signature = labcomm.LabComm.decl_from_signature
-
-try:
-    import labcomm.TreeModel
-    TreeModel = labcomm.TreeModel.TreeModel
-except:
-    pass
-
diff --git a/lib/python/labcomm/LabComm.py b/lib/python/labcomm2014/LabComm.py
similarity index 100%
rename from lib/python/labcomm/LabComm.py
rename to lib/python/labcomm2014/LabComm.py
diff --git a/lib/python/labcomm/StreamReader.py b/lib/python/labcomm2014/StreamReader.py
similarity index 95%
rename from lib/python/labcomm/StreamReader.py
rename to lib/python/labcomm2014/StreamReader.py
index 87e9a59..a32b993 100644
--- a/lib/python/labcomm/StreamReader.py
+++ b/lib/python/labcomm2014/StreamReader.py
@@ -1,5 +1,3 @@
-import labcomm
-
 class StreamReader:
 
     def __init__(self, stream):
diff --git a/lib/python/labcomm/StreamWriter.py b/lib/python/labcomm2014/StreamWriter.py
similarity index 95%
rename from lib/python/labcomm/StreamWriter.py
rename to lib/python/labcomm2014/StreamWriter.py
index 2fffc98..f72c443 100644
--- a/lib/python/labcomm/StreamWriter.py
+++ b/lib/python/labcomm2014/StreamWriter.py
@@ -1,5 +1,3 @@
-import labcomm
-
 class StreamWriter:
     
     def __init__(self, stream):
diff --git a/lib/python/labcomm2014/__init__.py b/lib/python/labcomm2014/__init__.py
new file mode 100644
index 0000000..2e36c21
--- /dev/null
+++ b/lib/python/labcomm2014/__init__.py
@@ -0,0 +1,31 @@
+__all__ = [ 'LabComm' ]
+
+import LabComm
+
+from StreamReader import StreamReader
+from StreamWriter import StreamWriter
+
+Decoder = LabComm.Decoder
+Encoder = LabComm.Encoder
+
+sample = LabComm.sample_def
+sample_def = LabComm.sample_def
+sample_ref = LabComm.sample_ref
+typedef = LabComm.typedef
+
+array = LabComm.array
+struct = LabComm.struct
+primitive = LabComm.primitive
+
+BOOLEAN = LabComm.BOOLEAN
+BYTE = LabComm.BYTE
+SHORT = LabComm.SHORT
+INTEGER = LabComm.INTEGER
+LONG = LabComm.LONG
+FLOAT = LabComm.FLOAT
+DOUBLE = LabComm.DOUBLE
+STRING = LabComm.STRING
+SAMPLE = LabComm.SAMPLE
+
+decl_from_signature = LabComm.decl_from_signature
+
diff --git a/packaging/make_srpm b/packaging/make_srpm
index c5abe53..4925a83 100755
--- a/packaging/make_srpm
+++ b/packaging/make_srpm
@@ -2,7 +2,7 @@
 
 spec() {
 cat << 'EOF'
-Name:      labcomm
+Name:      labcomm__SUFFIX__
 Version:   __VERSION__
 Release:   1
 Summary:   LabComm communication protocol
@@ -40,58 +40,47 @@ make
 # C 
 #
 install -d ${RPM_BUILD_ROOT}/%{_libdir}
-install lib/c/liblabcomm2006.a ${RPM_BUILD_ROOT}/%{_libdir}/
-install lib/c/liblabcomm2006.so.1 ${RPM_BUILD_ROOT}/%{_libdir}/liblabcomm2006.so.__VERSION__
-ln -s liblabcomm2006.so.__VERSION__ ${RPM_BUILD_ROOT}/%{_libdir}/liblabcomm2006.so
 install lib/c/liblabcomm2014.a ${RPM_BUILD_ROOT}/%{_libdir}/
 install lib/c/liblabcomm2014.so.1 ${RPM_BUILD_ROOT}/%{_libdir}/liblabcomm2014.so.__VERSION__
 ln -s liblabcomm2014.so.__VERSION__ ${RPM_BUILD_ROOT}/%{_libdir}/liblabcomm2014.so
 install -d ${RPM_BUILD_ROOT}/%{_includedir}/labcomm
 install lib/c/2014/*h ${RPM_BUILD_ROOT}/%{_includedir}/labcomm
-install -d ${RPM_BUILD_ROOT}/%{_includedir}/labcomm2006
-install lib/c/2006/*h ${RPM_BUILD_ROOT}/%{_includedir}/labcomm
 
 #
 # java 
 #
 install -d ${RPM_BUILD_ROOT}/usr/lib
 install -m u=r,g=r,o=r compiler/labcomm2014_compiler.jar ${RPM_BUILD_ROOT}/usr/lib
-install -m u=r,g=r,o=r compiler/labcomm2006_compiler.jar ${RPM_BUILD_ROOT}/usr/lib
 install -m u=r,g=r,o=r lib/java/labcomm2014.jar ${RPM_BUILD_ROOT}/usr/lib
-install -m u=r,g=r,o=r lib/java/labcomm2006.jar ${RPM_BUILD_ROOT}/usr/lib
 
 install -d ${RPM_BUILD_ROOT}/%{_bindir}
 install -m u=rx,g=rx,o=rx \
         compiler/labcomm2014 ${RPM_BUILD_ROOT}/%{_bindir}/labcomm2014
-install -m u=rx,g=rx,o=rx \
-        compiler/labcomm2006 ${RPM_BUILD_ROOT}/%{_bindir}/labcomm2006
 ls -l ${RPM_BUILD_ROOT}/%{_bindir}
 
 #
 # C#
 #
 install -d ${RPM_BUILD_ROOT}/usr/lib
-install -m u=r,g=r,o=r lib/csharp/labcomm.dll ${RPM_BUILD_ROOT}/usr/lib
+install -m u=r,g=r,o=r lib/csharp/labcomm2014.dll ${RPM_BUILD_ROOT}/usr/lib
 
 #
 # Python
 #
-install -d ${RPM_BUILD_ROOT}/%{python_sitelib}/labcomm
-install lib/python/labcomm/* ${RPM_BUILD_ROOT}/%{python_sitelib}/labcomm
+install -d ${RPM_BUILD_ROOT}/%{python_sitelib}/labcomm2014
+install lib/python/labcomm/* ${RPM_BUILD_ROOT}/%{python_sitelib}/labcomm2014
 
 %files
 %defattr (-, root, root)
 %exclude /usr/lib/debug
 %exclude /usr/lib/labcomm2014_compiler.jar
-%exclude /usr/lib/labcomm2006_compiler.jar
 /usr/lib/*
 %{_libdir}/*
 
 %files devel
 %defattr (-, root, root)
 /usr/lib/labcomm2014_compiler.jar
-/usr/lib/labcomm2006_compiler.jar
-%{_includedir}/*
+%{_includedir}/labcomm/*
 %{_bindir}/*
 
 EOF
@@ -108,10 +97,12 @@ rm -rf rpmbuild/SOURCES/*
 
 # Create spec and .tar.gz
 DESCRIBE=$(git describe | sed -e 's/^v\(.*\)/\1/')
-VERSION=$(echo ${DESCRIBE} | sed -e 's/-/./g')
+SUFFIX=$(echo ${DESCRIBE} | sed -e 's/^\([^.]*\)[.].*$/\1/g')
+VERSION=$(echo ${DESCRIBE} | sed -e 's/^[^.]*[.]\(.*\)/\1/g;s/-/./g')
 COMMIT=$(git rev-parse HEAD)
 (
     spec | \
+        sed -e "s/__SUFFIX__/${SUFFIX}/g" | \
         sed -e "s/__VERSION__/${VERSION}/g" | \
         sed -e "s/__DESCRIBE__/${DESCRIBE}/g" | \
         sed -e "s/__COMMIT__/${COMMIT}/g" \
diff --git a/test/test_encoder_decoder.py b/test/test_encoder_decoder.py
index 29960cb..66e289e 100755
--- a/test/test_encoder_decoder.py
+++ b/test/test_encoder_decoder.py
@@ -3,7 +3,7 @@
 
 import argparse
 import imp
-import labcomm
+import labcomm2014
 import math
 import os
 import re
@@ -47,25 +47,25 @@ class Test:
         pass
 
     def generate(self, decl):
-        if decl.__class__ == labcomm.sample:
+        if decl.__class__ == labcomm2014.sample:
             result = []
             for values in self.generate(decl.decl):
                 result.append((decl, values))
             return result
     
-        elif decl.__class__ == labcomm.typedef:
+        elif decl.__class__ == labcomm2014.typedef:
             result = []
             for values in self.generate(decl.decl):
                 result.append(values)
             return result
 
-        elif decl.__class__ == labcomm.struct:
+        elif decl.__class__ == labcomm2014.struct:
             result = []
             if len(decl.field) == 0:
                 result.append({})
             else:
                 values1 = self.generate(decl.field[0][1])
-                values2 = self.generate(labcomm.struct(decl.field[1:]))
+                values2 = self.generate(labcomm2014.struct(decl.field[1:]))
                 for v1 in values1:
                     for v2 in values2:
                         v = dict(v2)
@@ -73,7 +73,7 @@ class Test:
                         result.append(v)
             return result
         
-        elif decl.__class__ == labcomm.array:
+        elif decl.__class__ == labcomm2014.array:
             if len(decl.indices) == 1:
                 values = self.generate(decl.decl)
                 if decl.indices[0] == 0:
@@ -81,7 +81,7 @@ class Test:
                 else:
                     lengths = [ decl.indices[0] ]
             else:
-                values = self.generate(labcomm.array(decl.indices[1:],
+                values = self.generate(labcomm2014.array(decl.indices[1:],
                                                      decl.decl))
                 if decl.indices[0] == 0:
                     lengths = [1, 2]
@@ -96,33 +96,33 @@ class Test:
                     result.append(element)
             return result
     
-        elif decl.__class__ == labcomm.BOOLEAN:
+        elif decl.__class__ == labcomm2014.BOOLEAN:
             return [False, True]
     
-        elif decl.__class__ == labcomm.BYTE:
+        elif decl.__class__ == labcomm2014.BYTE:
             return [0, 127, 128, 255]
     
-        elif decl.__class__ == labcomm.SHORT:
+        elif decl.__class__ == labcomm2014.SHORT:
             return [-32768, 0, 32767]
     
-        elif decl.__class__ == labcomm.INTEGER:
+        elif decl.__class__ == labcomm2014.INTEGER:
             return [-2147483648, 0, 2147483647]
     
-        elif decl.__class__ == labcomm.LONG:
+        elif decl.__class__ == labcomm2014.LONG:
             return [-9223372036854775808, 0, 9223372036854775807]
     
-        elif decl.__class__ == labcomm.FLOAT:
+        elif decl.__class__ == labcomm2014.FLOAT:
             def tofloat(v):
                 return struct.unpack('f', struct.pack('f', v))[0]
             return [tofloat(-math.pi), 0.0, tofloat(math.pi)]
     
-        elif decl.__class__ == labcomm.DOUBLE:
+        elif decl.__class__ == labcomm2014.DOUBLE:
             return [-math.pi, 0.0, math.pi]
     
-        elif decl.__class__ == labcomm.STRING:
+        elif decl.__class__ == labcomm2014.STRING:
             return ['string', u'sträng' ]
     
-        elif decl.__class__ == labcomm.SAMPLE:
+        elif decl.__class__ == labcomm2014.SAMPLE:
             return self.signatures
     
         print>>sys.stderr, decl
@@ -130,19 +130,19 @@ class Test:
 
     def uses_refs(self, decls):
         for decl in decls:
-            if decl.__class__ == labcomm.sample:
+            if decl.__class__ == labcomm2014.sample:
                 if self.uses_refs([ decl.decl ]):
                     return True
     
-            elif decl.__class__ == labcomm.struct:
+            elif decl.__class__ == labcomm2014.struct:
                 if self.uses_refs([ d for n,d in decl.field ]):
                     return True
         
-            elif decl.__class__ == labcomm.array:
+            elif decl.__class__ == labcomm2014.array:
                 if self.uses_refs([ decl.decl ]):
                     return True
 
-            elif decl.__class__ == labcomm.SAMPLE:
+            elif decl.__class__ == labcomm2014.SAMPLE:
                 return True
 
         return False
@@ -159,7 +159,7 @@ class Test:
         self.next = threading.Condition()
         decoder = threading.Thread(target=self.decode, args=(p.stdout,))
         decoder.start()
-        encoder = labcomm.Encoder(labcomm.StreamWriter(p.stdin))
+        encoder = labcomm2014.Encoder(labcomm2014.StreamWriter(p.stdin))
         for signature in self.signatures:
             encoder.add_decl(signature)
             pass
@@ -202,7 +202,7 @@ class Test:
         pass
 
     def decode(self, f):
-        decoder = labcomm.Decoder(labcomm.StreamReader(f))
+        decoder = labcomm2014.Decoder(labcomm2014.StreamReader(f))
         try:
             while True:
                 value,decl = decoder.decode()
diff --git a/tools/lc2csv.py b/tools/lc2csv.py
index bebcd69..f887bda 100755
--- a/tools/lc2csv.py
+++ b/tools/lc2csv.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 import argparse
-import labcomm
+import labcomm2014
 import sys
 import time
 
@@ -41,67 +41,67 @@ class FollowingReader(Reader):
 
 
 def flatten(sample, _type):
-    if isinstance(_type, labcomm.sample):
+    if isinstance(_type, labcomm2014.sample):
         flatten(sample, _type.decl)
-    elif isinstance(_type, labcomm.array):
+    elif isinstance(_type, labcomm2014.array):
         for e in sample:
             flatten(e, _type.decl)
-    elif isinstance(_type, labcomm.struct):
+    elif isinstance(_type, labcomm2014.struct):
         for name, decl in _type.field:
             flatten(sample[name], decl)
-    elif isinstance(_type, labcomm.BOOLEAN):
+    elif isinstance(_type, labcomm2014.BOOLEAN):
         print "%d," % sample,
-    elif isinstance(_type, labcomm.STRING):
+    elif isinstance(_type, labcomm2014.STRING):
         print "\"%s\"," % sample,
-    elif isinstance(_type, labcomm.primitive):
+    elif isinstance(_type, labcomm2014.primitive):
         print "%s," % sample,
     else:
         raise Exception("Unhandled type. " + str(type(type_)) + " " + str(type_))
 
 
 def flatten_labels(_type, prefix=""):
-    if isinstance(_type, labcomm.sample):
+    if isinstance(_type, labcomm2014.sample):
         flatten_labels(_type.decl, _type.name)
-    elif isinstance(_type, labcomm.array):
+    elif isinstance(_type, labcomm2014.array):
         if len(_type.indices) != 1:
             raise Exception("Fix multidimensional arrays")
         if len(_type.indices) == 0:
             raise Exception("We dont't handle dynamical sizes yet %s" % _type)
         for i in range(0, _type.indices[0]):
             flatten_labels(_type.decl, prefix + "[%d]" % i)
-    elif isinstance(_type, labcomm.struct):
+    elif isinstance(_type, labcomm2014.struct):
         for name, decl in _type.field:
             flatten_labels(decl,
                            prefix + "." + name)
-    elif isinstance(_type, labcomm.primitive):
+    elif isinstance(_type, labcomm2014.primitive):
         print '"%s",' % prefix,
     else:
         raise Exception("Unhandled type. " + str(type(type_)) + " " + str(type_))
 
 
 def default(type_):
-    if isinstance(type_, labcomm.sample):
+    if isinstance(type_, labcomm2014.sample):
         return default(type_.decl)
-    elif isinstance(type_, labcomm.array):
+    elif isinstance(type_, labcomm2014.array):
         if len(type_.indices) != 1:
             raise Exception("Fix multidimensional arrays")
         if len(type_.indices) == 0:
             raise Exception("We dont't handle dynamical sizes yet %s" % type_)
         for i in range(0, type_.indices[0]):
             return [default(type_.decl) for _ in range(type_.indices[0])]
-    elif isinstance(type_, labcomm.struct):
+    elif isinstance(type_, labcomm2014.struct):
         return {name: default(decl) for name, decl in type_.field}
-    elif isinstance(type_, labcomm.STRING):
+    elif isinstance(type_, labcomm2014.STRING):
         return ''
-    elif isinstance(type_, labcomm.BOOLEAN):
+    elif isinstance(type_, labcomm2014.BOOLEAN):
         return False
-    elif (isinstance(type_, labcomm.FLOAT) or
-          isinstance(type_, labcomm.DOUBLE)):
+    elif (isinstance(type_, labcomm2014.FLOAT) or
+          isinstance(type_, labcomm2014.DOUBLE)):
         return float('NaN')
-    elif (isinstance(type_, labcomm.BYTE) or
-          isinstance(type_, labcomm.SHORT) or
-          isinstance(type_, labcomm.INTEGER) or
-          isinstance(type_, labcomm.LONG)):
+    elif (isinstance(type_, labcomm2014.BYTE) or
+          isinstance(type_, labcomm2014.SHORT) or
+          isinstance(type_, labcomm2014.INTEGER) or
+          isinstance(type_, labcomm2014.LONG)):
         return 0
     else:
         raise Exception("Unhandled type. " + str(type(type_)) + " " + str(type_))
@@ -156,7 +156,7 @@ def main(main_args):
         reader = FollowingReader(file_, args.interval, args.timeout)
     else:
         reader = Reader(file_)
-    d = labcomm.Decoder(reader)
+    d = labcomm2014.Decoder(reader)
     while True:
         try:
             o, t = d.decode()
diff --git a/tools/lc_to_matlab_coder.py b/tools/lc_to_matlab_coder.py
index f1fbf36..dda9665 100755
--- a/tools/lc_to_matlab_coder.py
+++ b/tools/lc_to_matlab_coder.py
@@ -4,11 +4,11 @@ import sys
 import imp
 import subprocess
 import os
-import labcomm
+import labcomm2014
 
 TRANSLATE={
-    labcomm.SHORT() : 'short',
-    labcomm.DOUBLE() : 'double'
+    labcomm2014.SHORT() : 'short',
+    labcomm2014.DOUBLE() : 'double'
 }
 
 def compile_lc(lc):
@@ -22,46 +22,46 @@ def compile_lc(lc):
     return (lc_import.typedef, lc_import.sample)
 
 def gen_binding(decl, lc_prefix, prefix, suffix):
-    if isinstance(decl, labcomm.sample):
-        if isinstance(decl.decl, labcomm.typedef):
+    if isinstance(decl, labcomm2014.sample):
+        if isinstance(decl.decl, labcomm2014.typedef):
             print "%(n1)s = coder.cstructname(%(n1)s, '%(lc)s_%(n2)s')" % dict(
                 n1=decl.name, n2=decl.decl.name, lc=lc_prefix)
         else:
             print "%(n1)s = coder.cstructname(%(n1)s, '%(lc)s_%(n2)s')" % dict(
                 n1=decl.name, n2=decl.name, lc=lc_prefix)
         gen_binding(decl.decl, lc_prefix, '%s.' % decl.name, suffix)
-    elif isinstance(decl, labcomm.typedef):
+    elif isinstance(decl, labcomm2014.typedef):
         print "%(p)s%(s)s = coder.cstructname(%(p)s%(s)s, '%(lc)s_%(n)s')" % dict(
             n=decl.name, lc=lc_prefix, p=prefix, s=suffix)
         gen_binding(decl.decl, lc_prefix, prefix, suffix)
-    elif isinstance(decl, labcomm.array):
+    elif isinstance(decl, labcomm2014.array):
          raise Exception("Array unhandled")
-    elif isinstance(decl, labcomm.struct):
+    elif isinstance(decl, labcomm2014.struct):
         for n, d in decl.field:
             gen_binding(d, lc_prefix, '%sFields.%s' % (prefix, n), suffix)
-    elif isinstance(decl, labcomm.primitive):
+    elif isinstance(decl, labcomm2014.primitive):
         pass
     else:
         raise Exception("Unhandled type. %s", decl)
     
 def gen_sample(lc_prefix, decl):
-    if isinstance(decl, labcomm.sample):
+    if isinstance(decl, labcomm2014.sample):
         print "%s = " % decl.name,
         gen_sample(lc_prefix, decl.decl)
         print
         gen_binding(decl, lc_prefix, '', '')
-    elif isinstance(decl, labcomm.typedef):
+    elif isinstance(decl, labcomm2014.typedef):
         # Expand in place
         gen_sample(lc_prefix, decl.decl)
-    elif isinstance(decl, labcomm.array):
+    elif isinstance(decl, labcomm2014.array):
          raise Exception("Array unhandled")
-    elif isinstance(decl, labcomm.struct):
+    elif isinstance(decl, labcomm2014.struct):
         print "struct(..."
         for n, d in decl.field:
             print "'%s, " % n,
             gen_sample(lc_prefix, d)
         print ")..."
-    elif isinstance(decl, labcomm.primitive):
+    elif isinstance(decl, labcomm2014.primitive):
         print "%s(0), ..." % TRANSLATE[decl]
     else:
         raise Exception("Unhandled type. %s", decl)  
-- 
GitLab