@@ -64,12 +64,21 @@ remove_comment = (s) ->
6464fix5p1 = ( data) ->
6565 lines = sutil. split_lines data
6666 outlines = {}
67+ cur_enum = nil
6768 for linepos = 1 , # lines
68- curline = sutil. strip lines[ linepos]
69+ curline = remove_comment sutil. strip lines[ linepos]
70+ if ( curline\ sub 1 , 4 ) == " enum"
71+ cur_enum = curline\ sub 5 ,- 1
72+ elseif cur_enum and curline == " "
73+ if ( outlines[ # outlines] \ sub - 2 ,- 1 ) != " ()"
74+ print ( " Enum missing function call: #{cur_enum}" )
75+ outlines[ # outlines] = outlines[ # outlines] .. " ()"
76+ cur_enum = nil
77+
6978 if ( curline\ sub 1 , 2 ) == " ()"
70- outlines[ # outlines] = ( remove_comment outlines[ # outlines] ) .. curline
79+ outlines[ # outlines] = outlines[ # outlines] .. curline
7180 else
72- outlines[ # outlines+ 1 ] = lines [ linepos ]
81+ outlines[ # outlines+ 1 ] = curline
7382 temp = io.open " bleh.lua" , " wt"
7483 temp\ write table.concat outlines, " \n "
7584 temp\ close!
@@ -96,7 +105,8 @@ key_sorted_concat = (t, sep) ->
96105 ordered_concat t, sorted_keys, sep
97106
98107exec_in = ( env, fn) ->
99- chunk, err = loadstring fix5p1 rawload fn
108+ src = fix5p1 rawload fn
109+ chunk, err = loadstring src
100110 if not chunk
101111 truss. error " Error parsing #{fn}: #{err}"
102112 setfenv chunk, env
@@ -109,12 +119,18 @@ load_idl = (buildpath) ->
109119 idl = exec_in env, " #{path}/scripts/idl.lua"
110120 exec_in idl, " #{path}/scripts/bgfx.idl"
111121
122+ BANNED_TYPES = { " va_list" }
123+
112124is_api_func = ( line) ->
113125 parts = sutil. split " " , line
114126 if parts[ 1 ] != " BGFX_C_API" then return nil
115127 api_key = ( parts[ 2 ] != " const" and parts[ 3 ] ) or parts[ 4 ] or line
116128 api_key = ( sutil. split " %(" , api_key) [ 1 ]
117- ( table.concat [ p for p in * parts[ 2 , ]] , " " ) , api_key
129+ signature = table.concat [ p for p in * parts[ 2 , ]] , " "
130+ for bad_type in * BANNED_TYPES
131+ if line\ find bad_type
132+ signature = " //" .. signature
133+ signature, api_key
118134
119135get_functions = ( buildpath) ->
120136 -- generating function signatures from the IDL is too much of a pain
@@ -294,8 +310,8 @@ gen_header = (buildpath) ->
294310 }
295311
296312export init = ->
297- bpath = " ../build"
298- print " Copying files"
313+ bpath = truss . args [ 3 ] or " ../build"
314+ print " Copying files from #{bpath} "
299315 copy_files bpath
300316 print " Generating include/bgfx_truss.c99.h"
301317 truss. save_string " include/bgfx_truss.c99.h" , ( gen_header bpath)
0 commit comments