{"id":16209261,"url":"https://github.com/gilzoide/gdextension-lite","last_synced_at":"2025-03-19T08:31:02.267Z","repository":{"id":194664048,"uuid":"691309161","full_name":"gilzoide/gdextension-lite","owner":"gilzoide","description":"Automatically generated header-only GDExtension bindings for C/C++","archived":false,"fork":false,"pushed_at":"2024-02-12T23:07:04.000Z","size":761,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T16:58:51.798Z","etag":null,"topics":["binding-generator","bindings","gdextension","godot","godot-engine","header-only"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gilzoide.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["gilzoide"],"patreon":null,"open_collective":null,"ko_fi":"gilzoide","tidelift":null,"community_bridge":null,"liberapay":"gilzoide","issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-09-13T23:25:17.000Z","updated_at":"2024-05-14T04:22:37.000Z","dependencies_parsed_at":"2023-12-29T11:28:11.488Z","dependency_job_id":"c78b4218-b0bb-4b65-9b29-d898270ed2d6","html_url":"https://github.com/gilzoide/gdextension-lite","commit_stats":null,"previous_names":["gilzoide/gdextension-lite"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fgdextension-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fgdextension-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fgdextension-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fgdextension-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilzoide","download_url":"https://codeload.github.com/gilzoide/gdextension-lite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243976478,"owners_count":20377691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binding-generator","bindings","gdextension","godot","godot-engine","header-only"],"created_at":"2024-10-10T10:28:58.676Z","updated_at":"2025-03-19T08:31:00.896Z","avatar_url":"https://github.com/gilzoide.png","language":"C","funding_links":["https://github.com/sponsors/gilzoide","https://ko-fi.com/gilzoide","https://liberapay.com/gilzoide"],"categories":[],"sub_categories":[],"readme":"# GDExtension Lite\nAutomatically generated GDExtension bindings for C/C++\n\nThis is not meant to be a replacement for the [godot-cpp](https://github.com/godotengine/godot-cpp) project,\nbut rather an alternative for those who want the full API matching `extension_api.json` in a C-compatible interface,\nfor example for creating bindings for other programming languages.\n\n\n## Features\n- Easily embeddable in any project: include [gdextension-lite.h](gdextension-lite/gdextension-lite.h), compile and link [gdextension-lite-one.c](gdextension-lite/gdextension-lite-one.c) and you're good to go\n- Automatically generated from `extension_api.json` file, so new Godot APIs are added in a matter of regenerating the bindings\n- Bindings for all Godot classes, variant types, methods, operators, utility functions, enums, GDExtension interface functions\n- Extra constructors with C strings for `String`, `StringName`, `NodePath`, `Color`, `godot_int` and `godot_float`\n- `GDCLEANUP` macro for declaring variables with automatic cleanup in C (compiler needs to support `__attribute__((cleanup(...)))`, like GCC and clang)\n- Supports Godot 4.1+\n- Faster compilation time than godot-cpp project\n\n\n## How to use\n1. Generate the bindings files (needs Python 3.10+):\n   ```sh\n   make generate-bindings\n   ```\n2. Implement your extension in C/C++:\n   ```c\n   // @file my-extension.c\n   \n   // 1. Include gdextension-lite.h: the whole API is accessible through it\n   #include \u003cgdextension-lite/gdextension-lite.h\u003e\n   \n   void initialize(void *userdata, GDExtensionInitializationLevel p_level);\n   void deinitialize(void *userdata, GDExtensionInitializationLevel p_level);\n   \n   // 2. In your GDExtension entrypoint, call `gdextension_lite_initialize`\n   GDExtensionBool gdextension_entry(\n       GDExtensionInterfaceGetProcAddress p_get_proc_address,\n       GDExtensionClassLibraryPtr p_library,\n       GDExtensionInitialization *r_initialization\n   ) {\n       gdextension_lite_initialize(p_get_proc_address);\n   \n       // setup initialize/deinitialize as usual\n       r_initialization-\u003einitialize = \u0026initialize;\n       r_initialization-\u003edeinitialize = \u0026deinitialize;\n       \n       // return success as usual\n       return 1;\n   }\n   \n   // 3. Use the bindings freely\n   void initialize(void *userdata, GDExtensionInitializationLevel p_level) {\n       if (p_level != GDEXTENSION_INITIALIZATION_SCENE) {\n           return;\n       }\n   \n       // print(\"Hello from GDExtension Lite!\")\n       {\n           godot_String msg = godot_new_String_with_latin1_chars(\"Hello from GDExtension Lite!\");\n           godot_Variant msg_var = godot_new_Variant_with_String(\u0026msg);\n           godot_print(\u0026msg_var, NULL, 0);\n           // As always in C, you are responsible for freeing objects\n           godot_Variant_destroy(\u0026msg_var);\n           godot_String_destroy(\u0026msg);\n       }\n   \n       // prints(\"OS.get_name() ==\", OS.get_name())\n       {\n           // Use \"GDCLEANUP(godot_TYPE)\" for automatic variable cleanup at the end of scope\n           // (compiler needs to support `__attribute__((cleanup(...)))`, like GCC and clang)\n           GDCLEANUP(godot_String) msg = godot_new_String_with_latin1_chars(\"OS.get_name() ==\");\n           GDCLEANUP(godot_Variant) msg_var = godot_new_Variant_with_String(\u0026msg);\n   \n           // Objects are always used via pointers, no need for cleanup\n           // You may need to reference/unreference RefCounted instances, though\n           godot_OS *os = godot_OS_singleton();\n   \n           GDCLEANUP(godot_String) os_name = godot_OS_get_name(os);\n           GDCLEANUP(godot_Variant) os_name_var = godot_new_Variant_with_String(\u0026os_name);\n   \n           const godot_Variant *args[] = { \u0026os_name_var };\n           godot_prints(\u0026msg_var, args, 1);\n       }\n   \n       // var node = Node()\n       // print(node)\n       // node.free()\n       {\n           godot_Node *node = godot_new_Node();\n           GDCLEANUP(godot_String) node_name = godot_Object_to_string((godot_Object *) node);\n           GDCLEANUP(godot_Variant) node_name_var = godot_new_Variant_with_String(\u0026node_name);\n           godot_print(\u0026node_name_var, NULL, 0);\n           godot_object_destroy(node);\n       }\n   }\n   \n   void deinitialize(void *userdata, GDExtensionInitializationLevel p_level) {\n       // no-op\n   }\n   ```\n3. Now compile `gdextension-lite-one.c` and link it to your own code.\n   Example SConstruct:\n   ```python\n   SharedLibrary(\n       [\n         'my-extension.c',\n         'path-to-gdextension-lite/gdextension-lite/gdextension-lite-one.c',\n       ],\n       CFLAGS=[\"-O2\", \"-flto\"],\n   )\n   ```\n   We recommend compiling `gdextension-lite-one.c` with `-O2 -flto` flags to avoid linking all Godot functions, but rather link only the ones you actually use.\n\nSample code is also available at the [sample](sample) folder.\n\n\n## Naming conventions\n1. Every type and function binding from Godot have the prefix `godot_`\n2. Every GDExtension Lite function have the prefix `gdextension_lite_`\n3. Constructors have the format `godot_new_\u003ctype name\u003e` or `godot_new_\u003ctype name\u003e_with_\u003carg1 type\u003e_\u003carg2 type\u003e...`\n4. Destructors have the format `godot_\u003ctype name\u003e_destroy`\n5. Member getters have the format `godot_\u003ctype name\u003e_get_\u003cmember name\u003e`\n6. Member setters have the format `godot_\u003ctype name\u003e_set_\u003cmember name\u003e`\n7. Indexed getters have the format `godot_\u003ctype name\u003e_indexed_get`\n8. Indexed setters have the format `godot_\u003ctype name\u003e_indexed_set`\n9. Keyed getters have the format `godot_\u003ctype name\u003e_keyed_get`\n10. Keyed setters have the format `godot_\u003ctype name\u003e_keyed_set`\n11. Operators have the format `godot_\u003ctype name\u003e_op_\u003coperator name\u003e` for unary operators and `godot_\u003ctype name\u003e_op_\u003coperator name\u003e_\u003cright-hand side type\u003e` for binary operators\n12. Methods have the format `godot_\u003ctype name\u003e_\u003cmethod name\u003e`\n13. Enumerators defined by classes have the format `godot_\u003ctype name\u003e_\u003cenum name\u003e`\n14. Godot utility functions have the format `godot_\u003cfunction name\u003e`\n15. Variadic methods and utility functions expect argv/argc parameters\n16. Singleton getters have the format `godot_\u003ctype name\u003e_singleton`\n\n\n## Generating bindings\n1. Update the `extension_api.json` and `gdextension_interface.h` files (depends on Godot 4 executable):\n   ```sh\n   make refresh-gdextension-api\n   ```\n2. Generate the bindings files (depends on Python 3.10+):\n   ```sh\n   make generate-bindings\n   ```\n3. Generate the distribution `build/gdextension-lite.zip` file with all headers:\n   ```sh\n   make dist\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Fgdextension-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilzoide%2Fgdextension-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Fgdextension-lite/lists"}