diff options
| author | realtradam <[email protected]> | 2022-03-07 18:33:20 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-03-07 18:33:20 -0500 |
| commit | 9d440b24a50b54b1708123d77679477b14c4b3c0 (patch) | |
| tree | c75ddb2d8d1289a4768274e93822f862e0be44bf /generate.rb | |
| parent | 779d9f17adf189b45c6be2a4b3d0959019c5ad03 (diff) | |
| download | FelBind-9d440b24a50b54b1708123d77679477b14c4b3c0.tar.gz FelBind-9d440b24a50b54b1708123d77679477b14c4b3c0.zip | |
added some struct wrapping methods
Diffstat (limited to 'generate.rb')
| -rw-r--r-- | generate.rb | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/generate.rb b/generate.rb index 5889139..30ab22a 100644 --- a/generate.rb +++ b/generate.rb @@ -1,7 +1,6 @@ require 'optparse' require 'json' -require 'set' -require 'active_record' +require 'active_record' # use to make strings to snake_case. probably overkill require_relative './templates.rb' options = {} @@ -20,8 +19,6 @@ end.parse! options[:glue] ||= './glue.json' glue = JSON.parse(File.read(options[:glue])) -bound = {} - $phase1 = {} $phase2 = {} $phase3 = {} @@ -46,24 +43,23 @@ includes = %{ } defines = "" init_body = "" -standard_types = ['bool', 'int', 'float', 'double', 'float', 'const char *', 'unsigned int', 'void'] # for displaying statistics glue.first.each do |func, params| if (func.rpartition(' ').first == 'void') && (params[0] == 'void') $phase1[func] = params - elsif (standard_types.include? func.rpartition(' ').first) && (params[0] == 'void') + elsif (Tplt.non_struct_types.include? func.rpartition(' ').first) && (params[0] == 'void') $phase2[func] = params else no_struct_param = true params.each do |param| - if !(standard_types.include? param.rpartition(' ').first) + if !(Tplt.non_struct_types.include? param.rpartition(' ').first) no_struct_param = false break end end if no_struct_param - if standard_types.include? func.rpartition(' ').first + if Tplt.non_struct_types.include? func.rpartition(' ').first $phase3[func] = params else $phase4[func] = params @@ -106,28 +102,26 @@ glue.first.each do |func, params| defines += Tplt.function(func_name, body) init_body += Tplt.init_module_function('test', Tplt.rubify_func_name(func_name), func_name, "MRB_ARGS_NONE()") - bound[func] = params debug_mark_binding(func, params) # if phase 2 - elsif (standard_types.include? func_datatype) && (params[0] == 'void') + elsif (Tplt.non_struct_types.include? func_datatype) && (params[0] == 'void') body = Tplt.return_format(func, params) #defines += 'PHASE 2\n' defines += Tplt.function(func_name, body) init_body += Tplt.init_module_function('test', Tplt.rubify_func_name(func_name), func_name, "MRB_ARGS_NONE()") - bound[func] = params debug_mark_binding(func, params) - elsif standard_types.include? func_datatype # accept params + else Tplt.non_struct_types.include? func_datatype # accept params # detecting if there is no struct param(wont need this in the future) no_struct_param = true params.each do |param| - if !(standard_types.include? param.rpartition(' ').first) + if !(Tplt.non_struct_types.include? param.rpartition(' ').first) no_struct_param = false break end end if no_struct_param - if standard_types.include? func.rpartition(' ').first + if Tplt.non_struct_types.include? func.rpartition(' ').first #$phase3[func] = params # --- #body = '' @@ -152,9 +146,11 @@ glue.first.each do |func, params| init_body += Tplt.init_module_function('test', Tplt.rubify_func_name(func_name), func_name, "MRB_ARGS_OPT(1)") # opt stuff isnt correct, need to look at this again # --- #puts func - bound[func] = params debug_mark_binding(func, params) else + #puts func + #puts params + #puts '---' #$phase4[func] = params end else |
