java_gen: adapt to of_g removal, new ir
diff --git a/java_gen/templates/_field_accessors.java b/java_gen/templates/_field_accessors.java
index 030388c..41ac66f 100644
--- a/java_gen/templates/_field_accessors.java
+++ b/java_gen/templates/_field_accessors.java
@@ -11,7 +11,7 @@
@Override
public ${prop.java_type.public_type} ${prop.getter_name}()${ "" if prop in msg.members else "throws UnsupportedOperationException"} {
//:: if prop in msg.members:
-//:: version_prop = msg.get_member(prop.name)
+//:: version_prop = msg.member_by_name(prop.name)
//:: if version_prop.is_fixed_value:
return ${version_prop.enum_value};
//:: elif version_prop.is_length_value:
diff --git a/java_gen/templates/const.java b/java_gen/templates/const.java
index 413c946..a7786f4 100644
--- a/java_gen/templates/const.java
+++ b/java_gen/templates/const.java
@@ -26,7 +26,6 @@
//:: # under the EPL.
//::
//:: import itertools
-//:: import of_g
//:: include('_copyright.java')
//:: include('_autogen.java')
diff --git a/java_gen/templates/const_serializer.java b/java_gen/templates/const_serializer.java
index 12ff28a..03ca8ac 100644
--- a/java_gen/templates/const_serializer.java
+++ b/java_gen/templates/const_serializer.java
@@ -26,7 +26,6 @@
//:: # under the EPL.
//::
//:: import itertools
-//:: import of_g
//:: include('_copyright.java')
//:: include('_autogen.java')
diff --git a/java_gen/templates/const_set_serializer.java b/java_gen/templates/const_set_serializer.java
index 4c624ee..61592a6 100644
--- a/java_gen/templates/const_set_serializer.java
+++ b/java_gen/templates/const_set_serializer.java
@@ -26,7 +26,6 @@
//:: # under the EPL.
//::
//:: import itertools
-//:: import of_g
//:: include('_copyright.java')
//:: include('_autogen.java')
diff --git a/java_gen/templates/of_class.java b/java_gen/templates/of_class.java
index 36d407c..4057b3d 100644
--- a/java_gen/templates/of_class.java
+++ b/java_gen/templates/of_class.java
@@ -28,7 +28,6 @@
//:: from loxi_ir import *
//:: import os
//:: import itertools
-//:: import of_g
//:: include('_copyright.java')
//:: include('_autogen.java')
@@ -50,6 +49,9 @@
//:: #endif
//:: for prop in msg.data_members:
+ //:: if prop.java_type.public_type != msg.interface.member_by_name(prop.name).java_type.public_type:
+ //:: raise Exception("Interface and Class types do not match up: C: {} <-> I: {}".format(prop.java_type.public_type, msg.interface.member_by_name(prop.name).java_type.public_type))
+ //:: #endif
//:: if prop.default_value:
private final static ${prop.java_type.public_type} ${prop.default_name} = ${prop.default_value};
//:: #endif
diff --git a/java_gen/templates/of_factories.java b/java_gen/templates/of_factories.java
index f8c9a80..f9ec015 100644
--- a/java_gen/templates/of_factories.java
+++ b/java_gen/templates/of_factories.java
@@ -26,7 +26,6 @@
//:: # under the EPL.
//::
//:: import itertools
-//:: import of_g
//:: include('_copyright.java')
//:: include('_autogen.java')
@@ -43,13 +42,13 @@
switch(version) {
//:: for v in versions:
case ${v.constant_version}:
- return org.projectfloodlight.openflow.protocol.ver${v.of_version}.OFFactoryVer${v.of_version}.INSTANCE;
+ return org.projectfloodlight.openflow.protocol.ver${v.dotless_version}.OFFactoryVer${v.dotless_version}.INSTANCE;
//:: #endfor
default:
throw new IllegalArgumentException("Unknown version: "+version);
}
}
-
+
private static class GenericReader implements OFMessageReader<OFMessage> {
public OFMessage readFrom(ChannelBuffer bb) throws OFParseError {
short wireVersion = U8.f(bb.getByte(0));
@@ -57,7 +56,7 @@
switch (wireVersion) {
//:: for v in versions:
case ${v.int_version}:
- factory = org.projectfloodlight.openflow.protocol.ver${v.of_version}.OFFactoryVer${v.of_version}.INSTANCE;
+ factory = org.projectfloodlight.openflow.protocol.ver${v.dotless_version}.OFFactoryVer${v.dotless_version}.INSTANCE;
break;
//:: #endfor
default:
diff --git a/java_gen/templates/of_factory_class.java b/java_gen/templates/of_factory_class.java
index eef1e04..deb6e53 100644
--- a/java_gen/templates/of_factory_class.java
+++ b/java_gen/templates/of_factory_class.java
@@ -26,7 +26,6 @@
//:: # under the EPL.
//::
//:: import itertools
-//:: import of_g
//:: import re
//:: include('_copyright.java')
@@ -47,7 +46,7 @@
//:: for name, clazz in factory.interface.sub_factories.items():
public ${clazz} ${name}() {
- return ${clazz}Ver${factory.version.of_version}.INSTANCE;
+ return ${clazz}Ver${factory.version.dotless_version}.INSTANCE;
}
//:: #endfor
diff --git a/java_gen/templates/of_factory_interface.java b/java_gen/templates/of_factory_interface.java
index 9a77aa7..3694530 100644
--- a/java_gen/templates/of_factory_interface.java
+++ b/java_gen/templates/of_factory_interface.java
@@ -26,7 +26,6 @@
//:: # under the EPL.
//::
//:: import itertools
-//:: import of_g
//:: import re
//:: include('_copyright.java')
diff --git a/java_gen/templates/of_interface.java b/java_gen/templates/of_interface.java
index 98d7b9e..a515ad1 100644
--- a/java_gen/templates/of_interface.java
+++ b/java_gen/templates/of_interface.java
@@ -27,7 +27,6 @@
//::
//:: import itertools
//:: import re
-//:: import of_g
//:: include('_copyright.java')
//:: include('_autogen.java')
diff --git a/java_gen/templates/of_virtual_class.java b/java_gen/templates/of_virtual_class.java
index 55ccc5e..2c31c75 100644
--- a/java_gen/templates/of_virtual_class.java
+++ b/java_gen/templates/of_virtual_class.java
@@ -28,7 +28,6 @@
//:: from loxi_ir import *
//:: import os
//:: import itertools
-//:: import of_g
//:: include('_copyright.java')
//:: include('_autogen.java')
@@ -87,7 +86,7 @@
//:: if not model.generate_class(sub):
// skip ${sub.name} - excluded from generation
//:: else:
-//:: m = sub.get_member(prop.name)
+//:: m = sub.member_by_name(prop.name)
//:: if not m.is_fixed_value:
//:: raise Exception("subtype %s of %s does not have fixed value for discriminator %s" %
//:: (sub.name, msg.name, prop.name))
diff --git a/java_gen/templates/unit_test.java b/java_gen/templates/unit_test.java
index cd85a74..ad2c3b8 100644
--- a/java_gen/templates/unit_test.java
+++ b/java_gen/templates/unit_test.java
@@ -27,7 +27,6 @@
//::
//:: from loxi_ir import *
//:: import itertools
-//:: import of_g
//:: import java_gen.java_model as java_model
//:: include('_copyright.java')
@@ -40,6 +39,9 @@
import org.junit.Test;
import static org.junit.Assert.*;
+import org.hamcrest.CoreMatchers;
+
+
public class ${test.name} {
//:: factory = java_model.model.factory_of(test.interface)
//:: var_type = msg.interface.name
@@ -67,7 +69,7 @@
byte[] written = new byte[bb.readableBytes()];
bb.readBytes(written);
- assertArrayEquals(${msg.constant_name}_SERIALIZED, written);
+ assertThat(written, CoreMatchers.equalTo(${msg.constant_name}_SERIALIZED));
}
@Test
@@ -102,7 +104,7 @@
byte[] written = new byte[bb.readableBytes()];
bb.readBytes(written);
- assertArrayEquals(${msg.constant_name}_SERIALIZED, written);
+ assertThat(written, CoreMatchers.equalTo(${msg.constant_name}_SERIALIZED));
}
}