{"id":15497388,"url":"https://github.com/heapwolf/bale","last_synced_at":"2025-04-22T22:17:13.949Z","repository":{"id":21038240,"uuid":"24334975","full_name":"heapwolf/bale","owner":"heapwolf","description":"A transpiler/module system polyfill for C++","archived":false,"fork":false,"pushed_at":"2015-08-07T18:07:05.000Z","size":276,"stargazers_count":38,"open_issues_count":1,"forks_count":4,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-22T22:17:07.292Z","etag":null,"topics":[],"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/heapwolf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-22T15:49:04.000Z","updated_at":"2023-04-01T04:48:01.000Z","dependencies_parsed_at":"2022-09-13T22:42:20.440Z","dependency_job_id":null,"html_url":"https://github.com/heapwolf/bale","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fbale","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fbale/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fbale/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fbale/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heapwolf","download_url":"https://codeload.github.com/heapwolf/bale/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250331819,"owners_count":21413103,"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-10-02T08:33:19.136Z","updated_at":"2025-04-22T22:17:13.535Z","avatar_url":"https://github.com/heapwolf.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SYNOPSIS\nA transpiler/module system polyfill for `C++`.\n\n\n# MOTIVATION\nC++ does not have a real module system. One is in the works but in the\nmeanwhile, here is a future-compatible polyfill. Inspired by \n[`this`](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2073.pdf), \n[`this`](http://isocpp.org/files/papers/n4214.pdf), clang's \n[`experimental module implementation`](http://clang.llvm.org/docs/Modules.html)\nand the node.js [`module system`](http://nodejs.org/api/modules.html).\n\n\n# PROJECT STATUS\nExperimental. A work in progress.\n\n\n# EXAMPLE\nA modue is a discrete unit of code, encapsulated in a file. It exposes at \nleast one public value, function, class, etc. Let's use the following file \nstrcture as an example...\n\n```\nindex.cc\npizza.cc\ncheese.cc\ncc_modules/\n  serve/\n    index.cc\n```\n\n\n## ./INDEX.CC\n`index.cc` is the typical entry point for most programs.\n\n```cpp\n//\n// import the file \"pizza.cc\" as \"pizza\".\n//\nimport pizza \"./pizza.cc\";\n\n//\n// import the module \"serve\" as \"serve\".\n//\nimport serve \"serve\";\n\nint main() {\n  serve.plate(pizza.make());\n}\n```\nTo understand how the math `module` is imported, read \n[`this`](http://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders).\n\n\n## ./PIZZA.CC\nThe module imported by the code in `index.cc`.\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cmath.h\u003e\n\n//\n// GLOBAL SCOPE\n//\n// Anything outside of export will be global, this will be \n// accessible from ANY file. you should not put anything here \n// unless you REALLY MEAN TO.\n//\n\nexport {\n\n  //\n  // MODULE SCOPE\n  //\n  // Variables defined here are implicitly private, they are\n  // not exported, this applies to varibles imported from other \n  // modules.\n  //\n  const double pi = M_PI;\n\n  //\n  // import the file \"./cheese.cc\" as \"chz\"\n  //\n  import chz \"./cheese.cc\";\n\n  //\n  // Variables found after the \"public:\" label are exported!\n  //\n  public:\n\n    int make(int qty) {\n      return qty * pi + chz.add(secret_sauce);\n    }\n\n  //\n  // You can switch back and forth between public and private\n  // by using the \"private:\" label.\n  //\n  private:\n    int secret_sauce = 42;\n}\n```\n\n\n## ./CHEESE.CC\nThis file happens to be included by `pizza.cc`.\n\n```cpp\nexport {\n  public:\n    int add(int i) {\n      return i*i;\n    }\n}\n```\n\n\n## ./CC_MODULES/SERVE/INDEX.CC\n```cpp\nexport {\n  public:\n    void plate(int pizza) {\n      cout \u003c\u003c pizza \u003c\u003c endl;\n    }\n}\n```\n\n\n# USAGE\n```bash\nbale ./test/input/index.cc\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheapwolf%2Fbale","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheapwolf%2Fbale","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheapwolf%2Fbale/lists"}