Updated IDL scripts.

This commit is contained in:
Бранимир Караџић
2019-07-04 18:47:08 -07:00
parent 7d047dfc5b
commit 4a96919315
4 changed files with 31 additions and 24 deletions

View File

@@ -1,9 +1,8 @@
-- Copyright 2019 云风 https://github.com/cloudwu . All rights reserved. -- Copyright 2019 云风 https://github.com/cloudwu . All rights reserved.
-- License (the same with bgfx) : https://github.com/bkaradzic/bgfx/blob/master/LICENSE -- License (the same with bgfx) : https://github.com/bkaradzic/bgfx/blob/master/LICENSE
local idl = require "idl"
local codegen = require "codegen" local codegen = require "codegen"
local doxygen = require "doxygen" local idl = codegen.idl "bgfx.idl"
local func_actions = { local func_actions = {
@@ -31,14 +30,6 @@ local type_actions = {
cfuncptrs = "\n", cfuncptrs = "\n",
} }
do
local source = doxygen.load "bgfx.idl"
local f = assert(load(source, "bgfx.idl" , "t", idl))
f()
end
codegen.nameconversion(idl.types, idl.funcs)
local function cfunc(f) local function cfunc(f)
return function(func) return function(func)
if not func.cpponly then if not func.cpponly then

View File

@@ -248,7 +248,7 @@ local function calc_flag_values(flag)
value = index + base - 1 value = index + base - 1
end end
if value >= cap then if value >= cap then
error (string.format("Out of range for %s (%d/%d)", name, value, cap)) error (string.format("Out of range for %s.%s (%d/%d)", flag.name, item.name, value, cap))
end end
value = value << shift value = value << shift
elseif #item == 0 then elseif #item == 0 then
@@ -964,4 +964,31 @@ function codegen.gen_handle(handle)
return (handle_temp:gsub("$(%u+)", { NAME = handle.name })) return (handle_temp:gsub("$(%u+)", { NAME = handle.name }))
end end
local idl = require "idl"
local doxygen = require "doxygen"
local conversion
local idlfile = {}
function codegen.load(filename)
assert(conversion == nil, "Don't call codegen.load() after codegen.idl()")
assert(idlfile[filename] == nil, "Duplicate load " .. filename)
local source = doxygen.load(filename)
local f = assert(load(source, filename , "t", idl))
f()
idlfile[filename] = true
end
function codegen.idl(filename)
if conversion == nil then
if filename and not idlfile[filename] then
codegen.load(filename)
end
assert(next(idlfile), "call codegen.load() first")
conversion = true
codegen.nameconversion(idl.types, idl.funcs)
end
return idl
end
return codegen return codegen

View File

@@ -1,14 +1,5 @@
local idl = require "idl"
do
local doxygen = require "doxygen"
local source = doxygen.load "bgfx.idl"
local f = assert(load(source, "bgfx.idl" , "t", idl))
f()
local codegen = require "codegen" local codegen = require "codegen"
codegen.nameconversion(idl.types, idl.funcs) local idl = codegen.idl "bgfx.idl"
end
local csharp_template = [[ local csharp_template = [[
using System; using System;

View File

@@ -1,5 +1,3 @@
local idl = require "idl"
local doxygen = {} local doxygen = {}
function doxygen.load(filename) function doxygen.load(filename)