{"id":16696724,"url":"https://github.com/atry/protoc-gen-haxe","last_synced_at":"2026-03-27T03:50:04.883Z","repository":{"id":142738108,"uuid":"11875605","full_name":"Atry/protoc-gen-haxe","owner":"Atry","description":"Protocol Buffers compiler and run-time library for Haxe","archived":false,"fork":false,"pushed_at":"2015-07-22T19:05:39.000Z","size":568,"stargazers_count":36,"open_issues_count":2,"forks_count":7,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-20T22:13:12.642Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Haxe","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/Atry.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":"2013-08-04T07:50:09.000Z","updated_at":"2024-07-03T13:17:07.000Z","dependencies_parsed_at":"2023-03-14T21:15:37.511Z","dependency_job_id":null,"html_url":"https://github.com/Atry/protoc-gen-haxe","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fprotoc-gen-haxe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fprotoc-gen-haxe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fprotoc-gen-haxe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atry%2Fprotoc-gen-haxe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atry","download_url":"https://codeload.github.com/Atry/protoc-gen-haxe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243515567,"owners_count":20303258,"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-12T17:44:40.046Z","updated_at":"2025-12-30T16:35:12.337Z","avatar_url":"https://github.com/Atry.png","language":"Haxe","funding_links":[],"categories":[],"sub_categories":[],"readme":"Warning: This project is obsolete, and only tested on Haxe 3.0.x branches. Looking for serialization solution in Haxe? Try [json-stream](https://github.com/qifun/json-stream)!\n\n---\n\nprotoc-gen-haxe\n===============\n\n**protoc-gen-haxe** is a Protocol Buffers implementation in [Haxe](http://www.haxe.org/).\n\n## Motive\n\nI am also the author of [protoc-gen-as3](https://code.google.com/p/protoc-gen-as3/),\nwhich is the best Protocol Buffers implementation in ActionScript 3.\nI rewritten these code because I want to try the Haxe way to generate code.\nThis table lists main difference between `protoc-gen-as` (or any other Protocol Buffers implementation) and `protoc-gen-haxe`:\n\n| | protoc-gen-as3 | protoc-gen-haxe |\n| ------------- | ------------- | ----- |\n| Cross-platform | No. It only runs in Adobe Flash Player or Adobe AIR. | Yes. `protoc-gen-haxe` can run in Flash Players, browsers, servers, and even in Haxe compiler macros. |\n| Run Time Type Information | Little, via native Flash API. | Yes. By parsing DescriptorProtoSet at runtime, users can access full information from `.proto` files. |\n| Mutable messages | Yes | Yes |\n| Readonly messages | No | Yes |\n| Will unused code be eliminated? | No | Yes. `protoc-gen-haxe` separate different features into different classes, unused codes can be easy eliminated by the Haxe compiler. |\n| Can users generate their custom code? | No. Users have to create another Protocol Buffers plugin. | Yes. Users can use `protoc-gen-haxe` API in Haxe macros. |\n| Self-hosting | No. `protoc-gen-as3`'s compiler is written in Java. | Yes. Both compiler and runtime library of `protoc-gen-haxe` are written in Haxe. Even [20% lines of source code](https://github.com/Atry/protoc-gen-haxe/tree/master/haxelib-release/com/dongxiguo/protobuf/compiler/bootstrap) are generated by `protoc-gen-haxe` itself! |\n| Is it a [protoc](https://code.google.com/p/protobuf/downloads/detail?name=protoc-2.5.0-win32.zip) plugin? | Yes. `protoc-gen-as3` compiler must be launched by Google's `protoc`. | No. `protoc-gen-haxe` can directly import binary format DescriptorProtoSet of `.proto` files. |\n\n## Installation\n\n 1. Download [protoc 2.5](https://code.google.com/p/protobuf/downloads/detail?name=protoc-2.5.0-win32.zip).\n 2. Download and install [Haxe 3](http://www.haxe.org/download).\n 3. ```haxelib install protoc-gen-haxe```\n\n## Usage\n\n### Step 1: Create `sample.proto`\n\n```\n// sample.proto\n\npackage samplePackage;\n\nmessage SampleMessage {\n  optional string sample_field = 1;\n}\n```\n\n### Step 2: Create `SampleMain.hx`\n\n```\n// SampleMain.hx\n\nimport sys.io.File;\nimport sys.FileSystem;\nimport com.dongxiguo.protobuf.binaryFormat.LimitableFileInput;\nimport samplePackage.SampleMessage_Builder;\nusing samplePackage.SampleMessage_Merger;\nusing samplePackage.SampleMessage_Writer;\n\nclass SampleMain {\n\n  static function save():Void\n  {\n    var builder = new SampleMessage_Builder();\n    builder.sampleField = \"Hello, World!\";\n    var output = File.write(\"sample.save\");\n    builder.writeTo(output);\n    output.close();\n  }\n\n  static function load():Void\n  {\n    var builder = new SampleMessage_Builder();\n    var input = File.read(\"sample.save\");\n    var pbInput = new LimitableFileInput(input, FileSystem.stat(\"sample.save\").size);\n    builder.mergeFrom(pbInput);\n    trace('builder.sample = ${builder.sampleField}');\n    input.close();\n  }\n\n  public static function main() {\n    save();\n    load();\n  }\n\n}\n```\n\n### Step 3: Convert `sample.proto` to binary format DescriptorProtoSet.\n\n```\nprotoc sample.proto --descriptor_set_out=sample.proto.bin\n```\n\n### Step 4: Run it!\n\n```\nhaxe -lib protoc-gen-haxe --macro \"com.dongxiguo.protobuf.commandLine.Importer.importDescroptorFileSet('sample.proto.bin')\" -x SampleMain.hx\n```\n\nNow you see your program created `sample.save` in Protocol Buffers format, and then loaded this file.\n\nYou may want to see which classes are genrated by `protoc-gen-haxe`.\nJust add `--gen-hx-classes` to your `haxe` command and look at the `hxclasses/` folder it generated .\n\n\n## Features\n\n * All basic types\n * Nested messages\n * Enumerations\n * Packed and non-packed repeated fields\n * Extensions\n * Unknown fields\n * Run-time type information of services, enums, messages, options, custom options...\n * Macro-time type information of services, enums, messages, options, custom options...\n\n### Missing features\n\n * Text format\n * Group (A deprecated feature since Protocol Buffers 2)\n\nI would like to see somebody's contribution for these missing features.\n\n## Requirement\n\n * Haxe 3.x\n * Protocol Buffers 2.x\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatry%2Fprotoc-gen-haxe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatry%2Fprotoc-gen-haxe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatry%2Fprotoc-gen-haxe/lists"}