openvswitch 根据schema生成db .c .h文件原理

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值