此处主要用到python语言, 解析schema中的json key value, 然后根据属性进行各种编程接口的模式化编辑。
ovsdb-idlc annotate schema annotations
ovsdb-idlc c-idl-header idl
ovsdb-idlc c-idl-source idl
ovs/ovsdb/ovsdb-idlc.in
.c .h的文件内容,根据predix作为参数,输出成完整的文件。 模板化编辑,此处可以这样做,是因为数据库操作接口比较固定,容易实现批量生成。
def printCIDLHeader(schemaFile):
schema = parseSchema(schemaFile)
replace_cplusplus_keyword(schema)
prefix = schema.idlPrefix
print('''\
/* Generated automatically -- do not modify! -*- buffer-read-only: t -*- */
#ifndef %(prefix)sIDL_HEADER
#define %(prefix)sIDL_HEADER 1
#include <std
def printCIDLSource(schemaFile):
schema = parseSchema(schemaFile)
replace_cplusplus_keyword(schema)
prefix = schema.idlPrefix
print('''\
/* Generated automatically -- do not modify! -*- buffer-read-only: t -*- */
#include <config.h>
#include %(header)s
#include <limits.h>
#include "ovs-thread.h"
#include "ovsdb-data.h"
#include "ovsdb-error.h"
#include "util.h"
%(cDecls)s
''' % {'header': schema.idlHeader,
'cDecls': schema.cDecls})