blob: 5eb45c61e618e118b61c38d334e2c64a88eda4a5 [file] [log] [blame]
Rich Lane99d9a8d2014-06-13 14:05:10 -07001:: # Copyright 2014, Big Switch Networks, Inc.
2:: #
3:: # LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
4:: # the following special exception:
5:: #
6:: # LOXI Exception
7:: #
8:: # As a special exception to the terms of the EPL, you may distribute libraries
9:: # generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
10:: # that copyright and licensing notices generated by LoxiGen are not altered or removed
11:: # from the LoxiGen Libraries and the notice provided below is (i) included in
12:: # the LoxiGen Libraries, if distributed in source code form and (ii) included in any
13:: # documentation for the LoxiGen Libraries, if distributed in binary form.
14:: #
15:: # Notice: "Copyright 2014, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
16:: #
17:: # You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
18:: # a copy of the EPL at:
19:: #
20:: # http://www.eclipse.org/legal/epl-v10.html
21:: #
22:: # Unless required by applicable law or agreed to in writing, software
23:: # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24:: # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
25:: # EPL for the specific language governing permissions and limitations
26:: # under the EPL.
27::
28:: include('_copyright.c')
29:: include('_pragmas.c')
30
31#include "loci_log.h"
32#include "loci_int.h"
33
34/**
35 * Associate an iterator with a list
36 * @param list The list to iterate over
37 * @param obj The list entry iteration pointer
38 * @return OF_ERROR_RANGE if the list is empty (end of list)
39 *
40 * The obj instance is completely initialized. The caller is responsible
41 * for cleaning up any wire buffers associated with obj before this call
42 */
43
44int
Rich Lane30943262014-11-07 09:04:13 -080045${cls}_first(${cls}_t *list, of_object_t *obj)
Rich Lane99d9a8d2014-06-13 14:05:10 -070046{
47 int rv;
Rich Lane99d9a8d2014-06-13 14:05:10 -070048
Rich Lane7fdaa5c2014-10-27 18:14:59 -070049 ${e_cls}_init(obj, list->version, -1, 1);
Rich Lane99d9a8d2014-06-13 14:05:10 -070050
51 if ((rv = of_list_first(list, obj)) < 0) {
52 return rv;
53 }
54
Rich Lane83f958d2014-06-13 15:01:40 -070055:: if e_uclass.virtual:
56 ${e_cls}_wire_object_id_get(obj, &obj->object_id);
57:: #endif
58
Rich Lanebbf5e1d2014-06-13 15:34:21 -070059:: if wire_length_get != 'NULL':
60 ${wire_length_get}(obj, &obj->length);
Rich Lane83f958d2014-06-13 15:01:40 -070061:: #endif
Rich Lane99d9a8d2014-06-13 14:05:10 -070062
63 return rv;
64}
65
66/**
67 * Advance an iterator to the next element in a list
68 * @param list The list being iterated
69 * @param obj The list entry iteration pointer
70 * @return OF_ERROR_RANGE if already at the last entry on the list
71 *
72 */
73
74int
Rich Lane30943262014-11-07 09:04:13 -080075${cls}_next(${cls}_t *list, of_object_t *obj)
Rich Lane99d9a8d2014-06-13 14:05:10 -070076{
77 int rv;
Rich Lane99d9a8d2014-06-13 14:05:10 -070078
79 if ((rv = of_list_next(list, obj)) < 0) {
80 return rv;
81 }
82
Rich Lane83f958d2014-06-13 15:01:40 -070083:: if e_uclass.virtual:
84 ${e_cls}_wire_object_id_get(obj, &obj->object_id);
85:: #endif
Rich Lane99d9a8d2014-06-13 14:05:10 -070086
Rich Lanebbf5e1d2014-06-13 15:34:21 -070087:: if wire_length_get != 'NULL':
88 ${wire_length_get}(obj, &obj->length);
Rich Lane83f958d2014-06-13 15:01:40 -070089:: #endif
Rich Lane99d9a8d2014-06-13 14:05:10 -070090
91 return rv;
92}
93
94/**
95 * Set up to append an object of type ${e_cls} to an ${cls}.
96 * @param list The list that is prepared for append
97 * @param obj Pointer to object to hold data to append
98 *
99 * The obj instance is completely initialized. The caller is responsible
100 * for cleaning up any wire buffers associated with obj before this call.
101 *
102 * See the generic documentation for of_list_append_bind.
103 */
104
105int
Rich Lane30943262014-11-07 09:04:13 -0800106${cls}_append_bind(${cls}_t *list, of_object_t *obj)
Rich Lane99d9a8d2014-06-13 14:05:10 -0700107{
Rich Lane30943262014-11-07 09:04:13 -0800108 return of_list_append_bind(list, obj);
Rich Lane99d9a8d2014-06-13 14:05:10 -0700109}
110
111/**
112 * Append an object to a ${cls} list.
113 *
114 * This copies data from obj and leaves item untouched.
115 *
116 * See the generic documentation for of_list_append.
117 */
118
119int
Rich Lane30943262014-11-07 09:04:13 -0800120${cls}_append(${cls}_t *list, of_object_t *obj)
Rich Lane99d9a8d2014-06-13 14:05:10 -0700121{
Rich Lane30943262014-11-07 09:04:13 -0800122 return of_list_append(list, obj);
Rich Lane99d9a8d2014-06-13 14:05:10 -0700123}