├── .gitignore ├── LICENSE ├── README.md ├── assets ├── api │ ├── load_lib_overload.lua │ ├── parse_to_bytes.lua │ ├── require_overload.lua │ ├── resset_require.lua │ ├── resset_so.lua │ └── so_actions.lua └── cli │ └── help.txt ├── build ├── assets.lua ├── dependencies.lua ├── embed_c.lua ├── main.lua └── types.lua ├── docs ├── api_usage.md ├── build.md ├── cli_usage.md └── dependencies.md ├── src ├── api │ ├── darwin │ │ ├── config.lua │ │ ├── create_project.lua │ │ └── file_stream.lua │ ├── private_darwin │ │ ├── assets.lua │ │ ├── extra.lua │ │ ├── native_funcs.lua │ │ ├── stream.lua │ │ └── string_functions.lua │ └── private_darwin_project │ │ ├── constructors │ │ ├── c.lua │ │ ├── lua.lua │ │ └── props.lua │ │ └── methods │ │ ├── c │ │ ├── c_data.lua │ │ ├── c_embed.lua │ │ ├── executable_generators.lua │ │ └── lib_generators.lua │ │ ├── embed_global.lua │ │ └── lua │ │ ├── add.lua │ │ ├── add_follow.lua │ │ ├── generators.lua │ │ └── lua_embed.lua └── cli │ ├── blueprint_mode.lua │ ├── colors.lua │ ├── default_execution.lua │ ├── drop.lua │ ├── embed_data.lua │ ├── errors.lua │ ├── lua_save.lua │ ├── main.lua │ └── projects │ ├── dynamic_link_lib.lua │ ├── executabe_bin_project.lua │ ├── executable_c_project.lua │ ├── lib_source.lua │ └── lua_project.lua └── types ├── LuaShip.lua ├── PrivateDarwinEmbed.lua ├── asset.lua ├── camalgamator.lua ├── candango.lua ├── cgeneration_props.lua ├── consts.lua ├── darwin.lua ├── darwin_project.lua ├── darwin_stream.lua ├── dtw.lua ├── lua_argv.lua ├── lua_generation.lua ├── private_darwin.lua ├── private_darwin_project.lua └── required_funcs.lua /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | debug.lua 4 | candangoEngine 5 | LuaDoTheWorld 6 | release 7 | LuaCEmbed.h 8 | cli 9 | cli.lua 10 | internal_build* 11 | assets/LuaCEmbed.h 12 | dependencies 13 | teste.sh 14 | teste 15 | assets/api/LuaCEmbedOne.c 16 | types0* 17 | local_move.sh 18 | teste.lua 19 | final* 20 | teste.c 21 | first.c 22 | final.o 23 | local_build.sh 24 | darwin0* 25 | test.lua 26 | final.c 27 | # Object files 28 | *.o 29 | *.ko 30 | *.obj 31 | *.elf 32 | 33 | # Linker output 34 | *.ilk 35 | *.map 36 | *.exp 37 | 38 | # Precompiled Headers 39 | *.gch 40 | *.pch 41 | 42 | # Libraries 43 | *.lib 44 | *.a 45 | *.la 46 | *.lo 47 | 48 | # Shared objects (inc. Windows DLLs) 49 | *.dll 50 | *.so 51 | *.so.* 52 | *.dylib 53 | 54 | # Executables 55 | *.exe 56 | *.out 57 | *.app 58 | *.i*86 59 | *.x86_64 60 | *.hex 61 | 62 | # Debug files 63 | *.dSYM/ 64 | *.su 65 | *.idb 66 | *.pdb 67 | 68 | # Kernel Module Compile Results 69 | *.mod* 70 | *.cmd 71 | .tmp_versions/ 72 | modules.order 73 | Module.symvers 74 | Mkfile.old 75 | dkms.conf 76 | 77 | build_teste.sh 78 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 OUI 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Darwin 2 | The Most Advanced Lua Compiler 3 | ## Generations 4 | - windows executable 5 | - Linux Executable 6 | - C/C++ code 7 | - SO Library 8 | - Lua Amalgamation 9 | 10 | ## Features 11 | - Embedding Files 12 | - Embedding Folder 13 | - Embedding Variables 14 | - C/C++ Integration 15 | - Comptime Lua Code Manipulation 16 | 17 | ## Quick Example 18 | ```bash 19 | darwin test.lua -o test.out 20 | ``` 21 | 22 | ## Quick Install 23 | if you are on linux you can install with: 24 | ```bash 25 | curl -L https://github.com/OUIsolutions/Darwin/releases/download/0.3.0/darwin.out -o darwin.out && sudo chmod +x darwin.out && sudo mv darwin.out /usr/bin/darwin 26 | ``` 27 | 28 | ## Releases 29 | | item | plataform | 30 | |------- |-----------| 31 | | [Amalgamation](https://github.com/OUIsolutions/Darwin/releases/download/0.3.0/darwin.c)| Source | 32 | | [darwin.out](https://github.com/OUIsolutions/Darwin/releases/download/0.3.0/darwin.out)|Linux binary| 33 | | [darwin.exe](https://github.com/OUIsolutions/Darwin/releases/download/0.3.0/darwin.exe)|Windows binary | 34 | 35 | 36 | 37 | ## References 38 | 39 | | item | explanation | 40 | |------- |-----------| 41 | | [Build](/docs/build.md)| Build Instructions | 42 | | [Cli Usage](/docs/cli_usage.md)| Comand line Instructions| 43 | | [Api Usage](/docs/api_usage.md)| Api Usage For Blue Print Generation| 44 | | [Dependencies](/docs/dependencies.md)| Dependencies and License list| 45 | -------------------------------------------------------------------------------- /assets/api/load_lib_overload.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | Private_darwin_old_package = package.loadlib 4 | 5 | package.loadlib = function (item, funcname) 6 | 7 | for i =1,#REQUIRE_SO do 8 | local current = REQUIRE_SO[i] 9 | if current.comptime_included == item then 10 | if current.loaded_obj then 11 | return current.loaded_obj 12 | end 13 | local dest = PRIVATE_DARWIN_SO_DEST.."/"..i..".so" 14 | current.loaded_obj = Private_darwin_old_package(dest,funcname) 15 | if not current.loaded_obj then 16 | error("impossible to load "..dest) 17 | end 18 | return current.loaded_obj 19 | end 20 | end 21 | return Private_darwin_old_package(item, funcname) 22 | end 23 | 24 | 25 | -------------------------------------------------------------------------------- /assets/api/parse_to_bytes.lua: -------------------------------------------------------------------------------- 1 | function PrivateDarwing_parse_to_bytes(seq) 2 | local buffer = {} 3 | for i = 1, #seq do 4 | buffer[#buffer + 1] = string.char(seq[i]) 5 | end 6 | return buffer 7 | end 8 | -------------------------------------------------------------------------------- /assets/api/require_overload.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | Private_darwin_old_require = require 4 | if not Private_darwin_old_package then 5 | Private_darwin_old_package = package.loadlib 6 | end 7 | 8 | 9 | 10 | function require(item) 11 | if REQUIRE_SO then 12 | for i =1,#REQUIRE_SO do 13 | 14 | local current = REQUIRE_SO[i] 15 | if current.comptime_included == item then 16 | if current.loaded_obj then 17 | return current.loaded_obj 18 | end 19 | local dest = PRIVATE_DARWIN_SO_DEST.."/"..i..".so" 20 | current.loaded_obj = Private_darwin_old_package(dest,"luaopen_"..current.comptime_included) 21 | if not current.loaded_obj then 22 | error("impossible to load "..dest) 23 | end 24 | current.loaded_obj = current.loaded_obj() 25 | return current.loaded_obj 26 | end 27 | end 28 | end 29 | 30 | for i = 1, #REQUIRE_FUNCS do 31 | local current = REQUIRE_FUNCS[i] 32 | 33 | if current.comptime_include == item then 34 | if current.loaded_obj then 35 | return current.loaded_obj 36 | end 37 | current.loaded_obj = current.content() 38 | return current.loaded_obj 39 | end 40 | end 41 | return Private_darwin_old_require(item) 42 | end 43 | 44 | -------------------------------------------------------------------------------- /assets/api/resset_require.lua: -------------------------------------------------------------------------------- 1 | 2 | if Private_darwin_old_require then 3 | require = Private_darwin_old_require 4 | end -------------------------------------------------------------------------------- /assets/api/resset_so.lua: -------------------------------------------------------------------------------- 1 | 2 | if Private_darwin_old_package then 3 | package.loadlib = Private_darwin_old_package 4 | end -------------------------------------------------------------------------------- /assets/api/so_actions.lua: -------------------------------------------------------------------------------- 1 | 2 | ---create a dir for dest if not exists 3 | 4 | os.execute("mkdir -p "..PRIVATE_DARWIN_SO_DEST) 5 | 6 | for i=1, #SO_INCLUDE do 7 | local current = SO_INCLUDE[i] 8 | local dest = PRIVATE_DARWIN_SO_DEST.."/"..i..".so" 9 | local write_point = io.open(dest, "wb") 10 | if not write_point then 11 | error("impossible to write in "..dest) 12 | end 13 | write_point:write(current.content) 14 | end 15 | 16 | -------------------------------------------------------------------------------- /assets/cli/help.txt: -------------------------------------------------------------------------------- 1 | 2 | Darwin Compiler Help 3 | ===================== 4 | Version:DARWIN_VERSION 5 | Usage: 6 | darwin -o [options] 7 | 8 | Examples: 9 | Linux Compilation: 10 | darwin main.lua -o my_program.out 11 | 12 | Windows Compilation: 13 | darwin main.lua -o my_program.exe 14 | 15 | Options: 16 | -compiler 17 | Set a custom compiler. Default: "gcc" (Linux) or "i686-w64-mingw32-gcc" (Windows). 18 | Example: darwin main.lua -o my_program.out -compiler clang 19 | 20 | -flags 21 | Add compilation flags. 22 | Example: darwin main.lua -o my_program.out -flags -DMY_DEFINITION -flags-static 23 | 24 | --embed_vars -:file 25 | Embed global variables or files into the project. 26 | Example: darwin main.lua -o my_program.out --embed_vars my_image -my_image:file my_file.png 27 | 28 | run_blueprint [-mode ] 29 | Generate a blueprint from a file or folder. 30 | - Mode "file" (default): Load the specified file or "darwinconf.lua" if no file is provided. 31 | Example: ./darwin.out run_blueprint props.lua 32 | - Mode "folder": Recursively load files in a folder, requiring a main function. 33 | Example: ./darwin.out run_blueprint my_folder -mode folder 34 | 35 | -c_include 36 | Add C include files to the project. 37 | Example: darwin main.lua -o my_program.out -c_include my_include.h 38 | 39 | -c_calls 40 | Add a C function call to the project. The function must be defined in the C include file 41 | and have the following signature: 42 | void my_c_function(LuaCEmbed *lua); 43 | Example: darwin main.lua -o my_program.out -c_calls my_func 44 | 45 | -c_lib --:func 46 | Load a C library and specify a function to be loaded. 47 | Example: darwin main.lua -o my_program.out -c_lib dtw --dtw:func load_luaDoTheWorld 48 | 49 | -amalgamation 50 | Add an amalgamation C file to the project. 51 | Example: darwin main.lua -o my_program.out -amalgamation my_amalgamation.c 52 | -------------------------------------------------------------------------------- /build/assets.lua: -------------------------------------------------------------------------------- 1 | function Create_api_assets(project) 2 | ---@type Asset[] 3 | local api_assets = {} 4 | 5 | local assets_files = darwin.dtw.list_files_recursively("assets/api", false) 6 | for i = 1, #assets_files do 7 | local current_item = assets_files[i] 8 | local path = "assets/api/" .. current_item 9 | api_assets[#api_assets + 1] = { 10 | path = current_item, 11 | content = darwin.dtw.load_file(path) 12 | } 13 | end 14 | 15 | project.embed_global("PRIVATE_DARWIN_API_ASSETS", api_assets) 16 | 17 | local cli_assets = {} 18 | local cli_files = darwin.dtw.list_files_recursively("assets/cli", false) 19 | for i = 1, #cli_files do 20 | local current_item = cli_files[i] 21 | local path = "assets/cli/" .. current_item 22 | cli_assets[#cli_assets + 1] = { 23 | path = current_item, 24 | content = darwin.dtw.load_file(path) 25 | } 26 | end 27 | 28 | project.embed_global("PRIVATE_DARWIN_CLI_ASSETS", cli_assets) 29 | end 30 | -------------------------------------------------------------------------------- /build/dependencies.lua: -------------------------------------------------------------------------------- 1 | function Install_all_dependencies() 2 | local hasher = darwin.dtw.newHasher() 3 | hasher.digest_folder_by_content("dependencies") 4 | local EXPECTED_HASH = '9243cee2af9d5487931f8dcf43aca20e4e0fc0529c53b8f061f90fe7a2772b46' 5 | if hasher.get_value() == EXPECTED_HASH then 6 | return 7 | end 8 | 9 | darwin.dtw.remove_any("dependencies") 10 | local commands = { 11 | 12 | "mkdir dependencies", 13 | "cd dependencies && curl -L https://github.com/OUIsolutions/LuaFluidJson/releases/download/0.6.1/luaFluidJson_no_dep.c -o luaFluidJson_no_dep.c", 14 | "cd dependencies && curl -L https://github.com/OUIsolutions/LuaDoTheWorld/releases/download/0.7.2/luaDoTheWorld_no_dep.c -o luaDoTheWorld_no_dep.c", 15 | "cd dependencies && git clone -b V0.003 https://github.com/SamuelHenriqueDeMoraisVitrio/candangoEngine.git", 16 | "cd dependencies && curl -L https://github.com/OUIsolutions/CTextEngine/releases/download/3.0.000/CTextEngineOne.c -o CTextEngineOne.c", 17 | "cd assets/api && curl -L https://github.com/OUIsolutions/LuaCEmbed/releases/download/0.8.3/LuaCEmbedOne.c -o LuaCEmbedOne.c", 18 | "cd dependencies && curl -L https://github.com/OUIsolutions/DoTheWorld/releases/download/10.1.1/doTheWorldOne.c -o doTheWorldOne.c", 19 | "cd dependencies && curl -L https://github.com/OUIsolutions/LuaArgv/releases/download/0.1.0/luargv.lua -o luargv.lua", 20 | 'cd dependencies && curl -L https://github.com/OUIsolutions/LuaShip/releases/download/0.1.0/LuaShip.lua -o LuaShip.lua', 21 | "cd dependencies && curl -L https://github.com/OUIsolutions/LuaSilverChain/releases/download/0.1.2/silverchain_no_dependecie_included.c -o silverchain_no_dependecie_included.c", 22 | "cd dependencies && curl -L https://github.com/OUIsolutions/LuaCAmalgamator/releases/download/0.1.0/lua_c_amalgamator_dependencie_not_included.c -o lua_c_amalgamator_dependencie_not_included.c" 23 | } 24 | 25 | for _, cmd in ipairs(commands) do 26 | os.execute(cmd) 27 | end 28 | local new_hasher = darwin.dtw.newHasher() 29 | new_hasher.digest_folder_by_content("dependencies") 30 | print("dependencie hash: " .. new_hasher.get_value()) 31 | end 32 | -------------------------------------------------------------------------------- /build/embed_c.lua: -------------------------------------------------------------------------------- 1 | function Embed_c_code(project) 2 | project.add_c_file("dependencies/CTextEngineOne.c") 3 | project.add_c_external_code("#define error LuaError\n") 4 | project.add_c_file("assets/api/LuaCEmbedOne.c") 5 | project.add_c_external_code("#undef error\n") 6 | project.add_c_file("dependencies/doTheWorldOne.c") 7 | project.add_c_file("dependencies/lua_c_amalgamator_dependencie_not_included.c") 8 | project.add_c_file("dependencies/silverchain_no_dependecie_included.c") 9 | project.add_c_file("dependencies/luaDoTheWorld_no_dep.c") 10 | project.add_c_file("dependencies/luaFluidJson_no_dep.c") 11 | project.add_c_file("dependencies/candangoEngine/src/main.c", true, function(path,import) 12 | -- to make the luacembe not be imported twice 13 | if import == "../dependencies/depB.LuaCEmbed.h" then 14 | return false 15 | end 16 | return true 17 | end) 18 | 19 | 20 | project.load_lib_from_c("luaopen_lua_c_amalgamator", "private_darwin_camalgamator") 21 | project.load_lib_from_c("luaopen_lua_silverchain", "private_darwin_silverchain") 22 | project.load_lib_from_c("load_luaDoTheWorld", "private_darwin_dtw") 23 | project.load_lib_from_c("load_lua_fluid_json", "private_darwin_json") 24 | project.load_lib_from_c("candango_engine_start_point", "private_darwin_candango") 25 | end 26 | -------------------------------------------------------------------------------- /build/main.lua: -------------------------------------------------------------------------------- 1 | function main() 2 | Install_all_dependencies() 3 | 4 | local valid_builds = { 5 | "build_source", 6 | "build_linux", 7 | "build_linux_from_docker", 8 | "build_windows", 9 | "build_windows_from_source" 10 | } 11 | local generate_source = false 12 | for _, item in ipairs(valid_builds) do 13 | if darwin.argv.one_of_args_exist(item) then 14 | generate_source = true 15 | end 16 | end 17 | 18 | if generate_source then 19 | local project = darwin.create_project("darwin") 20 | Embed_c_code(project) 21 | Create_api_assets(project) 22 | Embed_types(project) 23 | 24 | project.add_lua_code("darwin = {}") 25 | if darwin.argv.one_of_args_exist("build_linux") then 26 | project.add_lua_code("darwin.os = 'linux'") 27 | end 28 | if darwin.argv.one_of_args_exist("build_windows") then 29 | project.add_lua_code("darwin.os = 'windows'") 30 | end 31 | project.add_lua_code("darwin.dtw=private_darwin_dtw") 32 | project.add_lua_code("darwin.json=private_darwin_json") 33 | project.add_lua_code("darwin.candango=private_darwin_candango") 34 | project.add_lua_code("darwin.camalgamator=private_darwin_camalgamator") 35 | project.add_lua_code("darwin.silverchain = private_darwin_silverchain") 36 | local lua_argv_content = darwin.dtw.load_file("dependencies/luargv.lua") 37 | project.add_lua_code(string.format( 38 | "darwin.argv = function()\n %s\n end \n", 39 | lua_argv_content 40 | )) 41 | project.add_lua_code("darwin.argv = darwin.argv()") 42 | 43 | 44 | local lua_ship_content = darwin.dtw.load_file("dependencies/LuaShip.lua") 45 | project.add_lua_code(string.format( 46 | "darwin.ship = function()\n %s\n end \n", 47 | lua_ship_content 48 | )) 49 | project.add_lua_code("darwin.ship = darwin.ship()") 50 | 51 | 52 | 53 | 54 | project.add_lua_code("private_darwin = {}") 55 | 56 | project.add_lua_code("private_darwin_project = {}") 57 | local src_files = darwin.dtw.list_files_recursively("src", true) 58 | for i = 1, #src_files do 59 | local current = src_files[i] 60 | project.add_lua_code("-- file " .. current) 61 | project.add_lua_file(current) 62 | end 63 | 64 | 65 | project.add_lua_code("private_darwin.main()") 66 | project.generate_lua_file({ output = "debug.lua" }) 67 | project.generate_c_file({ output = "release/darwin.c", include_lua_cembed = false }) 68 | end 69 | 70 | 71 | if darwin.argv.one_of_args_exist("build_windows_from_docker") then 72 | local image = darwin.ship.create_machine("debian:latest") 73 | image.add_comptime_command("apt-get update") 74 | image.add_comptime_command("apt-get -y install mingw-w64") 75 | image.start({ 76 | volumes = { 77 | { "./release", "/release" } 78 | }, 79 | command = "i686-w64-mingw32-gcc --static /release/darwin.c -o /release/darwin.exe" 80 | }) 81 | end 82 | if darwin.argv.one_of_args_exist("build_windows") then 83 | os.execute("i686-w64-mingw32-gcc --static release/darwin.c -o release/darwin.exe") 84 | end 85 | 86 | if darwin.argv.one_of_args_exist("build_linux_from_docker") then 87 | local image = darwin.ship.create_machine("alpine:latest") 88 | image.add_comptime_command("apk update") 89 | image.add_comptime_command("apk add --no-cache gcc musl-dev curl") 90 | 91 | image.start({ 92 | volumes = { 93 | { "./release", "/release" } 94 | }, 95 | command = "gcc --static /release/darwin.c -o /release/darwin.out" 96 | }) 97 | end 98 | 99 | if darwin.argv.one_of_args_exist("build_linux") then 100 | if darwin.argv.one_of_args_exist("no_static") then 101 | os.execute("gcc release/darwin.c -o release/darwin.out") 102 | else 103 | os.execute("gcc --static release/darwin.c -o release/darwin.out") 104 | end 105 | end 106 | if darwin.argv.one_of_args_exist("debug") then 107 | os.execute("gcc release/darwin.c -o release/debug.out") 108 | end 109 | end 110 | -------------------------------------------------------------------------------- /build/types.lua: -------------------------------------------------------------------------------- 1 | function Embed_types(project) 2 | local types = "" 3 | local types_files = darwin.dtw.list_files_recursively("types", true) 4 | for i = 1, #types_files do 5 | types = types .. "\n" .. darwin.dtw.load_file(types_files[i]) 6 | end 7 | project.embed_global("PRIVATE_DARWIN_TYPES", types) 8 | end 9 | -------------------------------------------------------------------------------- /docs/api_usage.md: -------------------------------------------------------------------------------- 1 | 2 | ## Project Explanation 3 | the first thing you need to do, its to create a a project,then you can add lua and C code to it 4 | ```lua 5 | project = darwin.create_project("teste") 6 | ``` 7 | ### Working with Lua 8 | 9 | ## Adding lua Code 10 | you can add what ever lua code you want by calling **project.add_lua_code** 11 | ```lua 12 | project.add_lua_code("print('Hello World!')") 13 | ``` 14 | ## Adding Lua File 15 | you also can add a lua file to your project 16 | ```lua 17 | project.add_lua_file("test.lua") 18 | ``` 19 | 20 | ## Adding lua File Following Require 21 | you can add a lua file ,and follow all **requires** and **packages.load_lib** of your code, 22 | and them embed into your final code with 23 | ```lua 24 | project.add_lua_file_following_require("test.lua") 25 | ``` 26 | 27 | ### Generatig lua output 28 | you can generate a lua file with: 29 | ```lua 30 | project.generate_lua_file({output="my_out.lua",include_embed_data=true}) 31 | ``` 32 | you also can get the lua code generation with: 33 | ```lua 34 | local code = project.generate_lua_code({include_embed_data=true}) 35 | ``` 36 | if you need , you can generate lua code streaming data to what ever you want 37 | ```lua 38 | project.generate_lua_complex({ 39 | 40 | stream=function(s) 41 | print(s) 42 | end, 43 | include_embed_data=true 44 | }) 45 | ``` 46 | 47 | 48 | ### Working With C 49 | 50 | 51 | ### Adding C include 52 | you can add a C include file to be included into your main code 53 | ```lua 54 | project.add_c_include("teste.c") 55 | ``` 56 | 57 | ### Adding C File 58 | you also can add a C file directly, and you also can decide to include all the itens of file recusively 59 | ```lua 60 | local follow_require = true 61 | local verifier_callback = function (import,path) 62 | print("import",import) 63 | print("path",path) 64 | print("----------------") 65 | --if you return false the file will not be added 66 | return true 67 | end 68 | project.add_c_file("LuaDoTheWorld/src/one.c",true,verifier_callback) 69 | ``` 70 | 71 | ### Adding C call func 72 | you can set a c function to be called on your main code 73 | ```lua 74 | project.add_c_call("my_c_function") 75 | ``` 76 | these function must accept **LuaCEmbed** as first argument and return void,for having 77 | [LuaCEmbed.c](https://github.com/OUIsolutions/LuaCEmbed) file run: 78 | ```bash 79 | darwin drop_lua_cembed 80 | ``` 81 | function example: 82 | ```c 83 | 84 | #include "LuaCEmbed.c" 85 | void my_c_function(LuaCEmbed *lua) 86 | { 87 | printf("Hello World\n"); 88 | } 89 | ``` 90 | ## Load a C Library 91 | for load a clib, the function must follow the pattern : 92 | ```c 93 | int your_func(lua_State *state); 94 | ``` 95 | and you can add it to your project with: 96 | ```lua 97 | project.load_lib_from_c("your_func","my_output_object") 98 | ``` 99 | and a global object will be created with the name **my_output_object** 100 | 101 | 102 | ### Generating C output 103 | you can generate a C file with: 104 | ```lua 105 | project.generate_c_file({output="mycode.c",include_lua_cembed=true}) 106 | ``` 107 | you also can get the C code generation with: 108 | ```lua 109 | local code = project.generate_c_code({include_lua_cembed=true}) 110 | ``` 111 | if you need , you can generate C code streaming data to what ever you want 112 | ```lua 113 | project.generate_c_complex({ 114 | 115 | stream=function(s) 116 | print(s) 117 | end, 118 | include_lua_cembed=true 119 | }) 120 | ``` 121 | 122 | ### Generating C lib 123 | you can generate a C lib with: 124 | ```lua 125 | project.generate_c_lib_file({ 126 | output="mycode.c", 127 | include_lua_cembed=true, 128 | lib_name="mylib", 129 | object_export="my_object" 130 | }) 131 | 132 | ``` 133 | where lib name will became the name of the lib, with a c function called **luaopen_mylib** and a global object that will be returned by the function called **my_object** 134 | 135 | ### Generating C lib Code 136 | you can generate a C lib code with: 137 | ```lua 138 | local code = project.generate_c_lib_code({ 139 | include_lua_cembed=true, 140 | lib_name="mylib", 141 | object_export="my_object" 142 | }) 143 | ``` 144 | 145 | ### Generating C lib Code Streaming 146 | if you need , you can generate C lib code streaming data to what ever you want 147 | ```lua 148 | project.generate_c_lib_complex({ 149 | 150 | stream=function(s) 151 | print(s) 152 | end, 153 | include_lua_cembed=true, 154 | lib_name="mylib", 155 | object_export="my_object" 156 | }) 157 | ``` 158 | 159 | 160 | ## Building libs 161 | Darwin Have The Follow libs native 162 | 163 | | Object Name | Lib Name | 164 | |--------------|---------| 165 | |darwin.camalgamator | [LuaCAmalgamator](https://github.com/OUIsolutions/LuaCAmalgamator) | 166 | |darwin.dtw| [LuaDoTheWorld](https://github.com/OUIsolutions/LuaDoTheWorld)| 167 | |darwin.candango|[candangoEngine](https://github.com/SamuelHenriqueDeMoraisVitrio/candangoEngine) | 168 | |darwin.json|[LuaFluidJson](https://github.com/OUIsolutions/LuaFluidJson) | 169 | |darwin.argv|[LuaFluidJson](https://github.com/OUIsolutions/LuaArgv) | 170 | |darwin.silverchain|[LuaFluidJson](https://github.com/OUIsolutions/LuaSilverChain) | 171 | |darwin.ship|[LuaShip](https://github.com/OUIsolutions/LuaShip)| 172 | -------------------------------------------------------------------------------- /docs/build.md: -------------------------------------------------------------------------------- 1 | 2 | ## Building From source 3 | for building from source, type 4 | ```bash 5 | curl -L https://github.com/OUIsolutions/Darwin/releases/download/0.3.0/darwin.c -o darwin.c && 6 | gcc darwin.c -o darwin.out 7 | ``` 8 | ### Building From Docker 9 | for building from docker,you must have darwin installed on version 0.020 and docker installed,clone the repo then type 10 | ```bash 11 | darwin run_blueprint build/ --mode folder build_linux_from_docker build_windows_from_docker 12 | ``` 13 | 14 | ### Building From Native 15 | for building from native,you must have darwin installed on version 0.020,gcc with the **--static** flag and **mingw** installed,clone the repo then type 16 | 17 | ```bash 18 | darwin run_blueprint build/ --mode folder build_linux build_windows 19 | ``` 20 | ### Building Only source 21 | you can build the source amalgamation **darwin.c** only 22 | ```bash 23 | darwin run_blueprint build/ --mode folder build_source 24 | ``` 25 | -------------------------------------------------------------------------------- /docs/cli_usage.md: -------------------------------------------------------------------------------- 1 | ## Compilations 2 | 3 | ### Linux Compilation 4 | these generate a basic linux compilation 5 | 6 | ```shell 7 | darwin main.lua -o my_program.out 8 | ``` 9 | 10 | ### Windows Compilation 11 | ```shell 12 | darwin main.lua -o my_program.exe 13 | ``` 14 | ### Setting Compiler 15 | you can set compilers and flags, in windows compilation,the default compiler its 16 | **"i686-w64-mingw32-gcc** and on linux its **gcc** ,but you can set the compiler with 17 | **compiler** flag 18 | ```shell 19 | darwin main.lua -o my_program.out -compiler clang 20 | ``` 21 | ### Setting flags 22 | its also possible to set compilation flags with the **flags** flag 23 | ```shell 24 | darwin main.lua -o my_program.out -compiler clang -flags -DMY_DEFINITION -flags-static 25 | ``` 26 | 27 | ### Embedding Global Variables 28 | you can embed data into your priject, you just need to especify the **--embed_vars** flags 29 | 30 | ```shell 31 | darwin main.lua -o my_program.out -embed_vars my_image -my_image:file my_file.png 32 | ``` 33 | you can embed **files**, **folders** and **text**, just change :file for :folder or :text 34 | 35 | 36 | ### Generating Blue Prints 37 | if you need to make the you compilation props into a **darwinconf.lua** file , you can make your generation by passing a file to be **interpreted** 38 | ```shell 39 | ./darwin.out run_blueprint props.lua 40 | ``` 41 | if you dont pass the **props.lua** darwin will try to open a **darwinconf.lua** file 42 | 43 | ### Generating Blue Prints by folder 44 | you also can generate a blue print by folder ,but you need to specify the mode as **folder**, and your code 45 | must have a **main** function,since it will load recursively all files of the folder, then 46 | call the **main** function 47 | 48 | ```shell 49 | ./darwin.out run_blueprint my_folder -mode folder 50 | ``` 51 | ### Adding C include files 52 | 53 | you can add c include files to your project by passing the **-c_include** flag 54 | ```shell 55 | darwin main.lua -o my_program.out -c_include my_include.h 56 | ``` 57 | 58 | ### Adding C Calls 59 | you can add c calls to your project by passing the **-c_calls** flag 60 | ```shell 61 | darwin main.lua -o my_program.out -c_calls my_func 62 | ``` 63 | note that the **my_func** must be a function that is defined in the **c_include** file 64 | and must follow the following signature 65 | ```c 66 | void my_c_function(LuaCEmbed *lua); 67 | ``` 68 | 69 | ### Load a C Library 70 | you can load a c library by passing the **-c_lib** flag 71 | ```shell 72 | darwin main.lua -o my_program.out --lib_objects dtw --dtw:func load_luaDoTheWorld 73 | ``` 74 | 75 | ### Adding a amalgamation 76 | you can add a amalgamation to your project by passing the **-amalgamation** flag 77 | ```shell 78 | darwin main.lua -o my_program.out -amalgamation my_amalgamation.c 79 | ``` 80 | 81 | ### Type anotations 82 | to get type annotations just type: 83 | ```bash 84 | darwin drop_types 85 | ``` 86 | -------------------------------------------------------------------------------- /docs/dependencies.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### DePendencies: 4 | ## Lua: 5 | **Lua** from https://lua.org/ 6 | 7 | Lua is free software distributed under the terms of the MIT license reproduced here. Lua may be used for any purpose, including commercial purposes, at absolutely no cost. No paperwork, no royalties, no GNU-like "copyleft" restrictions, either. Just download it and use it. 8 | 9 | Lua is certified Open Source software. [Open Source Initiative Approved License]Its license is simple and liberal and is compatible with GPL. Lua is not in the public domain and PUC-Rio keeps its copyright. 10 | 11 | The spirit of the Lua license is that you are free to use Lua for any purpose at no cost without having to ask us. The only requirement is that if you do use Lua, then you should give us credit by including the copyright notice somewhere in your product or its documentation. A nice, but optional, way to give us further credit is to include a Lua logo and a link to our site in a web page for your product. 12 | 13 | The Lua language is entirely designed, implemented, and maintained by a team at PUC-Rio in Brazil. The implementation is not derived from licensed software. 14 | 15 | 16 | ## LuaCEmbed 17 | **LuaCEmbed** from: https://github.com/OUIsolutions/LuaCEmbed 18 | MIT License 19 | 20 | Copyright (c) 2024 Mateus Moutinho Queiroz 21 | 22 | Permission is hereby granted, free of charge, to any person obtaining a copy 23 | of this software and associated documentation files (the "Software"), to deal 24 | in the Software without restriction, including without limitation the rights 25 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 26 | copies of the Software, and to permit persons to whom the Software is 27 | furnished to do so, subject to the following conditions: 28 | 29 | The above copyright notice and this permission notice shall be included in all 30 | copies or substantial portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | 40 | 41 | ## LuaDoTheWorld 42 | **LuaDoTheWorld**:from https://github.com/OUIsolutions/LuaDoTheWorld 43 | MIT License 44 | 45 | Copyright (c) 2024 OUI 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a copy 48 | of this software and associated documentation files (the "Software"), to deal 49 | in the Software without restriction, including without limitation the rights 50 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 51 | copies of the Software, and to permit persons to whom the Software is 52 | furnished to do so, subject to the following conditions: 53 | 54 | The above copyright notice and this permission notice shall be included in all 55 | copies or substantial portions of the Software. 56 | 57 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 58 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 59 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 60 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 61 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 62 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 63 | SOFTWARE. 64 | ## DoTheWorld 65 | MIT License 66 | **DoTHeWorld** from: https://github.com/OUIsolutions/DoTheWorld 67 | Copyright (c) 2023 Mateus Moutinho Queiroz 68 | 69 | Permission is hereby granted, free of charge, to any person obtaining a copy 70 | of this software and associated documentation files (the "Software"), to deal 71 | in the Software without restriction, including without limitation the rights 72 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 73 | copies of the Software, and to permit persons to whom the Software is 74 | furnished to do so, subject to the following conditions: 75 | 76 | The above copyright notice and this permission notice shall be included in all 77 | copies or substantial portions of the Software. 78 | 79 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 80 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 81 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 82 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 83 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 84 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 85 | SOFTWARE. 86 | 87 | ## CJson

