loci: move per-class declarations to loci_classes.h
The goal is to free loci.h of dynamically generated code and turn it into a
static template.
Needed to move some declarations out of loci.h and into of_object.h, where they
really belonged anyway.
diff --git a/c_gen/templates/loci_classes.h b/c_gen/templates/loci_classes.h
new file mode 100644
index 0000000..3486055
--- /dev/null
+++ b/c_gen/templates/loci_classes.h
@@ -0,0 +1,35 @@
+:: # Copyright 2013, Big Switch Networks, Inc.
+:: #
+:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
+:: # the following special exception:
+:: #
+:: # LOXI Exception
+:: #
+:: # As a special exception to the terms of the EPL, you may distribute libraries
+:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
+:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
+:: # from the LoxiGen Libraries and the notice provided below is (i) included in
+:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
+:: # documentation for the LoxiGen Libraries, if distributed in binary form.
+:: #
+:: # Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
+:: #
+:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
+:: # a copy of the EPL at:
+:: #
+:: # http://www.eclipse.org/legal/epl-v10.html
+:: #
+:: # Unless required by applicable law or agreed to in writing, software
+:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+:: # EPL for the specific language governing permissions and limitations
+:: # under the EPL.
+::
+:: include('_copyright.c')
+::
+#ifndef __LOCI_CLASSES_H__
+#define __LOCI_CLASSES_H__
+
+${legacy_code}
+
+#endif
diff --git a/c_gen/templates/of_object.h b/c_gen/templates/of_object.h
index ff4c9c5..fee95e1 100644
--- a/c_gen/templates/of_object.h
+++ b/c_gen/templates/of_object.h
@@ -46,6 +46,7 @@
#include <loci/of_match.h>
#include <loci/loci_base.h>
#include <loci/of_message.h>
+#include <loci/of_wire_buf.h>
#if defined(OF_OBJECT_TRACKING)
#include <BigList/biglist.h>
@@ -57,6 +58,24 @@
*/
#define OF_OBJECT_METADATA_BYTES 32
+/*
+ * Generic accessors:
+ *
+ * Many objects have a length represented in the wire buffer
+ * wire_length_get and wire_length_set access these values directly on the
+ * wire.
+ *
+ * Many objects have a length represented in the wire buffer
+ * wire_length_get and wire_length_set access these values directly on the
+ * wire.
+ *
+ * FIXME: TBD if wire_length_set and wire_type_set are required.
+ */
+typedef void (*of_wire_length_get_f)(of_object_t *obj, int *bytes);
+typedef void (*of_wire_length_set_f)(of_object_t *obj, int bytes);
+typedef void (*of_wire_type_get_f)(of_object_t *obj, of_object_id_t *id);
+typedef void (*of_wire_type_set_f)(of_object_t *obj);
+
/****************************************************************
* General list operations: first, next, append_setup, append_advance
****************************************************************/
@@ -173,4 +192,44 @@
int of_object_can_grow(of_object_t *obj, int new_len);
+struct of_object_s {
+ /* The control block for the underlying data buffer */
+ of_wire_object_t wire_object;
+ /* The LOCI type enum value of the object */
+ of_object_id_t object_id;
+
+ /*
+ * Objects need to track their "parent" so that updates to the
+ * object that affect its length can be pushed to the parent.
+ * Treat as private.
+ */
+ of_object_t *parent;
+
+ /*
+ * Not all objects have length and version on the wire so we keep
+ * them here. NOTE: Infrastructure manages length and version.
+ * Treat length as private and version as read only.
+ */
+ int length;
+ of_version_t version;
+
+ /*
+ * Many objects have a length and/or type represented in the wire buffer
+ * These accessors get and set those value when present. Treat as private.
+ */
+ of_wire_length_get_f wire_length_get;
+ of_wire_length_set_f wire_length_set;
+ of_wire_type_get_f wire_type_get;
+ of_wire_type_set_f wire_type_set;
+
+ of_object_track_info_t track_info;
+
+ /*
+ * Metadata available for applications. Ensure 8-byte alignment, but
+ * that buffer is at least as large as requested. This data is not used
+ * or inspected by LOCI.
+ */
+ uint64_t metadata[(OF_OBJECT_METADATA_BYTES + 7) / 8];
+};
+
#endif /* _OF_OBJECT_H_ */