{"id":23119239,"url":"https://github.com/over-run/marshal","last_synced_at":"2025-04-04T02:40:50.689Z","repository":{"id":211561019,"uuid":"726336798","full_name":"Over-Run/marshal","owner":"Over-Run","description":"Marshal allows you to conveniently create native library bindings with FFM API.","archived":false,"fork":false,"pushed_at":"2024-12-06T05:36:26.000Z","size":752,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T14:21:39.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://over-run.github.io/marshal/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Over-Run.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2023-12-02T04:48:53.000Z","updated_at":"2024-12-06T05:36:10.000Z","dependencies_parsed_at":"2023-12-19T19:55:37.035Z","dependency_job_id":"1c9115eb-3479-4a34-8153-9184ce1d2139","html_url":"https://github.com/Over-Run/marshal","commit_stats":null,"previous_names":["over-run/marshal"],"tags_count":39,"template":false,"template_full_name":"Over-Run/project-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Over-Run%2Fmarshal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Over-Run%2Fmarshal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Over-Run%2Fmarshal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Over-Run%2Fmarshal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Over-Run","download_url":"https://codeload.github.com/Over-Run/marshal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247112739,"owners_count":20885605,"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":[],"created_at":"2024-12-17T05:32:18.549Z","updated_at":"2025-04-04T02:40:50.667Z","avatar_url":"https://github.com/Over-Run.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Marshal\n\n[![Java CI with Gradle](https://github.com/Over-Run/marshal/actions/workflows/gradle.yml/badge.svg?event=push)](https://github.com/Over-Run/marshal/actions/workflows/gradle.yml)\n\nMarshal allows you to conveniently create native library bindings with [FFM API](https://openjdk.org/jeps/454).\n\n~~See [wiki](https://github.com/Over-Run/marshal/wiki) for more information.~~\n\nThis library requires JDK 23 ~~or newer~~.\n\n## Overview\n\n```java\nimport overrun.marshal.*;\nimport overrun.marshal.gen.*;\n\nimport java.lang.foreign.Arena;\nimport java.lang.foreign.MemorySegment;\nimport java.lang.foreign.SegmentAllocator;\nimport java.lang.invoke.MethodHandles;\n\n/**\n * GLFW constants and functions\n */\ninterface GLFW {\n    /**\n     * The instance of the loaded library\n     */\n    GLFW INSTANCE = Downcall.load(MethodHandles.lookup(), \"libglfw3.so\");\n\n    /**\n     * A field\n     */\n    int GLFW_KEY_A = 65;\n\n    /**\n     * A normal function\n     */\n    void glfwSwapInterval(int interval);\n\n    /**\n     * A function with ref parameters.\n     * Marks the array parameter as a place to store the value returned by C\n     */\n    void glfwGetWindowPos(MemorySegment window, @Ref int[] posX, @Ref int[] posY);\n\n    /**\n     * Requires a segment allocator to allocate the string;\n     * if the first parameter is not segment allocator, then the memory stack is used\n     *\n     * @param allocator the segment allocator\n     * @param width     the width\n     * @param height    the height\n     * @param title     the title\n     * @param monitor   the monitor\n     * @param share     the share\n     * @return the window\n     */\n    MemorySegment glfwCreateWindow(SegmentAllocator allocator, int width, int height, String title, MemorySegment monitor, MemorySegment share);\n}\n\nclass Main {\n    public static void main(String[] args) {\n        GLFW glfw = GLFW.INSTANCE;\n        int key = GLFW.GLFW_KEY_A;\n        glfw.glfwSwapInterval(1);\n\n        // Arena\n        try (var arena = Arena.ofConfined()) {\n            MemorySegment windowHandle = glfw.glfwCreateWindow(arena,\n                800,\n                600,\n                \"The title\",\n                MemorySegment.NULL,\n                MemorySegment.NULL);\n\n            // ref by array\n            int[] ax = {0}, ay = {0};\n            glfw.glfwGetWindowPos(windowHandle, ax, ay);\n        }\n    }\n}\n```\n\n## Import\n\nImport as a Gradle dependency:\n\n```groovy\ndependencies {\n    implementation(\"io.github.over-run:marshal:0.1.0-alpha.38-jdk23\")\n}\n```\n\nand add this VM argument to enable native access: `--enable-native-access=io.github.overrun.marshal`  \nor this if you don't use modules: `--enable-native-access=ALL-UNNAMED`\n\n## Additions\n\n- [OverrunGL](https://github.com/Over-Run/overrungl), which is using Marshal\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fover-run%2Fmarshal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fover-run%2Fmarshal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fover-run%2Fmarshal/lists"}