From 081d4ff261b1ef684e95cc74bba70b603dfa0929 Mon Sep 17 00:00:00 2001 From: realtradam Date: Fri, 4 Mar 2022 03:51:38 -0500 Subject: partially sorted json export --- .gitignore | 2 ++ scan.rb | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c475cc9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +json.json +raylib.h diff --git a/scan.rb b/scan.rb index 2966f43..7e97639 100644 --- a/scan.rb +++ b/scan.rb @@ -1 +1,46 @@ -`ctags --output-format=json --c-kinds=pmz --language-force=c raylib.h` # convert to json +require 'json' + +parse = `ctags --output-format=json --c-kinds=pmz --language-force=c raylib.h` +File.write('json.json', parse) +$params = {} +$members = {} +$garbage = [] +$struct = [] +parse.each_line do |line| + json_line = JSON.parse line + puts json_line['kind'] + if json_line['kind'] == 'parameter' + if $params[json_line['scope']].nil? + $params[json_line['scope']] = [] + end + $params[json_line['scope']].push json_line + elsif json_line['kind'] == 'prototype' + $members[json_line['name']] = json_line + elsif json_line['kind'] == 'member' + if json_line['scopeKind'] == 'struct' + $struct.push json_line + else + $garbage.push json_line + end + else + if json_line['scopeKind'] == 'struct' + $garbage.push json_line + end + end +end + +$members.each do |key, item| + puts "Function: #{item['typeref'].gsub(/typename:[^ ]* /,'')} #{item['name']}" + $params.each do |key, param_arry| + param_arry.each do |param| + if param['scope'] == item['name'] + puts "#{param['typeref'].gsub('typename:','')} #{param['name']}" + end + end + end + puts '---' +end + +puts +puts "Struct: #{$struct.size}" +puts "Garbage: #{$garbage.size}(should be 0)" -- cgit v1.2.3