-
Notifications
You must be signed in to change notification settings - Fork 359
feat(xlang): fory schema idl and compiler #3106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98dd3df to
d86d20d
Compare
d86d20d to
89514f3
Compare
urlyy
approved these changes
Jan 20, 2026
3cd7925 to
0758d46
Compare
0758d46 to
508e135
Compare
19c570b to
146cddb
Compare
This was referenced Jan 20, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why?
Fory has lacked a schema-first Interface Definition Language (IDL) for cross-language serialization.
Currently, teams must manually craft type registration and cross-language models. This is Ok and perfered option if we are suign one language to build the system, since we can serialize domain object directly.
But it is error-prone when we have multiple languages due to the type system inconsistency and makes it difficult to guarantee consistent schemas, type IDs, and reference-tracking behavior across languages.
Users who want to migrate from Protocol Buffers to Fory for better performance, reference tracking, or polymorphism support had to manually define structs in every language.
This PR addresses this gap by introducing FDL (Fory Definition Language) - a native schema IDL specifically designed for Fory's cross-language serialization capabilities.
Key motivations:
What does this PR do?
1. FDL (Fory Definition Language) Specification
package,import,enum,messageoptional,ref,repeatedrepeated(list),map<K,V>reservednames/IDs for backward compatibilityoptions(protobuf-style and bracket-style)2. Compiler Frontend (Python-based)
fory_compiler/parser/lexer.py): Tokenizes FDL source filesfory_compiler/parser/parser.py): Parses tokens into ASTfory_compiler/parser/ast.py): Schema, Message, Enum, Field, Import, and type representations3. Multi-Language Code Generation
#[derive(Fory, ...)], registration function, nested type flatteningFORY_STRUCT,FORY_FIELD_INFO, registration helper, nested type support4. Compiler CLI & Build Integration
fory compilewith comprehensive options--java_out,--python_out,--go_out,--rust_out,--cpp_out-I/--proto_pathfor import resolutionpip install -e .withforyentrypoint5. C++ Improvements
FORY_PP_IS_EMPTY,FORY_PP_HAS_ARGSmacros for empty struct supportFORY_STRUCT_0variant to support structs with no fieldsFORY_STRUCTmacro to detect empty argument lists6. Integration Tests
integration_tests/idl_tests/7. Comprehensive Documentation
-Type System - Primitive types, collections, and mappings
Example FDL Schema
Related issues
Closes #3163 #3164 #3165 #3167 #3168 #3169 #3173 #3174 #3175 #3176 #3177
#1197
#1945
#3099
Does this PR introduce any user-facing change?
Yes, this PR introduces a new FDL compiler tool that can be installed via pip:
Does this PR introduce any public API change?
fory compileCLI commandDoes this PR introduce any binary protocol compatibility change?
Benchmark
N/A - This PR focuses on code generation tooling. The generated code uses existing Fory serialization APIs which have been benchmarked separately. The compiler itself is a build-time tool and does not impact runtime serialization performance.