{"id":19145572,"url":"https://github.com/yue/kizunapi","last_synced_at":"2025-05-07T01:43:33.166Z","repository":{"id":57711599,"uuid":"507902695","full_name":"yue/kizunapi","owner":"yue","description":"A set of header-only C++ classes for type conversion between C++ and JavaScript using Node-API.","archived":false,"fork":false,"pushed_at":"2024-11-10T01:29:52.000Z","size":157,"stargazers_count":20,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-05T00:17:41.233Z","etag":null,"topics":["cpp","javascript","napi","node-api","node-module","nodejs"],"latest_commit_sha":null,"homepage":"","language":"C++","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/yue.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":"2022-06-27T12:36:42.000Z","updated_at":"2024-12-14T03:49:01.000Z","dependencies_parsed_at":"2024-09-07T02:53:17.827Z","dependency_job_id":"a759cda2-dc1d-4f4a-a631-a1eaa8c5f2a1","html_url":"https://github.com/yue/kizunapi","commit_stats":{"total_commits":111,"total_committers":2,"mean_commits":55.5,"dds":"0.18918918918918914","last_synced_commit":"4c59c84e6dd1d2da260b257adf1bd8c5244fde32"},"previous_names":["zcbenz/kizunapi","yue/kizunapi"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yue%2Fkizunapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yue%2Fkizunapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yue%2Fkizunapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yue%2Fkizunapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yue","download_url":"https://codeload.github.com/yue/kizunapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252676031,"owners_count":21786883,"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":["cpp","javascript","napi","node-api","node-module","nodejs"],"created_at":"2024-11-09T07:41:04.575Z","updated_at":"2025-05-07T01:43:33.141Z","avatar_url":"https://github.com/yue.png","language":"C++","readme":"# kizunapi\n\nA set of header-only C++ classes for type conversion between C++ and JavaScript\nusing [Node-API](https://nodejs.org/api/n-api.html).\n\nKizunapi makes writing library bindings easy: you don't write wrapper code for\neach API, instead you provide minimal information about types and kizunapi will\ndo the rest of the work via C++ type deduction.\n\n__This project is at early stage, behavior of APIs may change without notice.__\n\n## Usage\n\n1. Add this module to dependencies in `package.json`:\n\n```json\n  \"dependencies\": {\n    \"kizunapi\": \"*\",\n  }\n```\n\n2. Add include directory in `binding.gyp`:\n\n```python\n  'include_dirs': [\"\u003c!(node -p \\\"require('kizunapi').include_dir\\\")\"],\n```\n\n3. Enable C++17 in `bindings.gyp`:\n\n```python\n  'cflags_cc': [ '-std=c++17' ],\n  'xcode_settings': { 'OTHER_CFLAGS': [ '-std=c++17'] },\n  'msvs_settings': {\n    'VCCLCompilerTool': {\n      'AdditionalOptions': [ '/std:c++17' ],\n    },\n  },\n```\n\n4. In source code:\n\n```c\n#include \u003ckizunapi.h\u003e\n```\n\n## Docs\n\n* [Tutorial](docs/tutorial.md)\n\n## Example\n\nThis example maps C++ classes with inheritance relationship to JavaScript\nusing non-intrusive APIs.\n\n```c++\n#include \u003ckizunapi.h\u003e\n\n// The classes to be exported to JavaScript.\nclass Parent {\n public:\n  int Year() const {\n    return 1989;\n  }\n};\n\nclass Child : public Parent {\n public:\n  Child(int month, int day) : month_(month), day_(day) {}\n\n  std::string Date() const {\n    return std::to_string(month_) + std::to_string(day_);\n  }\n\n private:\n  int month_;\n  int day_;\n};\n\n// Type information provided to kizunapi.\nnamespace ki {\n\ntemplate\u003c\u003e\nstruct Type\u003cParent\u003e {\n  static constexpr const char* name = \"Parent\";\n  static Parent* Constructor() {\n    return new Parent();\n  }\n  static void Destructor(Parent* ptr) {\n    delete ptr;\n  }\n  static void Define(napi_env env,\n                     napi_value constructor,\n                     napi_value prototype) {\n    Set(env, prototype, \"year\", \u0026Parent::Year);\n  }\n};\n\ntemplate\u003c\u003e\nstruct Type\u003cChild\u003e {\n  using Base = Parent;\n  static constexpr const char* name = \"Child\";\n  static Child* Constructor(int month, int day) {\n    return new Child(month, day);\n  }\n  static void Destructor(Child* ptr) {\n    delete ptr;\n  }\n  static void Define(napi_env env,\n                     napi_value constructor,\n                     napi_value prototype) {\n    Set(env, prototype, \"date\", \u0026Child::Date);\n  }\n};\n\n}  // namespace ki\n\n// Export the converted constructors to JavaScript.\nnapi_value Init(napi_env env, napi_value exports) {\n  ki::Set(env, exports,\n          \"Parent\", ki::Class\u003cParent\u003e(),\n          \"Child\", ki::Class\u003cChild\u003e());\n  return nullptr;\n}\n\nNAPI_MODULE(NODE_GYP_MODULE_NAME, Init);\n```\n\n## Contributing\n\nFor new features, it is recommended to start an issue first before creating a\npull request.\n\nGenerally I would encourage forking if you would like to add a feature that\nneeds over a thousand lines, because I don't really have much time maintaining\nthis project. But bug reports are very welcomed.\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyue%2Fkizunapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyue%2Fkizunapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyue%2Fkizunapi/lists"}