{"id":19572640,"url":"https://github.com/parapluu/nifty","last_synced_at":"2025-04-27T04:32:17.108Z","repository":{"id":11666282,"uuid":"14175077","full_name":"parapluu/nifty","owner":"parapluu","description":"Erlang NIF Wrapper Generator","archived":false,"fork":false,"pushed_at":"2022-07-08T16:32:45.000Z","size":4593,"stargazers_count":141,"open_issues_count":5,"forks_count":29,"subscribers_count":15,"default_branch":"master","last_synced_at":"2023-11-07T20:14:24.441Z","etag":null,"topics":["erlang"],"latest_commit_sha":null,"homepage":"http://parapluu.github.io/nifty/","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parapluu.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}},"created_at":"2013-11-06T14:38:47.000Z","updated_at":"2023-09-23T12:03:17.000Z","dependencies_parsed_at":"2022-07-14T02:50:27.342Z","dependency_job_id":null,"html_url":"https://github.com/parapluu/nifty","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parapluu%2Fnifty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parapluu%2Fnifty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parapluu%2Fnifty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parapluu%2Fnifty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parapluu","download_url":"https://codeload.github.com/parapluu/nifty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224059052,"owners_count":17248735,"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":["erlang"],"created_at":"2024-11-11T06:27:47.373Z","updated_at":"2024-11-11T06:27:48.263Z","avatar_url":"https://github.com/parapluu.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Travis][travis badge]][travis]\n[![Erlang Versions][erlang versions badge]][erlang]\n[![Clang Versions][clang versions badge]][clang]\n[![Last Commit][commit badge]][commit]\n\n\n# Nifty - Erlang NIF Wrapper Generator\n\nNifty is an interface generator that allows the use of C modules from Erlang.\n\nWeb page: [http://parapluu.github.io/nifty/]\n\n## A Simple Example\n\nLet's say we have two C files `mylib.h` and `mylib.c` which we want to use in our Erlang application:\n\n```C\n/* mylib.h */\nextern int fib(int n);\n```\n\n```C\n/* mylib.c */\nint\nfib(int n) {\n  if (n \u003c= 2) {\n    return 1;\n  } else {\n    return fib(n-1) + fib(n-2);\n  }\n}\n\n```\n\nWe can generate a NIF interface and use it from Erlang with the following command:\n\n```Erlang\nnifty:compile(\"mylib.h\", mylib, nifty_utils:add_sources([\"mylib.c\"], [])).\n5 = mylib:fib(5).\n```\n\n***nifty:compile/3*** gets as its first argument a header or interface\nfile and tries to generate an interface for all specified functions.\nThe second argument specifies the Erlang module the interface is about\nto use and the third argument is used for additional options.  These\noptions are compatible with the ones rebar uses to compile NIF\nmodules.  In fact, Nifty uses rebar to compile the generated interface.\n\n## Installation\nAfter successfully cloning enter the following commands\n\n```shell\nmake\n```\n\nand include Nifty in your ERL_LIBS path.\n\n## Unit Tests\nRun the following command to check that everything works correct:\n\n```shell\nmake tests\n```\n\n## Dependencies\n* The [clang](http://clang.llvm.org/) compiler and **libclang**, including the header files.\n* **[Optional]** [PropEr](https://github.com/proper-testing/proper) for the unit tests.\n\n## Base Types\n\n| C Types                        | Erlang Types                | Nifty Type Name\n|--------------------------------|-----------------------------|--------------------------\n| ```signed int``` or ```int```  | ```integer()```             | ```nifty.int```\n| ```unsigned int```             | ```integer()```             | ```nifty.unsigned int```\n| ```char```                     | ```integer()```             | ```nifty.char```\n| ```short```                    | ```integer()```             | ```nifty.short```\n| ```long```                     | ```integer()```             | ```nifty.long```\n| ```long long```                | ```integer()```             | ```nifty.long long```\n| ```float```                    | ```float()```               | ```nifty.float```\n| ```double```                   | ```float()```               | ```nifty.double```\n| ```\u003ctype\u003e *```                 | ```{integer(), string()}``` | ```\u003cmodule\u003e.\u003ctype\u003e *```\n\n## Known Limitations\n* Function pointers are only partially supported.\n* There is no support for anonymous structs and unions.\n* Functions using unsupported types are not translated and a warning is issued.\n* Functions with a variable number of arguments (`va_list` or `...`) are not supported. If `va_list` as type is used, Nifty will print a warning. If `...` is used, then the function is translated **without** the variable arguments: `int printf(const char *format, ...)` will be translated into `printf/1`.\n* The usage of incomplete types is limited.\n* Nifty has not been tested under Windows.\n\n\u003c!-- Links (alphabetically) --\u003e\n[clang]: http://clang.llvm.org\n[commit]: https://github.com/parapluu/nifty/commit/HEAD\n[erlang]: http://www.erlang.org\n[travis]: https://travis-ci.org/parapluu/nifty\n\n\u003c!-- Badges (alphabetically) --\u003e\n[clang versions badge]: https://img.shields.io/badge/clang-3.8.1%20to%209.0.0-ff69b4.svg?style=flat-square\n[commit badge]: https://img.shields.io/github/last-commit/parapluu/nifty.svg?style=flat-square\n[erlang versions badge]: https://img.shields.io/badge/erlang-20.0%20to%2022.3-blue.svg?style=flat-square\n[travis badge]: https://img.shields.io/travis/parapluu/nifty.svg?branch=master?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparapluu%2Fnifty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparapluu%2Fnifty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparapluu%2Fnifty/lists"}