88 | **CJson**: from https://github.com/DaveGamble/cJSON
89 | Copyright (c) 2009-2017 Dave Gamble and cJSON contributors 90 | 91 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 92 | 93 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 94 | 95 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 96 | 97 | ## sha-256
98 | **sha-256**: from https://github.com/amosnier/sha-2
99 | 100 | Zero Clause BSD License 101 | © 2021 Alain Mosnier 102 | 103 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. 104 | 105 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 106 | -------------------------------------------------------------------------------- /src/api/darwin/config.lua: -------------------------------------------------------------------------------- 1 | darwin.chunk_size = 1048576 ---One mega 2 | darwin.version = "0.3.0" -------------------------------------------------------------------------------- /src/api/darwin/create_project.lua: -------------------------------------------------------------------------------- 1 | darwin.create_project = function(project_name) 2 | local selfobj = {} 3 | if not project_name then 4 | error("project_name is required") 5 | end 6 | 7 | selfobj.project_name = project_name 8 | selfobj.embed_global = function(name, value) 9 | private_darwin_project.embed_global(selfobj, name, value) 10 | end 11 | 12 | private_darwin_project.construct_globals(selfobj) 13 | private_darwin_project.add_lua_methods(selfobj) 14 | private_darwin_project.add_c_methods(selfobj) 15 | private_darwin_project.embed_global(selfobj, 16 | "PRIVATE_DARWIN_"..selfobj.project_name.."_SO_INCLUDED", 17 | selfobj.so_includeds 18 | ) 19 | 20 | return selfobj 21 | end 22 | -------------------------------------------------------------------------------- /src/api/darwin/file_stream.lua: -------------------------------------------------------------------------------- 1 | darwin.file_stream = function(src) 2 | return { 3 | type = "DarwinFileStream", 4 | filename = src 5 | } 6 | end 7 | -------------------------------------------------------------------------------- /src/api/private_darwin/assets.lua: -------------------------------------------------------------------------------- 1 | private_darwin.get_asset = function(asset_struct, src) 2 | for i = 1, #asset_struct do 3 | local current = asset_struct[i] 4 | if current.path == src then 5 | return current.content 6 | end 7 | end 8 | error("unknow asset" .. src) 9 | end 10 | 11 | 12 | private_darwin.list_assets_recursivly = function(asset_struct, src) 13 | local result = {} 14 | 15 | for i = 1, #asset_struct do 16 | local current = asset_struct[i] 17 | if private_darwin.starts_with(current.path, src .. "/") then 18 | local formmated_path = string.sub(current.path, #src + 2, #current.path) 19 | result[#result + 1] = formmated_path 20 | end 21 | end 22 | return result 23 | end 24 | private_darwin.list_assets = function(asset_struct, src) 25 | local values = private_darwin.list_assets_recursivly(asset_struct, src) 26 | local valid_values = {} 27 | for i = 1, #values do 28 | local current = values[i] 29 | if private_darwin.count_bars(current) == 0 then 30 | valid_values[#valid_values + 1] = current 31 | end 32 | end 33 | return valid_values 34 | end 35 | -------------------------------------------------------------------------------- /src/api/private_darwin/extra.lua: -------------------------------------------------------------------------------- 1 | private_darwin.is_inside = function(target_table, value) 2 | for i = 1, #target_table do 3 | if target_table[i] == value then 4 | return true 5 | end 6 | end 7 | return false 8 | end 9 | 10 | 11 | private_darwin.extract_dir = function(path) 12 | local i = string.len(path) 13 | while i > 0 do 14 | local current_char = string.sub(path, i, i) 15 | if current_char == '/' then 16 | return string.sub(path, 1, i) 17 | end 18 | i = i - 1 19 | end 20 | return "" 21 | end 22 | 23 | 24 | private_darwin.count_bars = function(str) 25 | local total = 0 26 | for i = 1, #str do 27 | if string.sub(str, i, i) == "/" then 28 | total = total + 1 29 | end 30 | end 31 | return total 32 | end 33 | -------------------------------------------------------------------------------- /src/api/private_darwin/native_funcs.lua: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/api/private_darwin/stream.lua: -------------------------------------------------------------------------------- 1 | private_darwin.transfer_byte_direct_stream = function(str, stream) 2 | local current_chunk_size = #str 3 | for i = 1, current_chunk_size do 4 | local current_char = string.sub(str, i, i) 5 | local byte = string.byte(current_char) 6 | stream(string.format("%d,", byte)) 7 | end 8 | end 9 | 10 | private_darwin.transfer_byte_internal_format = function(str, stream) 11 | local current_chunk_size = #str 12 | local data = {} 13 | for i = 1, current_chunk_size do 14 | local current_char = string.sub(str, i, i) 15 | local byte = string.byte(current_char) 16 | data[#data + 1] = string.format("%d,", byte) 17 | end 18 | stream(table.concat(data)) 19 | end 20 | 21 | private_darwin.transfer_byte_size_decide = function(str, stream) 22 | local limit = darwin.chunk_size 23 | if #str > limit then 24 | private_darwin.transfer_byte_direct_stream(str, stream) 25 | return 26 | end 27 | private_darwin.transfer_byte_internal_format(str, stream) 28 | end 29 | 30 | private_darwin.is_file_stream = function(item) 31 | if type(item) ~= "table" then 32 | return false 33 | end 34 | if item.type == "DarwinFileStream" then 35 | return true 36 | end 37 | return false 38 | end 39 | 40 | private_darwin.transfer_file_stream = function(filestream, stream) 41 | local file = io.open(filestream.filename, "a+b") 42 | if not file then 43 | error("impossible to open" .. filestream.filename) 44 | end 45 | 46 | while true do 47 | local chunk = file:read(math.floor(darwin.chunk_size)) 48 | if not chunk then break end 49 | stream(chunk) 50 | end 51 | end 52 | 53 | private_darwin.transfer_file_stream_bytes = function(filestream, stream) 54 | local file = io.open(filestream.filename, "a+b") 55 | if not file then 56 | error("impossible to open" .. filestream.filename) 57 | end 58 | 59 | 60 | local count = 0 61 | while true do 62 | local chunk = file:read(math.floor(darwin.chunk_size)) 63 | if chunk then 64 | count = count + #chunk 65 | --print("transfed: " .. count) 66 | end 67 | if not chunk then break end 68 | private_darwin.transfer_byte_internal_format(chunk, stream) 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /src/api/private_darwin/string_functions.lua: -------------------------------------------------------------------------------- 1 | private_darwin.is_string_at_point = function(str, target, point) 2 | local possible = string.sub(str, point, point + #target - 1) 3 | if possible == target then 4 | return true 5 | end 6 | return false 7 | end 8 | private_darwin.is_one_of_string_at_point = function(str, targets, point) 9 | for i = 1, #targets do 10 | local target = targets[i] 11 | if private_darwin.is_string_at_point(str, target, point) then 12 | return true 13 | end 14 | end 15 | return false 16 | end 17 | private_darwin.starts_with = function(str, target) 18 | return private_darwin.is_string_at_point(str, target, 1) 19 | end 20 | private_darwin.ends_with = function(str, target) 21 | return private_darwin.is_string_at_point(str, target, #str - #target + 1) 22 | end 23 | private_darwin.replace_str = function(str, target, replacement) 24 | local result = "" 25 | local i = 1 26 | while i <= #str do 27 | local current_char = string.sub(str, i, i) 28 | if private_darwin.is_string_at_point(str, target, i) then 29 | result = result .. replacement 30 | i = i + #target 31 | else 32 | result = result .. current_char 33 | i = i + 1 34 | end 35 | end 36 | return result 37 | end -------------------------------------------------------------------------------- /src/api/private_darwin_project/constructors/c.lua: -------------------------------------------------------------------------------- 1 | private_darwin_project.add_c_methods = function(selfobj) 2 | selfobj.add_c_external_code = function(code) 3 | private_darwin_project.add_c_external_code(selfobj, code) 4 | end 5 | 6 | selfobj.add_c_include = function(include_code) 7 | private_darwin_project.add_c_include(selfobj, include_code) 8 | end 9 | 10 | selfobj.add_c_file = function(filename, follow_includes, verifier_callback) 11 | private_darwin_project.add_c_file(selfobj, filename, follow_includes, verifier_callback) 12 | end 13 | 14 | selfobj.add_c_call = function(func_name) 15 | private_darwin_project.add_c_call(selfobj, func_name) 16 | end 17 | 18 | selfobj.load_lib_from_c = function(lib_start_func, lua_obj) 19 | private_darwin_project.load_lib_from_c(selfobj, lib_start_func, lua_obj) 20 | end 21 | 22 | selfobj.generate_c_complex = function(props) 23 | return private_darwin_project.generate_c_complex(selfobj, props) 24 | end 25 | selfobj.generate_c_code = function(props) 26 | return private_darwin_project.generate_c_code(selfobj, props) 27 | end 28 | 29 | selfobj.generate_c_file = function(props) 30 | return private_darwin_project.generate_c_file(selfobj, props) 31 | end 32 | selfobj.generate_c_lib_complex = function(props) 33 | return private_darwin_project.generate_c_lib_complex(selfobj, props) 34 | end 35 | 36 | selfobj.generate_c_lib_code = function(props) 37 | return private_darwin_project.generate_c_lib_code(selfobj, props) 38 | end 39 | 40 | selfobj.generate_c_lib_file = function(props) 41 | return private_darwin_project.generate_c_lib_file(selfobj, props) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /src/api/private_darwin_project/constructors/lua.lua: -------------------------------------------------------------------------------- 1 | private_darwin_project.add_lua_methods = function(selfobj) 2 | selfobj.add_lua_code = function(code) 3 | private_darwin_project.add_lua_code(selfobj, code) 4 | end 5 | selfobj.add_lua_file = function(src) 6 | private_darwin_project.add_lua_file(selfobj, src) 7 | end 8 | 9 | selfobj.add_lua_file_following_require = function(src,relative_path) 10 | private_darwin_project.add_lua_file_following_require(selfobj, src,relative_path) 11 | end 12 | 13 | selfobj.generate_lua_complex = function(props) 14 | private_darwin_project.generate_lua_complex(selfobj, props) 15 | end 16 | 17 | selfobj.generate_lua_code = function(props) 18 | return private_darwin_project.generate_lua_code(selfobj, props) 19 | end 20 | selfobj.generate_lua_file = function(props) 21 | private_darwin_project.generate_lua_file(selfobj, props) 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /src/api/private_darwin_project/constructors/props.lua: -------------------------------------------------------------------------------- 1 | private_darwin_project.construct_globals = function(self_obj) 2 | self_obj.lua_code = {} 3 | self_obj.c_external_code = {} 4 | self_obj.c_main_code = {} 5 | self_obj.embed_data = {} 6 | -- self_obj.embed_lua_requires = {} 7 | self_obj.required_funcs = {} 8 | self_obj.so_includeds = {} 9 | end 10 | -------------------------------------------------------------------------------- /src/api/private_darwin_project/methods/c/c_data.lua: -------------------------------------------------------------------------------- 1 | private_darwin_project.add_c_external_code = function(selfob, code) 2 | selfob.c_external_code[#selfob.c_external_code + 1] = code 3 | end 4 | 5 | private_darwin_project.add_c_include = function(selfobj, file) 6 | local include_code = string.format('#include "%s"\n', file) 7 | private_darwin_project.add_c_external_code(selfobj, include_code) 8 | end 9 | 10 | private_darwin_project.add_c_file = function(selfobj, filename, follow_includes, verifier_callback) 11 | if not follow_includes then 12 | selfobj.c_external_code[#selfobj.c_external_code + 1] = darwin.file_stream(filename) 13 | return 14 | end 15 | local MAX_CONTENT = darwin.camalgamator.ONE_MB * 100000 16 | local MAX_RECURSION = 1000 17 | if not verifier_callback then 18 | local result = darwin.camalgamator.generate_amalgamation(filename, MAX_CONTENT, MAX_RECURSION) 19 | selfobj.c_external_code[#selfobj.c_external_code + 1] = result 20 | return 21 | end 22 | 23 | local callback = function(import, path) 24 | local internal_result = verifier_callback(import, path) 25 | if internal_result then 26 | return "include-once" 27 | end 28 | return "dont-include" 29 | end 30 | 31 | local result = darwin.camalgamator.generate_amalgamation_with_callback( 32 | filename, 33 | callback, 34 | MAX_CONTENT, MAX_RECURSION 35 | ) 36 | selfobj.c_external_code[#selfobj.c_external_code + 1] = result 37 | end 38 | 39 | private_darwin_project.add_c_call = function(selfob, func_name) 40 | local c_call = string.format("%s(darwin_main_obj);", func_name) 41 | selfob.c_main_code[#selfob.c_main_code + 1] = c_call 42 | end 43 | 44 | 45 | private_darwin_project.load_lib_from_c = function(selfobj, lib_start_func, lua_obj) 46 | local c_call = string.format( 47 | "LuaCEmbed_load_lib_from_c(darwin_main_obj,%s,%q);", 48 | lib_start_func, 49 | lua_obj 50 | ) 51 | selfobj.c_main_code[#selfobj.c_main_code + 1] = c_call 52 | end 53 | -------------------------------------------------------------------------------- /src/api/private_darwin_project/methods/c/c_embed.lua: -------------------------------------------------------------------------------- 1 | private_darwin_project.create_c_str_buffer = function(str_code, streamed_shas, stream) 2 | local name = string.format("private_darwin_sha%s", darwin.dtw.generate_sha(str_code)) 3 | if private_darwin.is_inside(streamed_shas, name) then 4 | return name 5 | end 6 | streamed_shas[#streamed_shas + 1] = name 7 | stream(string.format( 8 | "unsigned char %s[] ={", 9 | name 10 | )) 11 | private_darwin.transfer_byte_size_decide(str_code, stream) 12 | stream("0};\n") 13 | return name 14 | end 15 | 16 | 17 | private_darwin_project.create_c_stream_buffer = function(filestream, streamed_shas, stream) 18 | local name = string.format("private_darwin_sha%s",darwin.dtw.generate_sha_from_file(filestream.filename)) 19 | if private_darwin.is_inside(streamed_shas, name) then 20 | return name 21 | end 22 | streamed_shas[#streamed_shas + 1] = name 23 | stream(string.format( 24 | "unsigned char %s[] ={", 25 | name 26 | )) 27 | private_darwin.transfer_file_stream_bytes(filestream, stream) 28 | stream("0};\n") 29 | return name 30 | end 31 | 32 | 33 | private_darwin_project.embed_c_table = function(current_table, increment, streamed_shas, stream) 34 | local table_name = "private_darwin_table" .. increment() 35 | stream(string.format("LuaCEmbedTable *%s = LuaCembed_new_anonymous_table(darwin_main_obj);\n", table_name)) 36 | for key, val in pairs(current_table) do 37 | local key_type = type(key) 38 | local valtype = type(val) 39 | 40 | if not private_darwin.is_inside({ "string", "number" }, key_type) then 41 | error("invalid key on ") 42 | end 43 | if not private_darwin.is_inside({ "string", "number", "table", "boolean" }, key_type) then 44 | error("invalid val on ") 45 | end 46 | 47 | if valtype == "function" then 48 | error("function cannot be embed") 49 | end 50 | local is_stream = private_darwin.is_file_stream(val) 51 | 52 | if key_type == "number" and valtype == "number" then 53 | stream(string.format( 54 | "LuaCEmbedTable_set_double_by_index(%s,%d,%f);\n", 55 | table_name, 56 | key - 1, 57 | val 58 | )) 59 | end 60 | 61 | if key_type == "number" and valtype == "string" then 62 | local sha_name = private_darwin_project.create_c_str_buffer(val, streamed_shas, stream) 63 | stream(string.format( 64 | "LuaCEmbedTable_set_raw_string_by_index(%s,%d,%s,%d);\n", 65 | table_name, 66 | key - 1, 67 | sha_name, 68 | string.len(val) 69 | )) 70 | end 71 | 72 | if key_type == "number" and val == true then 73 | stream(string.format( 74 | "LuaCEmbedTable_set_bool_by_index(%s,%d,true);\n", 75 | table_name, 76 | key - 1 77 | )) 78 | end 79 | if key_type == "number" and val == false then 80 | stream(string.format( 81 | "LuaCEmbedTable_set_bool_by_index(%s,%d,false);\n", 82 | table_name, 83 | key - 1 84 | )) 85 | end 86 | if key_type == "number" and is_stream then 87 | local sha_name = private_darwin_project.create_c_stream_buffer(val, streamed_shas, stream) 88 | local size = io.open(val.filename, "rb"):seek("end") 89 | stream(string.format( 90 | "LuaCEmbedTable_set_raw_string_by_index(%s,%d,%s,%d);\n", 91 | table_name, 92 | key - 1, 93 | sha_name, 94 | size 95 | )) 96 | end 97 | 98 | if key_type == "number" and valtype == "table" and not is_stream then 99 | local created_name = private_darwin_project.embed_c_table(val, increment, streamed_shas, stream) 100 | stream(string.format( 101 | "LuaCEmbedTable_set_sub_table_by_index(%s,%d,%s);\n", 102 | table_name, 103 | key - 1, 104 | created_name 105 | )) 106 | end 107 | 108 | if key_type == "string" and valtype == "number" then 109 | stream(string.format( 110 | "LuaCEmbedTable_set_double_prop(%s,%q,%f);\n", 111 | table_name, 112 | key, 113 | val 114 | )) 115 | end 116 | 117 | 118 | if key_type == "string" and valtype == "string" then 119 | local sha_name = private_darwin_project.create_c_str_buffer(val, streamed_shas, stream) 120 | stream(string.format( 121 | "LuaCEmbedTable_set_raw_string_prop(%s,%q,(const char*)%s,%d);\n", 122 | table_name, 123 | key, 124 | sha_name, 125 | string.len(val) 126 | )) 127 | end 128 | if key_type == "string" and val == true then 129 | stream(string.format( 130 | "LuaCEmbedTable_set_bool_prop(%s,%q,true);\n", 131 | table_name, 132 | key 133 | )) 134 | end 135 | if key_type == "string" and val == false then 136 | stream(string.format( 137 | "LuaCEmbedTable_set_bool_prop(%s,%q,false);\n", 138 | table_name, 139 | key 140 | )) 141 | end 142 | 143 | if key_type == "string" and is_stream then 144 | local sha_name = private_darwin_project.create_c_stream_buffer(val, streamed_shas, stream) 145 | local size = io.open(val.filename, "rb"):seek("end") 146 | stream(string.format( 147 | "LuaCEmbedTable_set_raw_string_prop(%s,%q,(const char*)%s,%d);\n", 148 | table_name, 149 | key, 150 | sha_name, 151 | size 152 | )) 153 | end 154 | if key_type == "string" and valtype == "table" and not is_stream then 155 | local created_name = private_darwin_project.embed_c_table(val, increment, streamed_shas, stream) 156 | stream(string.format( 157 | "LuaCEmbedTable_set_sub_table_prop(%s,%q,%s);\n", 158 | table_name, 159 | key, 160 | created_name 161 | )) 162 | end 163 | end 164 | return table_name 165 | end 166 | 167 | 168 | private_darwin_project.embed_global_in_c = function(name, var, streamed_shas, stream, increment) 169 | local var_type = type(var) 170 | if var_type == "number" then 171 | stream( 172 | string.format('LuaCEmbed_set_global_double(darwin_main_obj,"%s",%f);\n', name, var) 173 | ) 174 | end 175 | if var_type == "function" then 176 | error("function cannot be embed") 177 | end 178 | 179 | if var_type == "boolean" then 180 | if var == true then 181 | stream( 182 | string.format('LuaCEmbed_set_global_bool(darwin_main_obj,"%s",true);\n', name) 183 | ) 184 | end 185 | if var == false then 186 | stream( 187 | string.format('LuaCEmbed_set_global_bool(darwin_main_obj,"%s",false);\n', name) 188 | ) 189 | end 190 | end 191 | if var_type == "string" then 192 | local sha_name = private_darwin_project.create_c_str_buffer(var, streamed_shas, stream) 193 | stream(string.format('LuaCEmbed_set_global_raw_string(darwin_main_obj,%q,(const char*)%s,%d);\n', name, sha_name, 194 | string.len(var))) 195 | end 196 | 197 | local is_stream = private_darwin.is_file_stream(var) 198 | if is_stream then 199 | local sha_name = private_darwin_project.create_c_stream_buffer(var, streamed_shas, stream) 200 | local size = io.open(var.filename, "rb"):seek("end") 201 | stream( 202 | string.format( 203 | 'LuaCEmbed_set_global_raw_string(darwin_main_obj,%q,(const char*)%s,%d);\n', 204 | name, 205 | sha_name, 206 | size 207 | ) 208 | ) 209 | end 210 | 211 | if var_type == "table" and not is_stream then 212 | local table_name = private_darwin_project.embed_c_table(var, increment, streamed_shas, stream) 213 | stream(string.format('LuaCEmbed_set_global_table(darwin_main_obj,%q,%s);\n', name, table_name)) 214 | end 215 | end 216 | -------------------------------------------------------------------------------- /src/api/private_darwin_project/methods/c/executable_generators.lua: -------------------------------------------------------------------------------- 1 | private_darwin_project.generate_c_complex = function(selfobj, props) 2 | local include_lua_cembed = true 3 | if props.include_lua_cembed ~= nil then 4 | include_lua_cembed = props.include_lua_cembed 5 | end 6 | 7 | for i = 1, #selfobj.c_external_code do 8 | props.stream("\n") 9 | local current = selfobj.c_external_code[i] 10 | if private_darwin.is_file_stream(current) then 11 | private_darwin.transfer_file_stream(current, props.stream) 12 | else 13 | props.stream(current) 14 | end 15 | end 16 | 17 | 18 | 19 | if include_lua_cembed then 20 | local lua_cembedd = private_darwin.get_asset(PRIVATE_DARWIN_API_ASSETS, "LuaCEmbedOne.c") 21 | props.stream("#define error LuaCEmbed_error\n") 22 | props.stream(lua_cembedd) 23 | props.stream("#undef error\n") 24 | end 25 | 26 | 27 | props.stream([[ 28 | int main(int argc, char **argv) { 29 | LuaCEmbed *darwin_main_obj = newLuaCEmbedEvaluation(); 30 | 31 | #ifdef _WIN32 32 | LuaCEmbed_set_global_string(darwin_main_obj, "darwin_os", "windows"); 33 | #endif 34 | 35 | #ifdef __unix__ 36 | LuaCEmbed_set_global_string(darwin_main_obj, "darwin_os", "unix"); 37 | #endif 38 | 39 | LuaCEmbedTable *args_table =LuaCembed_new_global_table(darwin_main_obj,"arg"); 40 | 41 | for(int i =0; i last_string_start_point and not is_a_scape then 138 | local is_small_string_end = private_darwin.is_string_at_point(content, "'", i) 139 | 140 | if is_small_string_end then 141 | inside_string = false 142 | last_string_end_point = i 143 | end 144 | end 145 | 146 | if inside_string and string_starter_char == '"' and i > last_string_start_point and not is_a_scape then 147 | local is_medium_string_end = private_darwin.is_string_at_point(content, '"', i) 148 | 149 | if is_medium_string_end then 150 | inside_string = false 151 | last_string_end_point = i 152 | end 153 | end 154 | 155 | if inside_string and string_starter_char == "[[" and i > last_string_start_point and not is_a_scape then 156 | local is_big_string_end = private_darwin.is_string_at_point(content, "]]", i) 157 | 158 | if is_big_string_end then 159 | inside_string = false 160 | last_string_end_point = i + 1 161 | end 162 | end 163 | 164 | if inside_string then 165 | local current_char = string.sub(content, i, i) 166 | if current_char == "\\" then 167 | acumulative_scape = acumulative_scape + 1 168 | else 169 | acumulative_scape = 0 170 | end 171 | is_a_scape = acumulative_scape % 2 == 1 172 | end 173 | if not inside_string and not inside_comment then 174 | local is_require_start = private_darwin.is_one_of_string_at_point(content, { "require ", "require(" }, i) 175 | 176 | if is_require_start then 177 | waiting_required_string = true 178 | required_call_point = i 179 | i = i + #"require" 180 | end 181 | 182 | local is_package_start = private_darwin.is_one_of_string_at_point(content, 183 | { "package.loadlib ", "package.loadlib(" }, i) 184 | 185 | if is_package_start then 186 | waiting_package_string = true 187 | package_call_point = i 188 | i = i + #"package.loadlib" 189 | end 190 | end 191 | 192 | if (waiting_package_string or waiting_required_string) and not inside_string then 193 | local current_char = string.sub(content, i, i) 194 | --print(string.sub(content, i-5, i).."("..current_char..")"..string.sub(content, i, i+5)) 195 | local valid_chars = { "(", ")", " ", '"', "'", "[", "]", "," } 196 | if not private_darwin.is_inside(valid_chars, current_char) then 197 | error("invalid package call at:(" .. src .. ") only raw string is allowed ") 198 | end 199 | end 200 | 201 | -- means it found a required call 202 | if waiting_required_string and not inside_string and last_string_start_point > required_call_point then 203 | local require_string = string.sub(content, last_string_start_point, last_string_end_point) 204 | local identifier_size = string.len(string_starter_char) 205 | 206 | require_string = string.sub(require_string, identifier_size + 1, string.len(require_string) - identifier_size) 207 | point = private_darwin_project.create_include_stream(selfobj, require_string, relative_path) 208 | waiting_required_string = false 209 | if point then 210 | private_darwin_project.add_lua_file_following_require_recursively(selfobj, point, relative_path) 211 | end 212 | end 213 | if waiting_package_string and not inside_string and last_string_start_point > package_call_point then 214 | local package_string = string.sub(content, last_string_start_point, last_string_end_point) 215 | local identifier_size = string.len(string_starter_char) 216 | package_string = string.sub(package_string, identifier_size + 1, string.len(package_string) - identifier_size) 217 | 218 | if relative_path then 219 | package_string_path = relative_path .. "/" .. package_string 220 | end 221 | 222 | if not private_darwin_project.is_so_includeds(selfobj, package_string) then 223 | selfobj.so_includeds[#selfobj.so_includeds + 1] = { 224 | comptime_included = package_string, 225 | content = darwin.file_stream(package_string_path) 226 | } 227 | end 228 | 229 | waiting_package_string = false 230 | end 231 | 232 | i = i + 1 233 | end 234 | end 235 | 236 | private_darwin_project.add_lua_file_following_require = function(selfobj, src, relative_path) 237 | if relative_path == nil then 238 | relative_path = "." 239 | end 240 | private_darwin_project.add_lua_file(selfobj, src) 241 | private_darwin_project.add_lua_file_following_require_recursively(selfobj, src, relative_path) 242 | end 243 | -------------------------------------------------------------------------------- /src/api/private_darwin_project/methods/lua/generators.lua: -------------------------------------------------------------------------------- 1 | private_darwin_project.generate_lua_complex = function(selfobj, props) 2 | local embed_data = props.include_embed_data 3 | if embed_data == nil then 4 | embed_data = true 5 | end 6 | if #selfobj.embed_data == 0 then 7 | embed_data = false 8 | end 9 | local so_dest = props.so_dest 10 | if not props.so_dest then 11 | so_dest = "/tmp/"..selfobj.project_name.."_so" 12 | end 13 | -----------------------------Embedding global variables 14 | if embed_data then 15 | local parse_to_bytes = private_darwin.get_asset(PRIVATE_DARWIN_API_ASSETS, "parse_to_bytes.lua") 16 | props.stream(parse_to_bytes) 17 | local streamed_shas = {} 18 | for i = 1, #selfobj.embed_data do 19 | local current = selfobj.embed_data[i] 20 | private_darwin_project.embed_global_in_lua(current.name, current.value, streamed_shas, props.stream) 21 | end 22 | end 23 | 24 | local required_func_name = "PRIVATE_DARWIN_"..selfobj.project_name.."_REQUIRED_FUNCS" 25 | local so_includeds_name = "PRIVATE_DARWIN_"..selfobj.project_name.."_SO_INCLUDED" 26 | 27 | 28 | -----------------------------Embedding so files 29 | if #selfobj.so_includeds > 0 then 30 | local so_actions = private_darwin.get_asset(PRIVATE_DARWIN_API_ASSETS, "so_actions.lua") 31 | local so_actions_format = private_darwin.replace_str(so_actions, "SO_INCLUDE", so_includeds_name) 32 | so_actions_format = private_darwin.replace_str(so_actions_format, "PRIVATE_DARWIN_SO_DEST","'"..so_dest.."'") 33 | props.stream(so_actions_format) 34 | 35 | local load_lib_overload = private_darwin.get_asset(PRIVATE_DARWIN_API_ASSETS, "load_lib_overload.lua") 36 | local load_lib_overload_format = private_darwin.replace_str(load_lib_overload, "REQUIRE_SO", so_includeds_name) 37 | load_lib_overload_format = private_darwin.replace_str(load_lib_overload_format, "PRIVATE_DARWIN_SO_DEST", "'"..so_dest.."'") 38 | props.stream(load_lib_overload_format) 39 | end 40 | 41 | -----------------------------Embedding required functions 42 | if #selfobj.required_funcs > 0 then 43 | props.stream(required_func_name.." = {}\n") 44 | for i=1,#selfobj.required_funcs do 45 | local current = selfobj.required_funcs[i] 46 | props.stream(required_func_name.."[" .. i .. "] = {\n") 47 | props.stream("comptime_include ='".. current.comptime_included .. "',\n") 48 | props.stream("loaded_obj = nil,\n") 49 | props.stream("content = function()\n") 50 | private_darwin.transfer_file_stream(current.content, props.stream) 51 | props.stream("end\n") 52 | 53 | props.stream("\n}\n") 54 | end 55 | 56 | 57 | local require_code = private_darwin.get_asset(PRIVATE_DARWIN_API_ASSETS, "require_overload.lua") 58 | local require_code_format = private_darwin.replace_str(require_code, "REQUIRE_FUNCS", required_func_name) 59 | require_code_format = private_darwin.replace_str(require_code_format, "REQUIRE_SO", so_includeds_name) 60 | require_code_format = private_darwin.replace_str(require_code_format, "PRIVATE_DARWIN_SO_DEST", "'"..so_dest.."'") 61 | props.stream(require_code_format) 62 | 63 | end 64 | 65 | -----------------------------Embedding lua code 66 | for i = 1, #selfobj.lua_code do 67 | props.stream("\n") 68 | local current = selfobj.lua_code[i] 69 | if private_darwin.is_file_stream(current) then 70 | private_darwin.transfer_file_stream(current, props.stream) 71 | else 72 | props.stream(selfobj.lua_code[i]) 73 | end 74 | end 75 | 76 | if #selfobj.required_funcs > 0 then 77 | local resset_require = private_darwin.get_asset(PRIVATE_DARWIN_API_ASSETS, "resset_require.lua") 78 | props.stream(resset_require) 79 | props.stream("\n") 80 | end 81 | if #selfobj.so_includeds > 0 then 82 | local resset_so = private_darwin.get_asset(PRIVATE_DARWIN_API_ASSETS, "resset_so.lua") 83 | props.stream(resset_so) 84 | props.stream("\n") 85 | end 86 | end 87 | 88 | private_darwin_project.generate_lua_code = function(selfobj, props) 89 | local content = {} 90 | local function stream(data) 91 | content[#content + 1] = data 92 | end 93 | private_darwin_project.generate_lua_complex(selfobj, { 94 | stream = stream, 95 | include_embed_data = props.include_embed_data 96 | }) 97 | return table.concat(content, "") 98 | end 99 | 100 | private_darwin_project.generate_lua_file = function(selfobj, props) 101 | darwin.dtw.write_file(props.output, "") 102 | local file = io.open(props.output, "a+b") 103 | 104 | local function stream(data) 105 | if not file then 106 | file = io.open(props.output, "a+b") 107 | end 108 | if not file then 109 | error("impossible to generate output in" .. props.output) 110 | end 111 | file:write(data) 112 | end 113 | 114 | private_darwin_project.generate_lua_complex(selfobj, { 115 | stream = stream, 116 | include_embed_data = props.include_embed_data 117 | }) 118 | if file then 119 | file:close() 120 | end 121 | end 122 | -------------------------------------------------------------------------------- /src/api/private_darwin_project/methods/lua/lua_embed.lua: -------------------------------------------------------------------------------- 1 | private_darwin_project.create_lua_str_buffer = function(str_code, streamed_shas, stream) 2 | local name = string.format("private_darwin_sha%s", darwin.dtw.generate_sha(str_code)) 3 | if private_darwin.is_inside(streamed_shas, name) then 4 | return name 5 | end 6 | streamed_shas[#streamed_shas + 1] = name 7 | stream(string.format( 8 | "%s = table.concat(PrivateDarwing_parse_to_bytes({", 9 | name 10 | )) 11 | private_darwin.transfer_byte_size_decide(str_code, stream) 12 | 13 | stream("}))\n") 14 | return name 15 | end 16 | 17 | 18 | private_darwin_project.create_lua_stream_buffer = function(filestream, streamed_shas, stream) 19 | local name = string.format("private_darwin_sha%s", darwin.dtw.generate_sha_from_file(filestream.filename)) 20 | if private_darwin.is_inside(streamed_shas, name) then 21 | return name 22 | end 23 | 24 | streamed_shas[#streamed_shas + 1] = name 25 | stream(string.format( 26 | "%s = table.concat(PrivateDarwing_parse_to_bytes({", 27 | name 28 | )) 29 | private_darwin.transfer_file_stream_bytes(filestream, stream) 30 | stream("}))\n") 31 | return name 32 | end 33 | 34 | 35 | 36 | private_darwin_project.embed_table_in_lua = function(table_name, current_table, streamed_shas, stream) 37 | stream( 38 | string.format('%s = {}\n', table_name) 39 | ) 40 | 41 | for key, val in pairs(current_table) do 42 | local key_type = type(key) 43 | local val_type = type(val) 44 | 45 | if not private_darwin.is_inside({ "string", "number" }, key_type) then 46 | error("invalid key on " .. table_name) 47 | end 48 | 49 | if not private_darwin.is_inside({ "string", "number", "table", "boolean" }, val_type) then 50 | error("invalid val on " .. table_name) 51 | end 52 | 53 | -- Format the key appropriately 54 | local formatted_key 55 | if key_type == "number" then 56 | formatted_key = string.format("[%d]", key) 57 | else 58 | formatted_key = string.format("[%q]", key) 59 | end 60 | 61 | -- Handle different value types 62 | if val_type == "number" then 63 | stream( 64 | string.format('%s%s = %f\n', table_name, formatted_key, val) 65 | ) 66 | end 67 | if val_type == "boolean" then 68 | stream( 69 | string.format('%s%s = %s\n', table_name, formatted_key, tostring(val)) 70 | ) 71 | end 72 | 73 | if val_type == "string" then 74 | local sha_name = private_darwin_project.create_lua_str_buffer(val, streamed_shas, stream) 75 | stream( 76 | string.format('%s%s = %s;\n', table_name, formatted_key, sha_name) 77 | ) 78 | end 79 | local is_stream = private_darwin.is_file_stream(val) 80 | if is_stream then 81 | local sha_name = private_darwin_project.create_lua_stream_buffer(val, streamed_shas, stream) 82 | stream( 83 | string.format('%s%s = %s;\n', table_name, formatted_key, sha_name) 84 | ) 85 | end 86 | 87 | if val_type == "table" and not is_stream then 88 | private_darwin_project.embed_table_in_lua( 89 | table_name .. formatted_key, 90 | val, 91 | streamed_shas, 92 | stream 93 | ) 94 | end 95 | end 96 | end 97 | 98 | 99 | private_darwin_project.embed_global_in_lua = function(name, var, streamed_shas, stream) 100 | local var_type = type(var) 101 | 102 | if not private_darwin.is_inside({ "string", "number", "table", "boolean" }, var_type) then 103 | error("var " .. name .. "cannot be embed") 104 | end 105 | 106 | if var_type == "number" then 107 | stream( 108 | string.format('%s = %f;\n', name, var) 109 | ) 110 | end 111 | if var_type == "boolean" then 112 | stream( 113 | string.format('%s = %s;\n', name, tostring(var)) 114 | ) 115 | end 116 | 117 | if var_type == "string" then 118 | local sha_name = private_darwin_project.create_lua_str_buffer(var, streamed_shas, stream) 119 | stream( 120 | string.format('%s = %s;\n', name, sha_name) 121 | ) 122 | end 123 | 124 | local is_stream = private_darwin.is_file_stream(var) 125 | if is_stream then 126 | local sha_name = private_darwin_project.create_lua_stream_buffer(var, streamed_shas, stream) 127 | stream( 128 | string.format('%s = %s;\n', name, sha_name) 129 | ) 130 | end 131 | if var_type == 'table' and not is_stream then 132 | private_darwin_project.embed_table_in_lua(name, var, streamed_shas, stream) 133 | end 134 | end 135 | -------------------------------------------------------------------------------- /src/cli/blueprint_mode.lua: -------------------------------------------------------------------------------- 1 | ---@param blueprint string[] 2 | ---@param used_flags string[] 3 | function Perform_blue_print() 4 | 5 | 6 | local blue_print_mode = darwin.argv.get_flag_arg_by_index_consider_only_first("mode",1, "file") 7 | if not private_darwin.is_inside({ "file", "folder" }, blue_print_mode) then 8 | private_darwin.print_red("blue print mode must be file or folder\n") 9 | return 10 | end 11 | 12 | local file_or_folder = darwin.argv.get_next_unused() 13 | if not file_or_folder then 14 | file_or_folder = "darwinconf.lua" 15 | end 16 | 17 | 18 | 19 | 20 | if blue_print_mode == "folder" then 21 | if not darwin.dtw.isdir(file_or_folder) then 22 | private_darwin.print_red(file_or_folder .. "its not a folder\n") 23 | return 24 | end 25 | 26 | 27 | local all_paths = darwin.dtw.list_files_recursively(file_or_folder, true) 28 | for i = 1, #all_paths do 29 | dofile(all_paths[i]) 30 | end 31 | 32 | if not main then 33 | private_darwin.print_red("main function not provided\n") 34 | return 35 | end 36 | main() 37 | end 38 | 39 | if blue_print_mode == "file" then 40 | if not darwin.dtw.isfile(file_or_folder) then 41 | private_darwin.print_red("blue print:"..file_or_folder.." its not a file") 42 | return 43 | end 44 | dofile(file_or_folder) 45 | end 46 | return 47 | end 48 | -------------------------------------------------------------------------------- /src/cli/colors.lua: -------------------------------------------------------------------------------- 1 | ---typestart 2 | ---@class PrivateDarwin 3 | ---@field print_color fun(color:string,text:string) 4 | ---@field print_red fun(text:string) 5 | ---@field print_green fun(text:string) 6 | ---@field print_blue fun(text:string) 7 | 8 | ---typeend 9 | 10 | private_darwin.print_color = function(color, text) 11 | local RESSET = "\x1b[0m" 12 | io.write(color .. text .. RESSET) 13 | end 14 | private_darwin.print_green = function(text) 15 | private_darwin.print_color("\x1b[32m", text) 16 | end 17 | 18 | private_darwin.print_blue = function(text) 19 | private_darwin.print_color("\x1b[34m", text) 20 | end 21 | private_darwin.print_red = function(text) 22 | private_darwin.print_color("\x1b[31m", text) 23 | end 24 | -------------------------------------------------------------------------------- /src/cli/default_execution.lua: -------------------------------------------------------------------------------- 1 | 2 | local valid_out_modes = { 3 | lua= {"lua"}, 4 | executable_source= {"c"}, 5 | lib_source={}, 6 | linux_bin={"o", "out"}, 7 | windows_bin={"exe"}, 8 | linux_so={"so"}, 9 | windows_dll={"dll"} 10 | } 11 | 12 | local function get_default_output_mode(output) 13 | local extension = darwin.dtw.newPath(output).get_extension() 14 | for key,val in pairs(valid_out_modes) do 15 | 16 | for i=1,#val do 17 | if val[i] == extension then 18 | return key 19 | end 20 | end 21 | end 22 | return nil 23 | 24 | end 25 | 26 | function output_mode_its_valid(output_mode) 27 | if not output_mode then 28 | return false 29 | end 30 | for key,_ in pairs(valid_out_modes) do 31 | if key == output_mode then 32 | return true 33 | end 34 | end 35 | return false 36 | end 37 | 38 | function Default_execution() 39 | 40 | local output = darwin.argv.get_flag_arg_by_index_consider_only_first({"o", "output"},1) 41 | 42 | if not output then 43 | private_darwin.print_red("output not found") 44 | return 45 | end 46 | local output_mode = darwin.argv.get_flag_arg_by_index_consider_only_first( 47 | {"mode", "output_mode"}, 48 | 1, 49 | get_default_output_mode(output) 50 | ) 51 | 52 | 53 | if not output_mode_its_valid(output_mode) then 54 | private_darwin.print_red("output mode not valid") 55 | return 56 | end 57 | 58 | local default_name = darwin.dtw.newPath(output).get_only_name() 59 | local project_name = darwin.argv.get_flag_arg_by_index_consider_only_first({"name"}, 1,default_name) 60 | 61 | local project = darwin.create_project(project_name) 62 | 63 | local ok =get_embed_vars(project) 64 | if not ok then 65 | return 66 | end 67 | local cinclude_size = darwin.argv.get_flag_size_consider_only_first({"c_include"}, 1) 68 | 69 | for i=1,cinclude_size do 70 | local cinclude = darwin.argv.get_flag_arg_by_index_consider_only_first( "c_include", i) 71 | project.add_c_include(cinclude) 72 | end 73 | 74 | local c_call_size = darwin.argv.get_flag_size_consider_only_first({"c_call"}, 1) 75 | for i=1,c_call_size do 76 | local c_call = darwin.argv.get_flag_arg_by_index_consider_only_first({"c_call"}, i) 77 | project.add_c_call(c_call) 78 | end 79 | 80 | local c_amalgamate_size = darwin.argv.get_flag_size_consider_only_first({"amalgamation"}, 1) 81 | for i=1,c_amalgamate_size do 82 | local c_amalgamate = darwin.argv.get_flag_arg_by_index_consider_only_first({"amalgamation"}, i) 83 | project.add_c_file(c_amalgamate, true) 84 | end 85 | 86 | local lib_objects_size = darwin.argv.get_flag_size_consider_only_first({"lib_objects"}, 1) 87 | for i=1,lib_objects_size do 88 | local lib_object = darwin.argv.get_flag_arg_by_index_consider_only_first({"lib_objects"}, i) 89 | local func_name_flag = lib_object..":func" 90 | local func_name = darwin.argv.get_flag_arg_by_index_consider_only_first({func_name_flag}, 1) 91 | project.load_lib_from_c(func_name, lib_object) 92 | end 93 | 94 | 95 | if output_mode == "lua" then 96 | create_lua_project(project,output, output_mode) 97 | return 98 | end 99 | if output_mode == "linux_bin" or output_mode == "windows_bin" then 100 | create_executable_bin_project( project,output, output_mode) 101 | return 102 | end 103 | if output_mode == "executable_source" then 104 | create_executable_c_project(project,output, output_mode) 105 | return 106 | end 107 | if output_mode == "lib_source" then 108 | create_lib_source_project(project,output, output_mode) 109 | return 110 | end 111 | if output_mode == "linux_so" or output_mode == "windows_dll" then 112 | create_dynamic_link_lib_project( project,output, output_mode) 113 | return 114 | end 115 | 116 | 117 | 118 | 119 | end 120 | -------------------------------------------------------------------------------- /src/cli/drop.lua: -------------------------------------------------------------------------------- 1 | function Drop_types() 2 | local file = darwin.argv.get_next_unused() 3 | 4 | 5 | if not handle_unused() then 6 | return 7 | end 8 | 9 | 10 | if not file then 11 | file = "darwintypes.lua" 12 | end 13 | 14 | darwin.dtw.write_file(file, PRIVATE_DARWIN_TYPES) 15 | end 16 | 17 | function Drop_lua_cembed() 18 | local file = darwin.argv.get_next_unused() 19 | 20 | if not handle_unused() then 21 | return 22 | end 23 | 24 | if not file then 25 | file = "LuaCEmbed.c" 26 | end 27 | local lua_cembedd = private_darwin.get_asset(PRIVATE_DARWIN_API_ASSETS, "LuaCEmbedOne.c") 28 | darwin.dtw.write_file(file, lua_cembedd) 29 | end 30 | 31 | function Drop_help() 32 | local help = private_darwin.get_asset(PRIVATE_DARWIN_CLI_ASSETS, "help.txt") 33 | help = string.gsub(help, "DARWIN_VERSION", darwin.version) 34 | print(help) 35 | end 36 | -------------------------------------------------------------------------------- /src/cli/embed_data.lua: -------------------------------------------------------------------------------- 1 | 2 | ---@param project DarwinProject 3 | function get_embed_vars(project) 4 | 5 | local embed_vars_size = darwin.argv.get_flag_size_consider_only_first("embed_vars") 6 | for i=1,embed_vars_size do 7 | local embed_var = darwin.argv.get_flag_arg_by_index_consider_only_first("embed_vars", i) 8 | local possible_text = darwin.argv.get_flag_arg_by_index_consider_only_first(embed_var..":text",1) 9 | local possible_file = darwin.argv.get_flag_arg_by_index_consider_only_first(embed_var..":file",1) 10 | local possible_folder = darwin.argv.get_flag_arg_by_index_consider_only_first(embed_var..":folder",1) 11 | if not possible_text and not possible_file and not possible_folder then 12 | private_darwin.print_red("embed_var:"..embed_var.." not found\n") 13 | return false 14 | end 15 | 16 | if possible_text then 17 | project.embed_global(embed_var, possible_text) 18 | end 19 | 20 | if possible_file then 21 | project.embed_global(embed_var,darwin.file_stream(possible_file)) 22 | end 23 | 24 | if possible_folder then 25 | local folder_to_be_embed = {} 26 | if not darwin.dtw.isdir(possible_folder) then 27 | private_darwin.print_red("folder not found") 28 | return 29 | end 30 | 31 | local concat_path = false 32 | local files = darwin.dtw.list_files_recursively(possible_folder,concat_path) 33 | for i=1,#files do 34 | local file = files[i] 35 | local full_path = darwin.dtw.concat_path(possible_folder,file) 36 | folder_to_be_embed[file] = darwin.file_stream( full_path) 37 | end 38 | project.embed_global(embed_var,folder_to_be_embed) 39 | 40 | end 41 | 42 | end 43 | return true 44 | end -------------------------------------------------------------------------------- /src/cli/errors.lua: -------------------------------------------------------------------------------- 1 | 2 | function handle_unused() 3 | local unused_index = darwin.argv.get_next_unused_index() 4 | if unused_index then 5 | local unused_arg = darwin.argv.get_arg_by_index(unused_index) 6 | local msg = "arg:" .. unused_arg .. " at index: " .. unused_index .. "its unused" 7 | private_darwin.print_red(msg) 8 | return false 9 | end 10 | return true 11 | end -------------------------------------------------------------------------------- /src/cli/lua_save.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | function handle_main_file(project) 4 | local not_follow = darwin.argv.flags_exist({"not_follow"}) 5 | 6 | local entry_mode = darwin.argv.get_flag_arg_by_index_consider_only_first("entry_mode",1, "file") 7 | if not private_darwin.is_inside({"file","folder"},entry_mode) then 8 | private_darwin.print_red("entry mode not valid") 9 | return 10 | end 11 | 12 | local relative_path = darwin.argv.get_flag_arg_by_index_consider_only_first("relative_path") 13 | 14 | local main_file_or_folder = darwin.argv.get_next_unused() 15 | if not main_file_or_folder then 16 | private_darwin.print_red("main file not found") 17 | return false 18 | end 19 | 20 | if entry_mode == "file" then 21 | if not_follow then 22 | project.add_lua_file(main_file_or_folder,relative_path) 23 | else 24 | project.add_lua_file_following_require(main_file_or_folder,relative_path) 25 | end 26 | end 27 | 28 | 29 | if entry_mode == "folder" then 30 | if not darwin.dtw.isdir(main_file_or_folder) then 31 | private_darwin.print_red(main_file_or_folder .. "its not a folder\n") 32 | return false 33 | end 34 | local all_paths = darwin.dtw.list_files_recursively(main_file_or_folder, true) 35 | for i = 1, #all_paths do 36 | project.add_lua_file(all_paths[i],relative_path) 37 | end 38 | end 39 | return true 40 | end -------------------------------------------------------------------------------- /src/cli/main.lua: -------------------------------------------------------------------------------- 1 | ---typestart 2 | ---@class PrivateDarwin 3 | ---@field main fun() 4 | ---typeend 5 | 6 | private_darwin.main = function() 7 | darwin.argv.get_arg_by_index(1) 8 | if darwin.argv.one_of_args_exist("run_blueprint") then 9 | Perform_blue_print() 10 | elseif darwin.argv.one_of_args_exist("drop_types") then 11 | Drop_types() 12 | elseif darwin.argv.one_of_args_exist("drop_lua_cembed") then 13 | Drop_lua_cembed() 14 | elseif darwin.argv.flags_exist({ "help" }) or darwin.argv.one_of_args_exist("help") then 15 | Drop_help() 16 | elseif darwin.argv.flags_exist({ "version" }) or darwin.argv.one_of_args_exist("version") then 17 | print("darwin "..darwin.version) 18 | else 19 | Default_execution() 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /src/cli/projects/dynamic_link_lib.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | function create_dynamic_link_lib_project( project,output, output_mode) 4 | 5 | 6 | local compiler = nil 7 | if output_mode == "windows_bin" then 8 | compiler = darwin.argv.get_flag_arg_by_index_consider_only_first("compiler",1,"i686-w64-mingw32-gcc") 9 | end 10 | if output_mode == "linux_bin" then 11 | compiler = darwin.argv.get_flag_arg_by_index_consider_only_first("compiler",1, "gcc") 12 | end 13 | 14 | local flags_size = darwin.argv.get_flag_size_consider_only_first("flags") 15 | local flags_text = "" 16 | for i = 1, flags_size do 17 | local flag = darwin.argv.get_flag_arg_by_index_consider_only_first("flags", i, "") 18 | flags_text = flags_text .. " " .. flag 19 | end 20 | 21 | if not handle_main_file(project) then 22 | return 23 | end 24 | 25 | 26 | if not handle_unused() then 27 | return 28 | end 29 | 30 | local cache_output = "darwin_cache.c" 31 | darwin.dtw.remove_any(cache_output) 32 | project.generate_c_lib_file({ 33 | output = cache_output, 34 | object_export = object_export 35 | }) 36 | 37 | 38 | os.execute(compiler.." -shared -fPIC "..cache_output.." -o "..output.." "..flags) 39 | 40 | end -------------------------------------------------------------------------------- /src/cli/projects/executabe_bin_project.lua: -------------------------------------------------------------------------------- 1 | 2 | function create_executable_bin_project(project, output,output_mode) 3 | 4 | local compiler = nil 5 | if output_mode == "windows_bin" then 6 | compiler = darwin.argv.get_flag_arg_by_index_consider_only_first("compiler",1,"i686-w64-mingw32-gcc") 7 | end 8 | if output_mode == "linux_bin" then 9 | compiler = darwin.argv.get_flag_arg_by_index_consider_only_first("compiler",1, "gcc") 10 | end 11 | 12 | local flags_size = darwin.argv.get_flag_size_consider_only_first("flags") 13 | local flags_text = "" 14 | for i = 1, flags_size do 15 | local flag = darwin.argv.get_flag_arg_by_index_consider_only_first("flags", i, "") 16 | flags_text = flags_text .. " " .. flag 17 | end 18 | 19 | if not handle_main_file(project) then 20 | return 21 | end 22 | 23 | 24 | if not handle_unused() then 25 | return 26 | end 27 | 28 | 29 | local cache_output = "darwin_cache.c" 30 | darwin.dtw.remove_any(cache_output) 31 | project.generate_c_file({ 32 | output = cache_output, 33 | include_embed_data = true 34 | }) 35 | 36 | os.execute(compiler.." "..cache_output.." -o "..output.." "..flags_text) 37 | 38 | darwin.dtw.remove_any(cache_output) 39 | 40 | 41 | end -------------------------------------------------------------------------------- /src/cli/projects/executable_c_project.lua: -------------------------------------------------------------------------------- 1 | 2 | function create_executable_c_project(project, output, output_mode) 3 | 4 | 5 | if not handle_main_file(project) then 6 | return 7 | end 8 | 9 | 10 | if not handle_unused() then 11 | return 12 | end 13 | 14 | project.generate_c_file({ 15 | output = output, 16 | include_embed_data = true 17 | }) 18 | 19 | end -------------------------------------------------------------------------------- /src/cli/projects/lib_source.lua: -------------------------------------------------------------------------------- 1 | 2 | function create_lib_source_project(project,output, output_mode) 3 | 4 | local object_export = darwin.argv.get_flag_arg_by_index_consider_only_first("object_export", 1) 5 | if not object_export then 6 | private_darwin.print_red("Error: object_export is required") 7 | return 8 | end 9 | 10 | if not handle_main_file(project) then 11 | return 12 | end 13 | 14 | if not handle_unused() then 15 | return 16 | end 17 | 18 | 19 | 20 | project.generate_c_lib_file({ 21 | output = output, 22 | object_export = object_export 23 | }) 24 | 25 | end -------------------------------------------------------------------------------- /src/cli/projects/lua_project.lua: -------------------------------------------------------------------------------- 1 | 2 | ---@param entry string 3 | ---@param output string 4 | ---@param output_mode string 5 | function create_lua_project(project,output,output_mode) 6 | 7 | 8 | if not handle_main_file(project) then 9 | return 10 | end 11 | 12 | 13 | if not handle_unused() then 14 | return 15 | end 16 | 17 | 18 | project.generate_lua_file({ 19 | output = output, 20 | include_embed_data = true 21 | }) 22 | 23 | end -------------------------------------------------------------------------------- /types/LuaShip.lua: -------------------------------------------------------------------------------- 1 | ---@class LuaShipStartProps 2 | ---@class flags string[] 3 | ---@class volumes string[]string[] 4 | ---@class command string 5 | 6 | 7 | ---@class LuaShipMachine 8 | ---@field provider "podman"| "docker" 9 | ---@field docker_file string 10 | ---@field add_comptime_command fun(command:string) 11 | ---@field copy fun(host_data:string,dest_data:string) 12 | ---@field env fun(name:string,value:string) 13 | ---@field save_to_file fun(filename:string) 14 | ---@field start fun(props:LuaShipStartProps) 15 | 16 | 17 | ---@class LuaShip 18 | ---@field create_machine fun(distro:string):LuaShipMachine 19 | ---@field open fun(filename:string,mode:string) 20 | ---@field os_execute fun(command:string):boolean 21 | ---@field os_remove fun(filename:string) 22 | ---@field error fun(errror:string) 23 | -------------------------------------------------------------------------------- /types/PrivateDarwinEmbed.lua: -------------------------------------------------------------------------------- 1 | ---@class PrivateDarwinEmbed 2 | ---@field name string 3 | ---@field value table | string | boolean | number | DarwinFileStream 4 | -------------------------------------------------------------------------------- /types/asset.lua: -------------------------------------------------------------------------------- 1 | ---@class Asset 2 | ---@field path string 3 | ---@field content string 4 | -------------------------------------------------------------------------------- /types/camalgamator.lua: -------------------------------------------------------------------------------- 1 | ---@class PrivateAmalgamatorCInterop 2 | ---@field generate_amalgamation_simple fun(filename:string,max_content:number,max_recursion:number) 3 | ---@field generate_amalgamation_complex fun(filename:string,max_content:number,max_recursion:number,generator_callback:fun(include:string,path:string):"dont-include"| "dont-change" | "include-once" | "include-perpetual"):string 4 | ---@field CAMALGAMATOR_UNEXPECTED_ERROR number 5 | ---@field CAMALGAMATOR_DONT_INCLUDE number 6 | ---@field CAMALGAMATOR_DONT_CHANGE number 7 | ---@field CAMALGAMATOR_INCLUDE_ONCE number 8 | ---@field CAMALGAMATOR_INCLUDE_PERPETUAL number 9 | 10 | 11 | ---@class Amalgamator 12 | ---@field generate_amalgamation fun(filename:string, max_content_size:number | nil,max_recursion:number|nil):string 13 | ---@field generate_amalgamation_with_callback fun(filename:string,verifier_callback:(fun(include:string,path:string):"dont-include"|"dont-change"|"include-once"|"include-perpetual"), max_content_size:number|nil,max_recursion:number|nil):string 14 | ---@field ONE_MB number 15 | ---@field ONE_BYTE number 16 | 17 | 18 | ---@field Amalgamator 19 | private_darwin_camalgamator = private_darwin_camalgamator 20 | -------------------------------------------------------------------------------- /types/candango.lua: -------------------------------------------------------------------------------- 1 | ---@class HtmlContent 2 | ---@field exist_error boolean 3 | ---@field error_message boolean 4 | ---@field render_text string 5 | 6 | ---@class Cadango 7 | ---@field Render_text fun(text:string):HtmlContent 8 | 9 | 10 | ---@type Cadango 11 | private_darwin_candango = private_darwin_candango 12 | -------------------------------------------------------------------------------- /types/cgeneration_props.lua: -------------------------------------------------------------------------------- 1 | ---@class DarwinCGenerationComplexProps 2 | ---@field include_lua_cembed boolean | nil 3 | ---@field stream fun(data:string) 4 | 5 | ---@class DarwinCGenerationCodeProps 6 | ---@field include_lua_cembed boolean | nil 7 | 8 | ---@class DarwinCGenerationFileProps 9 | ---@field include_lua_cembed boolean | nil 10 | ---@field output string 11 | 12 | ---@class DarwinCLIBGenerationComplexProps 13 | ---@field lib_name string 14 | ---@field object_export string | nil 15 | ---@field include_lua_cembed boolean | nil 16 | ---@field stream fun(data:string) 17 | 18 | ---@class DarwinCLIBGenerationCodeProps 19 | ---@field lib_name string 20 | ---@field object_export string | nil 21 | ---@field include_lua_cembed boolean | nil 22 | 23 | ---@class DarwinCLIBGenerationFileProps 24 | ---@field lib_name string 25 | ---@field object_export string | nil 26 | ---@field include_lua_cembed boolean | nil 27 | ---@field output string 28 | -------------------------------------------------------------------------------- /types/consts.lua: -------------------------------------------------------------------------------- 1 | ---@type Asset[] 2 | PRIVATE_DARWIN_API_ASSETS = PRIVATE_DARWIN_API_ASSETS 3 | 4 | ---@type string 5 | PRIVATE_DARWIN_TYPES = PRIVATE_DARWIN_TYPES 6 | -------------------------------------------------------------------------------- /types/darwin.lua: -------------------------------------------------------------------------------- 1 | ---@class Darwin 2 | ---@field file_stream fun(src:string):DarwinFileStream 3 | ---@field create_project fun(project_name:string):DarwinProject 4 | ---@field dtw DtwModule 5 | ---@field candango Cadango 6 | ---@field chunk_size number 7 | ---@field argv Argv 8 | ---@field camalgamator Amalgamator 9 | ---@field ship LuaShip 10 | 11 | ---@type Darwin 12 | darwin = darwin 13 | -------------------------------------------------------------------------------- /types/darwin_project.lua: -------------------------------------------------------------------------------- 1 | ---@class DarwinProject 2 | ---@field lua_code (DarwinFileStream | string)[] 3 | ---@field c_code string[] 4 | ---@field c_calls string[] 5 | ---@field embed_data PrivateDarwinEmbed[] 6 | ---@field c_external_code (DarwinFileStream | string)[] 7 | ---@field c_main_code (DarwinFileStream | string)[] 8 | ---@field required_funcs DarwinEmbedCode[] 9 | ---@field so_includeds DarwinEmbedCode[] 10 | ---@field project_name string 11 | 12 | ---- methods 13 | ---@class DarwinProject 14 | ---@field add_c_external_code fun(code:string) 15 | ---@field add_c_include fun(include:string) 16 | ---@field add_c_file fun(filename:string, follow_includes:boolean, verifier_callback:(fun(import:string,path:string):boolean)) 17 | ---@field add_c_call fun(func_name:string) 18 | ---@field load_lib_from_c fun(lib_start_func:string, lua_obj:string) 19 | ---@field generate_c_complex fun(props:DarwinCGenerationComplexProps) 20 | ---@field generate_c_code fun(props:DarwinCGenerationCodeProps):string 21 | ---@field generate_c_file fun(props:DarwinCGenerationFileProps) 22 | ---@field generate_c_lib_complex fun(props:DarwinCLIBGenerationComplexProps) 23 | ---@field generate_c_lib_code fun(props:DarwinCLIBGenerationCodeProps):string 24 | ---@field generate_c_lib_file fun(props:DarwinCLIBGenerationFileProps) 25 | ---@field embed_global fun(name:string,value:table | string | number |boolean | DarwinFileStream) 26 | ---@field add_lua_code fun(code:string) 27 | ---@field add_lua_file fun(src:string) 28 | ---@field generate_lua_complex fun(props:LuaGenerationComplexProps) 29 | ---@field generate_lua_code fun(props:LuaGenerationCodeProps):string 30 | ---@field generate_lua_file fun(props:LuaGenerationOutputProps) 31 | ---@field add_lua_file_followin_require fun(src:string,relative_path:string) 32 | -------------------------------------------------------------------------------- /types/darwin_stream.lua: -------------------------------------------------------------------------------- 1 | ---@class DarwinFileStream 2 | ---@field type string 3 | ---@field filename string 4 | -------------------------------------------------------------------------------- /types/dtw.lua: -------------------------------------------------------------------------------- 1 | ---@class DtwFork 2 | ---@field sleep_time number 3 | ---@field kill fun() 4 | ---@field is_alive fun():boolean 5 | ---@field wait fun(milliseconds:number) 6 | 7 | ---@class DtwLocker 8 | ---@field lock fun(element:string):boolean 9 | ---@field unlock fun(element:string):DtwLocker 10 | 11 | 12 | ---@class DtwRandonizer 13 | ---@field set_seed fun(seed:number):DtwRandonizer 14 | ---@field set_time_seed fun(seed:number):DtwRandonizer 15 | ---@field generate_token fun(size:number):DtwRandonizer 16 | ---@field generate_num fun(size:number):number 17 | 18 | ---@class DtwTreeProps 19 | ---@field include_content boolean | nil 20 | ---@field include_content_data boolean | nil 21 | ---@field include_hardware_data boolean | nil 22 | ---@field include_ignored_elements boolean | nil 23 | ---@field mimify_json boolean | nil 24 | ---@field include_path_attributes boolean | nil 25 | 26 | ---@class DtwTreePart 27 | ---@field path DtwPath 28 | ---@field get_value fun():string 29 | ---@field set_value fun(value:string | number | boolean | DtwTreePart | DtwResource | DtwActionTransaction) 30 | ---@field hardware_remove fun(as_transaction:boolean|nil):DtwTreePart 31 | ---@field hardware_write fun(as_transaction:boolean|nil):DtwTreePart 32 | ---@field hardware_modify fun(as_transaction:boolean|nil):DtwTreePart 33 | ---@field get_sha fun():string 34 | ---@field is_blob fun():boolean 35 | ---@field unload fun():DtwTreePart 36 | ---@field load fun():DtwTreePart 37 | ---@field content_exist_in_hardware fun():boolean 38 | ---@field content_exist fun():boolean 39 | 40 | ---@class DtwTree 41 | ---@field newTreePart_empty fun (path:string):DtwTreePart 42 | ---@field newTreePart_loading fun (path:string):DtwTreePart 43 | ---@field get_tree_part_by_index fun(index:number):DtwTreePart 44 | ---@field insecure_hardware_write_tree fun():DtwTree 45 | ---@field insecure_hardware_remove fun():DtwTree 46 | ---@field commit fun():DtwTree 47 | ---@field get_size fun():number 48 | ---@field get_tree_part_by_name fun(name:string):DtwTreePart 49 | ---@field get_tree_part_by_path fun(name:string):DtwTreePart 50 | ---@field add_tree_from_hardware fun(path:string,props:DtwTreeProps | nil):DtwTreePart 51 | ---@field list fun(): DtwTreePart[] ,number 52 | ---@field find fun(callback: fun(part:DtwTreePart):boolean):DtwTreePart 53 | ---@field count fun(callback: fun(part:DtwTreePart):boolean):number 54 | ---@field map fun(callback: fun(part:DtwTreePart):any):any[] 55 | ---@field each fun(callback: fun(part:DtwTreePart)) 56 | ---@field filter fun(callback:fun(part:DtwTreePart):boolean):DtwTreePart[],number 57 | ---@field dump_to_json_string fun(props:DtwTreeProps | nil):string 58 | ---@field dump_to_json_file fun(file:string,props:DtwTreeProps | nil):DtwTree 59 | 60 | 61 | ---@class DtwPath 62 | ---@field path_changed fun():boolean 63 | ---@field add_start_dir fun(start_dir:string):DtwPath 64 | ---@field add_end_dir_method fun (end_dir:string):DtwPath 65 | ---@field changed fun():boolean 66 | ---@field get_dir fun():string 67 | ---@field get_extension fun():string 68 | ---@field get_name fun():string 69 | ---@field get_only_name fun():string 70 | ---@field get_full_path fun():string 71 | ---@field set_name fun(new_name:string) DtwPath 72 | ---@field set_only_name fun(new_name:string) DtwPath 73 | ---@field set_extension fun(extension:string):DtwPath 74 | ---@field set_dir fun(dir:string):DtwPath 75 | ---@field set_path fun(path:string):DtwPath 76 | ---@field replace_dirs fun(old_dir:string,new_dir:string):DtwPath 77 | ---@field get_total_dirs fun():number 78 | ---@field get_sub_dirs_from_index fun(start:number,end:number):string 79 | ---@field insert_dir_at_index fun(dir:string,index:number):DtwPath 80 | ---@field remove_sub_dir_at_index fun(start:number,end:number):DtwPath 81 | ---@field insert_dir_after fun(point:string, dir:string):DtwPath 82 | ---@field insert_dir_before fun(point:string, dir:string):DtwPath 83 | ---@field remove_dir_at fun(point:string):DtwPath 84 | ---@field unpack fun():string[],number 85 | 86 | 87 | 88 | ---@class DtwHasher 89 | ---@field digest fun(value:string | number | boolean | string ):DtwHasher 90 | ---@field digest_file fun(source:string):DtwHasher 91 | ---@field digest_folder_by_content fun(source:string):DtwHasher 92 | ---@field digest_folder_by_last_modification fun(source:string):DtwHasher 93 | ---@field get_value fun():string 94 | 95 | ---@class DtwActionTransaction 96 | ---@field get_type_code fun():number 97 | ---@field get_type fun():string 98 | ---@field get_content fun():string 99 | ---@field set_content fun() 100 | ---@field get_source fun():string 101 | ---@field get_dest fun():string 102 | ---@field set_dest fun():string 103 | 104 | 105 | ---@class DtwTransaction 106 | ---@field write fun(src :string , value:string | number | boolean | string | DtwResource ):DtwTransaction 107 | ---@field remove_any fun(src:string):DtwTransaction 108 | ---@field copy_any fun(src:string,dest:string):DtwTransaction 109 | ---@field move_any fun(src:string,dest:string):DtwTransaction 110 | ---@field dump_to_json_string fun():string 111 | ---@field dump_to_json_file fun(src:string):DtwTransaction 112 | ---@field list fun(): DtwActionTransaction[] ,number 113 | ---@field each fun(callbac: fun(value:DtwActionTransaction)) 114 | ---@field map fun(callbac: fun(value:DtwActionTransaction):any):any[],number 115 | ---@field find fun(callbac: fun(value:DtwActionTransaction):boolean):DtwActionTransaction 116 | ---@field count fun(callbac: fun(value:DtwActionTransaction):boolean):number 117 | ---@field filter fun(callback:fun(part:DtwActionTransaction):boolean):DtwActionTransaction[],number 118 | ---@field __index fun(index:number):DtwActionTransaction 119 | ---@field get_action fun(index:number):DtwActionTransaction 120 | ---@field commit fun():DtwTransaction 121 | 122 | 123 | ---@class DtwSchema 124 | ---@field add_primary_keys fun(values:string | string[]) 125 | ---@field sub_schema fun(values:string | string[]):DtwSchema 126 | ---@field set_value_name fun(name:string):DtwSchema 127 | ---@field set_index_name fun(name:string):DtwSchema 128 | 129 | 130 | ---@class DtwDatabaseSchema 131 | ---@field sub_schema fun(values:string | string[]):DtwSchema 132 | ---@field set_value_name fun(name:string):DtwSchema 133 | ---@field set_index_name fun(name:string):DtwSchema 134 | 135 | 136 | ---@class DtwResourceListaage 137 | ---@field resources DtwResource[] | nil 138 | ---@field size number | nil 139 | ---@field error string | nil 140 | 141 | 142 | 143 | ---@class DtwResource 144 | ---@field schema_new_insertion fun():DtwResource 145 | ---@field dangerous_remove_prop fun(primary_key:string):DtwResource 146 | ---@field dangerous_rename_prop fun(primary_key:string ,new_name:string) :DtwResource 147 | ---@field get_resource_matching_primary_key fun(primary_key: string, value:string | number | boolean | Dtwblobs | DtwResource ):DtwResource 148 | ---@field get_resource_by_name_id fun(id_name:string) DtwResource | nil 149 | ---@field list fun(): DtwResource[] ,number 150 | ---@field each fun(callback :fun(element:DtwResource)) 151 | ---@field find fun(callback:fun(value:DtwResource):boolean):DtwResource 152 | ---@field map fun(callback:fun(value:DtwResource):any):any[],number 153 | ---@field count fun(callback:fun(value:DtwResource):boolean):number 154 | ---@field filter fun(callback:fun(value:DtwResource):boolean):DtwResource[],number 155 | ---@field schema_list fun(): DtwResource[] 156 | ---@field schema_each fun(callback:fun(value:DtwResource)) 157 | ---@field schema_find fun(callback:fun(value:DtwResource):boolean):DtwResource 158 | ---@field schema_map fun(callback:fun(value:DtwResource):any):any[],number 159 | ---@field schema_count fun(callback:fun(value:DtwResource):boolean):number 160 | ---@field schema_filter fun(callback:fun(value:DtwResource):boolean):DtwResource[],number 161 | ---@field sub_resource fun(str:string) :DtwResource 162 | ---@field sub_resource_next fun(str:string | nil) :DtwResource 163 | ---@field sub_resource_now fun(str:string | nil) :DtwResource 164 | ---@field sub_resource_random fun(str:string | nil) :DtwResource 165 | ---@field sub_resource_now_in_unix fun(str:string | nil) :DtwResource 166 | ---@field __index fun(str:string) : number ,DtwResource 167 | ---@field get_value fun():string | number | boolean | nil | string 168 | ---@field get_string fun():string | nil 169 | ---@field get_type fun():string 170 | ---@field get_number fun(): number | nil 171 | ---@field get_bool fun(): boolean | nil 172 | ---@field set_value fun(value:string | number | boolean | string | DtwResource ):boolean 173 | ---@field commit fun() apply the modifications 174 | ---@field lock fun() boolean 175 | ---@field unlock fun():DtwResource 176 | ---@field unload fun() unload the content 177 | ---@field get_path_string fun() :string 178 | ---@field set_extension fun(extension:string) 179 | ---@field destroy fun():DtwResource 180 | ---@field set_value_in_sub_resource fun(key:string ,value:string | number | boolean | string | DtwResource ) 181 | ---@field try_set_value_in_sub_resource fun(key:string ,value:string | number | boolean | string | DtwResource ):boolean,string | nil 182 | ---@field get_value_from_sub_resource fun(key:string):string | number | boolean | nil | string 183 | ---@field newDatabaseSchema fun():DtwDatabaseSchema 184 | ---@field try_newSchema fun():boolean,string | DtwSchema 185 | ---@field try_rename fun(new_name:string):boolean,string | nil 186 | ---@field rename fun(new_name:string) 187 | ---@field try_set_value fun(value:string | number | boolean | string | DtwResource ):boolean,string | nil 188 | ---@field try_destroy fun():boolean,string | nil 189 | ---@field try_schema_new_insertion fun():boolean,string | DtwResource 190 | ---@field try_get_resource_by_name_id fun(id_name:string) :boolean,string | DtwResource 191 | ---@field try_dangerous_rename_prop fun(primary_key:string ,new_name:string):boolean,string | nil 192 | ---@field try_dangerous_remove_prop fun(primary_key:string):boolean,string | nil 193 | ---@field try_sub_resource fun(name:string):boolean,string | DtwResource 194 | ---@field try_sub_resource_next fun(name:string):boolean,string | DtwResource 195 | ---@field try_sub_resource_now fun(name:string):boolean,string | DtwResource 196 | ---@field try_sub_resource_now_in_unix fun(name:string):boolean,string | DtwResource 197 | ---@field try_sub_resource_random fun(name:string):boolean,string | DtwResource 198 | ---@field try_schema_list fun():DtwResourceListaage 199 | ---@field get_transaction fun():DtwTransaction 200 | 201 | 202 | ---@class DtwModule 203 | ---@field copy_any_overwriting fun(src:string,dest:string):boolean returns true if the operation were ok otherwise false 204 | ---@field copy_any_merging fun(src:string,dest:string):boolean returns true if the operation were ok otherwise false 205 | ---@field move_any_overwriting fun(src:string,dest:string):boolean returns true if the operation were ok otherwise false 206 | ---@field move_any_merging fun(src:string,dest:string):boolean returns true if the operation were ok otherwise false 207 | ---@field remove_any fun(src:string):boolean returns true if the operation were ok otherwise false 208 | ---@field base64_encode_file fun(src:string):string transform file into base64 209 | ---@field base64_encode fun(value:string | number | boolean | string):string transform content into base64 210 | ---@field base64_decode fun(value:string): string | string retransform base64 into normal value 211 | ---@field list_files fun(src:string,concat_path:boolean):string[],number 212 | ---@field list_dirs fun(src:string,concat_path:boolean):string[],number 213 | ---@field list_all fun(src:string,concat_path:boolean):string[],number 214 | ---@field list_files_recursively fun(src:string,concat_path:boolean):string[],number 215 | ---@field list_dirs_recursively fun(src:string,concat_path:boolean):string[],number 216 | ---@field list_all_recursively fun(src:string,concat_path:boolean):string[],number 217 | ---@field load_file fun(src:string):string | string 218 | ---@field write_file fun(src:string,value:string | number | boolean | DtwTreePart | DtwResource | DtwActionTransaction) 219 | ---@field is_blob fun(value:any):boolean returns if a value is a blob 220 | ---@field newResource fun(src:string):DtwResource 221 | ---@field generate_sha fun(value:string | number | boolean | string):string 222 | ---@field generate_sha_from_file fun(src:string):string 223 | ---@field generate_sha_from_folder_by_content fun(src:string):string 224 | ---@field generate_sha_from_folder_by_last_modification fun(src:string):string 225 | ---@field newHasher fun():DtwHasher 226 | ---@field isdir fun(file:string):boolean 227 | ---@field isfile fun(file:string):boolean 228 | ---@field isfile_blob fun(file:string):boolean 229 | ---@field newTransaction fun():DtwTransaction 230 | ---@field new_transaction_from_file fun(file:string):DtwTransaction 231 | ---@field new_transaction_from_string fun(content:string):DtwTransaction 232 | ---@field try_new_transaction_from_file fun(file:string):boolean,DtwTransaction |string 233 | ---@field try_new_transaction_from_string fun(content:string):boolean, DtwTransaction | string 234 | ---@field newPath fun(path:string):DtwPath 235 | ---@field newTree fun():DtwTree 236 | ---@field newTree_from_hardware fun(path:string,props:DtwTreeProps | nil):DtwTree 237 | ---@field newTree_from_json_file fun(path:string):DtwTree 238 | ---@field newTree_from_json_string fun (content:string):DtwTree 239 | ---@field try_newTree_from_json_file fun(path:string):DtwTree 240 | ---@field try_newTree_from_json_string fun (content:string):DtwTree 241 | ---@field concat_path fun(path1:string,path2:string):string 242 | ---@field starts_with fun(comparation:string,prefix:string):boolean 243 | ---@field ends_with fun(comparation:string,sulfix:string):boolean 244 | ---@field newRandonizer fun():DtwRandonizer 245 | ---@field newFork fun(callback:fun()):DtwFork 246 | ---@field newLocker fun():DtwLocker 247 | ---@field get_entity_last_modification_in_unix fun(entity:string):number | nil 248 | ---@field get_entity_last_modification fun(entity:string):string | nil 249 | 250 | ---@type DtwModule 251 | private_darwin_dtw = private_darwin_dtw 252 | -------------------------------------------------------------------------------- /types/lua_argv.lua: -------------------------------------------------------------------------------- 1 | -- file: src/types.lua 2 | 3 | ---@class Argv 4 | ---@field get_flag_size fun(flags:string[]|string):number 5 | ---@field get_flag_arg_by_index fun(flags:string[]|string,index:number,default:string | nil):string|nil 6 | ---@field flags_exist fun(flags:string[]):boolean 7 | ---@field get_flag_size_consider_only_first fun(flags:string[]|string):number 8 | ---@field get_flag_arg_by_index_consider_only_first fun(flags:string[]|string,index:number,default:string | nil):string|nil 9 | ---@field one_of_args_exist fun(arg:string[] | string):boolean 10 | ---@field get_total_args_size fun():number 11 | ---@field get_arg_by_index_not_adding_to_used fun(index:number):string 12 | ---@field get_arg_by_index fun(index:number):string | nil 13 | ---@field get_compact_flags fun(flags:string[]|string,index,default:string | nil):string|nil 14 | ---@field get_compact_flags_size fun(flags:string[]|string):number 15 | ---@field used_args number[] 16 | ---@field type fun(value:any):string 17 | ---@field argslist string[] 18 | ---@field substr_func fun(str:string,start:number,endnum:number):string 19 | ---@field get_str_size fun(str:string):number 20 | ---@field flag_identifiers string[] 21 | ---@field add_used_args_by_index fun(used_flag:number) 22 | ---@field get_total_unused_args fun():number 23 | ---@field get_unsed_arg_by_index fun(index:number):string|nil 24 | ---@field get_next_unused_index fun():number|nil 25 | ---@field get_next_unused fun():string|nil 26 | 27 | 28 | ---@class PrivateArgv 29 | ---@field starts_with fun(str:string,target:string):boolean 30 | ---@field get_array_size fun(array:table):number 31 | ---@field is_inside fun(array:table,item:any):boolean 32 | ---@field get_formmated_flag_if_its_a_flag fun(current_arg:string):string |nil 33 | 34 | 35 | 36 | ---@type PrivateArgv 37 | private_luargv = private_luargv 38 | 39 | 40 | ---@type Argv 41 | luargv = luargv 42 | 43 | 44 | 45 | ---@type PrivateArgv 46 | private_luargv = private_luargv 47 | 48 | 49 | ---@type Argv 50 | luargv = luargv 51 | -------------------------------------------------------------------------------- /types/lua_generation.lua: -------------------------------------------------------------------------------- 1 | ---@class LuaGenerationComplexProps 2 | ---@field stream fun(content:string) 3 | ---@field include_embed_data boolean 4 | 5 | ---@class LuaGenerationCodeProps 6 | ---@field include_embed_data boolean 7 | 8 | ---@class LuaGenerationOutputProps 9 | ---@field include_embed_data boolean 10 | ---@field output string 11 | -------------------------------------------------------------------------------- /types/private_darwin.lua: -------------------------------------------------------------------------------- 1 | ---@class PrivateDarwin 2 | ---@field get_asset fun(asset_struct:Asset[],src:string):string 3 | ---@field list_assets_recursivly fun(asset_struct:Asset[],src:string):string[] 4 | ---@field list_assets fun(asset_struct:Asset[],src:string):string[] 5 | ---@field is_file_stream fun(item:any):boolean 6 | ---@field transfer_file_stream fun(filestream:DarwinFileStream, stream:fun(data:string)) 7 | ---@field transfer_file_stream_bytes fun(filestream:DarwinFileStream, stream:fun(data:string)) 8 | ---@field transfer_byte_direct_stream fun(str:string,stream:fun(data:string)) 9 | ---@field transfer_byte_internal_format fun(str:string,stream:fun(data:string)) 10 | ---@field transfer_byte_size_decide fun(str:string,stream:fun(data:string)) 11 | ---@class PrivateDarwin 12 | ---@field is_inside fun(array:any[],value:any):boolean 13 | ---@field count_bars fun(src:string):number 14 | ---@field extract_dir fun(src:string):string 15 | 16 | ---@class PrivateDarwin 17 | ---@field is_string_at_point fun(str:string,target:string,point:number):boolean 18 | ---@field starts_with fun(str:string,target:string):boolean 19 | 20 | 21 | ---@type PrivateDarwin 22 | private_darwin = private_darwin 23 | -------------------------------------------------------------------------------- /types/private_darwin_project.lua: -------------------------------------------------------------------------------- 1 | ---@class PrivateDarwinProject 2 | ---@field construct_globals fun(selfobj:DarwinProject) 3 | ---@field add_lua_methods fun(selfobj:DarwinProject ) 4 | ---@field add_c_external_code fun(selfobj:DarwinProject,code:string) 5 | ---@field add_c_include fun(selfobj:DarwinProject,include:string) 6 | ---@field add_c_file fun(selfobj:DarwinProject,filename:string, follow_includes:boolean, verifier_callback:(fun(import:string,path:string):boolean)) 7 | ---@field add_c_call fun(selfobj:DarwinProject,func_name:string) 8 | ---@field load_lib_from_c fun(selfobj:DarwinProject, lib_start_func:string, lua_obj:string) 9 | ---@field create_include_stream fun(self_obj:DarwinProject, include:string, relative_path:DtwSchema):string | nil 10 | 11 | ---@class PrivateDarwinProject 12 | ---@field add_lua_code fun(selfobj:DarwinProject,code:string) 13 | ---@field add_lua_file fun(selfobj:DarwinProject,src:string) 14 | ---@field is_required_included fun(self_obj:DarwinProject, include:string):boolean 15 | ---@field is_so_includeds fun(self_obj:DarwinProject, include:string):boolean 16 | ---@field add_lua_file_followin_require fun(selfobj:DarwinProject,src:string,relative_path:string) 17 | ---@field add_lua_file_followin_require_recursively fun(selfobj:DarwinProject,src:string,relative_path:string) 18 | ---@field create_c_str_buffer fun(str_code:string,str_shas:string[],stream:fun(data:string)):string 19 | ---@field embed_c_table fun(current_table:table,increment:(fun():number), streamed_shas:string[], stream:fun(data:string)):string 20 | ---@field embed_global_in_c fun(name:string, var:any, streamed_shas:string[], stream:fun(data:string), increment:(fun():string)) 21 | ---@field generate_c_complex fun(selfobj:DarwinProject,props:DarwinCGenerationComplexProps) 22 | ---@field generate_c_code fun(selfobj:DarwinProject,props:DarwinCGenerationCodeProps):string 23 | ---@field generate_c_file fun(selfobj:DarwinProject,props:DarwinCGenerationFileProps) 24 | ---@field generate_c_lib_complex fun(selfobj:DarwinProject,props:DarwinCLIBGenerationComplexProps) 25 | ---@field generate_c_lib_code fun(selfobj:DarwinProject,props:DarwinCLIBGenerationCodeProps):string 26 | ---@field generate_c_lib_file fun(selfobj:DarwinProject,props:DarwinCLIBGenerationFileProps) 27 | 28 | ---@class PrivateDarwinProject 29 | ---@field add_c_methods fun(selfobj:DarwinProject) 30 | ---@field embed_global_in_lua fun(name:string,var:table | number | boolean | string,streammed_shas:string[], stream:fun(data:string)) 31 | ---@field embed_table_in_lua fun(name:string,var:table,streamed_shas:string[],stream:fun(data:string)) 32 | ---@field create_lua_str_buffer fun(str:string,streamed_shas:string[], stream:fun(data:string)):string 33 | ---@field create_lua_stream_buffer fun(filestream:DarwinFileStream ,streamed_shas:string[], stream:fun(data:string)):string 34 | 35 | 36 | ---@class PrivateDarwinProject 37 | ---@field embed_global fun(selfobj:DarwinProject,name:string,value:table | string | boolean | number | DarwinFileStream) 38 | ---@class PrivateDarwinProject 39 | ---@field generate_lua_complex fun(selfobj:DarwinProject,props:LuaGenerationComplexProps) 40 | ---@field generate_lua_code fun(selfobj:DarwinProject,props:LuaGenerationCodeProps):string 41 | ---@field generate_lua_file fun(selfobj:DarwinProject,props:LuaGenerationOutputProps) 42 | 43 | ---@type PrivateDarwinProject 44 | private_darwin_project = private_darwin_project 45 | -------------------------------------------------------------------------------- /types/required_funcs.lua: -------------------------------------------------------------------------------- 1 | ---@class DarwinEmbedCode 2 | ---@field content DarwinFileStream | string 3 | ---@field comptime_included string 4 | --------------------------------------------------------------------------------