<commit_before>#!./libs/lua-5.2.2/src/lua
-- mm sdk tools

-- [mmerr] --------------------------------------------------------------------
mmerrs={ 
  missing_config="missing configuration file",
  missing_argument="missing argument",
  missing_api_m="missing api meta",
  missing_api_m_dirname="missing api meta dirname",
  missing_api_m_basename="missing api meta basename",
  missing_api_m_version="missing api meta version",
  missing_api_m_define="missing api meta define",
  missing_api="missing api",
}
mmerr = function (str) 
  print(str)
  os.exit(1)
end
-- [mmgen_api_c] -------------------------------------------------------------------
function mmgen_api_c()
  
  local filename_c = mmapi_m.dirname .. "/" .. mmapi_m.basename ..".c";
  local f_c = io.open (filename_c,"w")
  local api_t = "struct " .. mmapi_m.basename .. "_s";  

-- c header
  f_c:write([[#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>

]])
  f_c:write("#include \"" .. mmapi_m.basename .. ".h\" \n")
  f_c:write("int " .. mmapi_m.basename .. "_load(" .. api_t .. "* cfg_,const char* f_){ (void)cfg_;(void)f_;return 1;}\n")
      
  f_c:close()
  
  print("[INFO] " .. filename_c .. " generated")
   
end

-- [mmgen_api_h] -------------------------------------------------------------------
function mmgen_api_h()
  
-- struct
  local api_t = "struct " .. mmapi_m.basename .. "_s";
  
-- open files
  local filename_h = mmapi_m.dirname .. "/" .. mmapi_m.basename ..".h";
  local f_h = io.open (filename_h,"w")

-- h header  
  f_h:write("#ifndef " .. mmapi_m.define .. "\n")
  f_h:write("#define " .. mmapi_m.define .. "\n")
  f_h:write([[
    
#ifdef  __cplusplus
extern "C" {
#endif

]])

-- h config struct definition
  f_h:write(api_t .. "{\n" );

  for n,v in pairs(mmapi) do
    if (type(v) == 'table') then
      f_h:write(" struct {\n");
      for n2,v2 in pairs(v) do
        f_h:write("     " .. v2 .. " " .. n2 ..";\n")
      end
      f_h:write(" } " .. n .. ";\n");
    else  
      f_h:write(" " .. v .. " " .. n ..";\n")
    end
  end
  f_h:write("};\n" );

  f_h:write("int " .. mmapi_m.basename .. "_load(" .. api_t .. "*,const char*);\n")
  
-- h footer      
  f_h:write([[      
    
#ifdef  __cplusplus
}
#endif
<commit_msg>lua generator dump default config<commit_after>#!./libs/lua-5.2.2/src/lua
-- mm sdk tools

-- [mmerr] --------------------------------------------------------------------
mmerrs={ 
  missing_config="missing configuration file",
  missing_argument="missing argument",
  missing_api_m="missing api meta",
  missing_api_m_dirname="missing api meta dirname",
  missing_api_m_basename="missing api meta basename",
  missing_api_m_version="missing api meta version",
  missing_api_m_define="missing api meta define",
  missing_api="missing api",
}
mmerr = function (str) 
  print(str)
  os.exit(1)
end
-- [mmgen_api_c] -------------------------------------------------------------------
function mmgen_api_c()
  
  local filename_c = mmapi_m.dirname .. "/" .. mmapi_m.basename ..".c";
  local f_c = io.open (filename_c,"w")
  local api_t = "struct " .. mmapi_m.basename .. "_s";  

-- c header
  f_c:write([[#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>

]])
  f_c:write("#include \"" .. mmapi_m.basename .. ".h\" \n")
  f_c:write("int " .. mmapi_m.basename .. "_load(" .. api_t .. "* cfg_,const char* f_){ (void)cfg_;(void)f_;return 1;}\n")
  f_c:write("int " .. mmapi_m.basename .. "_default(const char* f_){(void)f_;return 1;}\n")
      
  f_c:close()
  
  print("[INFO] " .. filename_c .. " generated")
   
end

-- [mmgen_api_h] -------------------------------------------------------------------
function mmgen_api_h()
  
-- struct
  local api_t = "struct " .. mmapi_m.basename .. "_s";
  
-- open files
  local filename_h = mmapi_m.dirname .. "/" .. mmapi_m.basename ..".h";
  local f_h = io.open (filename_h,"w")

-- h header  
  f_h:write("#ifndef " .. mmapi_m.define .. "\n")
  f_h:write("#define " .. mmapi_m.define .. "\n")
  f_h:write([[
    
#ifdef  __cplusplus
extern "C" {
#endif

]])

-- h config struct definition
  f_h:write(api_t .. "{\n" );

  for n,v in pairs(mmapi) do
    if (type(v) == 'table') then
      f_h:write(" struct {\n");
      for n2,v2 in pairs(v) do
        f_h:write("     " .. v2 .. " " .. n2 ..";\n")
      end
      f_h:write(" } " .. n .. ";\n");
    else  
      f_h:write(" " .. v .. " " .. n ..";\n")
    end
  end
  f_h:write("};\n" );

  f_h:write("int " .. mmapi_m.basename .. "_load(" .. api_t .. "*,const char*);\n")
  f_h:write("int " .. mmapi_m.basename .. "_default(const char* f_);\n")
  
-- h footer      
  f_h:write([[      
    
#ifdef  __cplusplus
}
#endif

{'fraction_non_alphanumeric': 0.2693711096801889, 'fraction_numerical': 0.004078128353723975, 'mean_word_length': 1.9643765903307888, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3450892', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1761, 'n_words': 347}