<commit_before>local codegen = require "codegen"
local idl = codegen.idl "bgfx.idl"

local d_types_template = [[
/*
 *
 * AUTO GENERATED! DO NOT EDIT!
 *
 */

module bindbc.bgfx.types;

public import core.stdc.stdarg : va_list;

extern(C) @nogc nothrow:

$version

alias bgfx_view_id_t = ushort;

$types
]]

local d_funcs_template = [[
/*
 *
 * AUTO GENERATED! DO NOT EDIT!
 *
 */

module bindbc.bgfx.funcs;

private import bindbc.bgfx.types;

extern(C) @nogc nothrow:

version(BindBgfx_Static)
{
	$funcs_static
}
else
{
	__gshared
	{
		$funcs_dynamic
	}
}
]]

local function hasPrefix(str, prefix)
	return prefix == "" or str:sub(1, #prefix) == prefix
end

local function hasSuffix(str, suffix)
	return suffix == "" or str:sub(-#suffix) == suffix
end

local function to_underscorecase(name)
	local tmp = {}
	for v in name:gmatch "[_%u][%l%d]*" do
		if v:byte() == 95 then	-- '_'
			v = v:sub(2)	-- remove _
		end
		tmp[#tmp+1] = v
	end
	return table.concat(tmp, "_")
end

local function convert_array(member)
	if string.find(member.array, "::") then
		local name = "bgfx_" .. to_underscorecase(string.gsub(member.array, "::.*", "")):lower() .. "_t"
		return "[" .. name .. ".BGFX_" .. to_underscorecase(member.array):upper() .. "]"
	else
		return member.array
	end
end

local function convert_type(arg)
	local ctype = arg.ctype:gsub("%s%*", "*")
	if arg.fulltype == "bx::AllocatorI*" or arg.fulltype == "CallbackI*" or arg.fulltype == "ReleaseFn" then
		ctype = "void*"
	elseif hasPrefix(ctype, "uint64_t") then
		ctype = ctype:gsub("uint64_t", "ulong")
	elseif hasPrefix(ctype, "int64_t") then
		ctype = ctype:gsub("int64_t", "long")
	elseif hasPrefix(ctype, "uint32_t") then
		ctype = ctype:gsub("uint32_t", "uint")
	elseif hasPrefix(ctype, "int32_t") then
		ctype = ctype:gsub("int32_t", "int")
	elseif hasPrefix(ctype, "uint16_t") then
		ctype = ctype:gsub("uint16_t", "ushort")
	elseif hasPrefix(ctype, "uint8_t") then
		ctype = ctype:gsub("uint8_t", "byte")
	elseif hasPrefix(ctype, "uintptr_t") then
		ctype = ctype:gsub("uintptr_t", "ulong")
	elseif hasPrefix(ctype, "const ") and hasSuffix(ctype, "*") then
		ctype = "const(" .. string.sub(ctype:gsub("const ", "", 1), 1, -2) .. ")*"
	end

	if arg.array ~= nil then
		ctype = ctype .. convert_array(arg)
	end

	return ctype
end

local function convert_struct_type(arg)
	return convert_type(arg)
end

local function convert_ret_type(arg)
	return convert_type(arg)
end

local function convert_name(arg)
	if arg == "debug" then
		return arg .. "_"
	end
	return arg
end
<commit_msg>Fixed uint8_t being bound to byte instead of ubyte (#2735)<commit_after>local codegen = require "codegen"
local idl = codegen.idl "bgfx.idl"

local d_types_template = [[
/*
 *
 * AUTO GENERATED! DO NOT EDIT!
 *
 */

module bindbc.bgfx.types;

public import core.stdc.stdarg : va_list;

extern(C) @nogc nothrow:

$version

alias bgfx_view_id_t = ushort;

$types
]]

local d_funcs_template = [[
/*
 *
 * AUTO GENERATED! DO NOT EDIT!
 *
 */

module bindbc.bgfx.funcs;

private import bindbc.bgfx.types;

extern(C) @nogc nothrow:

version(BindBgfx_Static)
{
	$funcs_static
}
else
{
	__gshared
	{
		$funcs_dynamic
	}
}
]]

local function hasPrefix(str, prefix)
	return prefix == "" or str:sub(1, #prefix) == prefix
end

local function hasSuffix(str, suffix)
	return suffix == "" or str:sub(-#suffix) == suffix
end

local function to_underscorecase(name)
	local tmp = {}
	for v in name:gmatch "[_%u][%l%d]*" do
		if v:byte() == 95 then	-- '_'
			v = v:sub(2)	-- remove _
		end
		tmp[#tmp+1] = v
	end
	return table.concat(tmp, "_")
end

local function convert_array(member)
	if string.find(member.array, "::") then
		local name = "bgfx_" .. to_underscorecase(string.gsub(member.array, "::.*", "")):lower() .. "_t"
		return "[" .. name .. ".BGFX_" .. to_underscorecase(member.array):upper() .. "]"
	else
		return member.array
	end
end

local function convert_type(arg)
	local ctype = arg.ctype:gsub("%s%*", "*")
	if arg.fulltype == "bx::AllocatorI*" or arg.fulltype == "CallbackI*" or arg.fulltype == "ReleaseFn" then
		ctype = "void*"
	elseif hasPrefix(ctype, "uint64_t") then
		ctype = ctype:gsub("uint64_t", "ulong")
	elseif hasPrefix(ctype, "int64_t") then
		ctype = ctype:gsub("int64_t", "long")
	elseif hasPrefix(ctype, "uint32_t") then
		ctype = ctype:gsub("uint32_t", "uint")
	elseif hasPrefix(ctype, "int32_t") then
		ctype = ctype:gsub("int32_t", "int")
	elseif hasPrefix(ctype, "uint16_t") then
		ctype = ctype:gsub("uint16_t", "ushort")
	elseif hasPrefix(ctype, "uint8_t") then
		ctype = ctype:gsub("uint8_t", "ubyte")
	elseif hasPrefix(ctype, "uintptr_t") then
		ctype = ctype:gsub("uintptr_t", "ulong")
	elseif hasPrefix(ctype, "const ") and hasSuffix(ctype, "*") then
		ctype = "const(" .. string.sub(ctype:gsub("const ", "", 1), 1, -2) .. ")*"
	end

	if arg.array ~= nil then
		ctype = ctype .. convert_array(arg)
	end

	return ctype
end

local function convert_struct_type(arg)
	return convert_type(arg)
end

local function convert_ret_type(arg)
	return convert_type(arg)
end

local function convert_name(arg)
	if arg == "debug" then
		return arg .. "_"
	end
	return arg
end

{'fraction_non_alphanumeric': 0.1598984771573604, 'fraction_numerical': 0.012690355329949238, 'mean_word_length': 4.415433403805497, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2845703', 'n_tokens_mistral': 2120, 'n_tokens_neox': 1998, 'n_words': 473}