此處主要用到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})