diff options
author | Edward Aymerich <edward.aymerich@hpe.com> | 2016-05-02 14:01:46 -0600 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-05-18 10:14:51 -0700 |
commit | 010fe7ae80f95a764d9049f34c872fee6ac89a86 (patch) | |
tree | c37f063b9aaa8b2868b701356d7c51b0ead28a5f /ovsdb | |
parent | f199df26e8e286a0e6556c7347eb4cf5a83703a2 (diff) | |
download | openvswitch-010fe7ae80f95a764d9049f34c872fee6ac89a86.tar.gz |
ovsdb-idlc.in: Autogenerate partial map updates functions.
Code inserted that autogenerates corresponding map functions to set and
delete elements in map columns.
Inserts description to the functions that are autogenerated.
Signed-off-by: Edward Aymerich <edward.aymerich@hpe.com>
Signed-off-by: Arnoldo Lutz <arnoldo.lutz.guevara@hpe.com>
Co-authored-by: Arnoldo Lutz <arnoldo.lutz.guevara@hpe.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovsdb')
-rwxr-xr-x | ovsdb/ovsdb-idlc.in | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index 26b0de445..19a86dc72 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -216,6 +216,13 @@ bool %(s)s_is_updated(const struct %(s)s *, enum %(s)s_column_id); print '%s);' % ', '.join(args) print + for columnName, column in sorted(table.columns.iteritems()): + if column.type.is_map(): + print 'void %(s)s_update_%(c)s_setkey(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, + print '%(coltype)s, %(valtype)s);' % {'coltype':column.type.key.toCType(prefix), 'valtype':column.type.value.toCType(prefix)} + print 'void %(s)s_update_%(c)s_delkey(const struct %(s)s *, ' % {'s': structName, 'c': columnName}, + print '%(coltype)s);' % {'coltype':column.type.key.toCType(prefix)} + print # Table indexes. printEnum("%stable_id" % prefix.lower(), ["%sTABLE_%s" % (prefix.upper(), tableName.upper()) for tableName in sorted(schema.tables)] + ["%sN_TABLES" % prefix.upper()]) @@ -746,6 +753,68 @@ const struct ovsdb_datum * 'S': structName.upper(), 'C': columnName.upper()} print "}" + # Update/Delete of partial map column functions + for columnName, column in sorted(table.columns.iteritems()): + type = column.type + if type.is_map(): + print ''' +/* Sets an element of the "%(c)s" map column from the "%(t)s" table in 'row' + * to 'new_value' given the key value 'new_key'. + * + */ +void +%(s)s_update_%(c)s_setkey(const struct %(s)s *row, %(coltype)snew_key, %(valtype)snew_value) +{ + struct ovsdb_datum *datum; + + ovs_assert(inited); + + datum = xmalloc(sizeof *datum); + datum->n = 1; + datum->keys = xmalloc(datum->n * sizeof *datum->keys); + datum->values = xmalloc(datum->n * sizeof *datum->values); +''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.value.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper(), 't': tableName} + + print " "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "new_key") + print " "+ type.value.copyCValue("datum->values[0].%s" % type.value.type.to_string(), "new_value") + print ''' + ovsdb_idl_txn_write_partial_map(&row->header_, + &%(s)s_columns[%(S)s_COL_%(C)s], + datum); +}''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.value.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper()} + print ''' +/* Deletes an element of the "%(c)s" map column from the "%(t)s" table in 'row' + * given the key value 'delete_key'. + * + */ +void +%(s)s_update_%(c)s_delkey(const struct %(s)s *row, %(coltype)sdelete_key) +{ + struct ovsdb_datum *datum; + + ovs_assert(inited); + + datum = xmalloc(sizeof *datum); + datum->n = 1; + datum->keys = xmalloc(datum->n * sizeof *datum->keys); + datum->values = NULL; +''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.value.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper(), 't': tableName} + + print " "+ type.key.copyCValue("datum->keys[0].%s" % type.key.type.to_string(), "delete_key") + print ''' + ovsdb_idl_txn_delete_partial_map(&row->header_, + &%(s)s_columns[%(S)s_COL_%(C)s], + datum); +}''' % {'s': structName, 'c': columnName,'coltype':column.type.key.toCType(prefix), + 'valtype':column.type.value.toCType(prefix), 'S': structName.upper(), + 'C': columnName.upper()} + # End Update/Delete of partial maps # Table columns. print "\nstruct ovsdb_idl_column %s_columns[%s_N_COLUMNS];" % ( |