Browse Source

IDL: Updated codegen.

Бранимир Караџић 6 years ago
parent
commit
cc24c4e998
2 changed files with 6 additions and 23 deletions
  1. 5 23
      scripts/bindings-cs.lua
  2. 1 0
      scripts/codegen.lua

+ 5 - 23
scripts/bindings-cs.lua

@@ -296,33 +296,15 @@ function converter.funcs(func)
 		yield("[return: MarshalAs(UnmanagedType.LPStr)]")
 		yield("[return: MarshalAs(UnmanagedType.LPStr)]")
 	end
 	end
 
 
-	local first = ""
-	local args  = "("
-
+	local args = {}
 	if func.this ~= nil then
 	if func.this ~= nil then
-
-		local thisType = func.this:gsub("const ", "")
-		if thisType == "bgfx_encoder_t*" then
-			thisType = "Encoder*"
-		elseif thisType == "bgfx_attachment_t*" then
-			thisType = "Attachment*"
-		elseif thisType == "bgfx_vertex_decl_t*" then
-			thisType = "VertexDecl*"
-		end
-
-		args = args .. thisType .. " " .. "_this"
-		first = ", "
+		args[1] = func.this_type.type .. "* _this"
 	end
 	end
-
 	for _, arg in ipairs(func.args) do
 	for _, arg in ipairs(func.args) do
-
-		local argtype = convert_type(arg)
-
-		args = args .. first .. argtype .. " " .. arg.name
-		first = ", "
+		table.insert(args, convert_type(arg) .. " " .. arg.name)
 	end
 	end
-
-	yield("internal static extern unsafe " .. convert_ret_type(func.ret) .. " " .. func.cname .. args .. ");")
+	yield("internal static extern unsafe " .. convert_ret_type(func.ret) .. " " .. func.cname
+		.. "(" .. table.concat(args, ", ") .. ");")
 end
 end
 
 
 -- printtable("idl types", idl.types)
 -- printtable("idl types", idl.types)

+ 1 - 0
scripts/codegen.lua

@@ -402,6 +402,7 @@ function codegen.nameconversion(all_types, all_funcs)
 			local classtype = { fulltype = classname .. "*" }
 			local classtype = { fulltype = classname .. "*" }
 			convert_arg(all_types, classtype, v)
 			convert_arg(all_types, classtype, v)
 			v.this = classtype.ctype
 			v.this = classtype.ctype
+			v.this_type = classtype
 			v.this_conversion = string.format( "%s This = (%s)_this;", classtype.cpptype, classtype.cpptype)
 			v.this_conversion = string.format( "%s This = (%s)_this;", classtype.cpptype, classtype.cpptype)
 			v.this_to_c = string.format("(%s)this", classtype.ctype)
 			v.this_to_c = string.format("(%s)this", classtype.ctype)
 		end
 		end