├── cs ├── nuget │ ├── empty │ └── .dir-locals.el ├── build │ ├── internal │ │ ├── bond.snk │ │ └── DevVersions.cs │ └── nuget │ │ ├── Bond.CSharp.props │ │ ├── Bond.Compiler.CSharp.props │ │ ├── Bond.CSharp.targets │ │ ├── Bond.Compiler.CSharp.targets │ │ └── cps │ │ └── ProjectItemsSchema.xaml ├── test │ ├── codegen │ │ ├── no-warnings │ │ │ └── simple.bond │ │ ├── output-no-slash │ │ │ └── simple.bond │ │ └── default-ignore-output │ │ │ ├── simple.bond │ │ │ ├── bin │ │ │ └── should-not-be-compiled.bond │ │ │ ├── obj │ │ │ ├── should-not-be-compiled.bond │ │ │ ├── debug │ │ │ │ └── netstandard1.0 │ │ │ │ │ └── should-not-be-compiled.bond │ │ │ └── retail │ │ │ │ └── netstandard1.0 │ │ │ │ └── should-not-be-compiled.bond │ │ │ ├── README.md │ │ │ ├── ConsumeCodegen.cs │ │ │ └── default-ignore-output.csproj │ ├── core │ │ ├── import dir with spaces │ │ │ └── dir1 │ │ │ │ └── dir2 │ │ │ │ └── Bond File With Spaces.bond │ │ ├── Partial.cs │ │ ├── NamespaceConflictBond.bond │ │ ├── Containers.bond │ │ ├── ReadOnly.bond │ │ ├── NamespaceConflict.bond │ │ ├── ImmutableCollections.bond │ │ ├── XmlSerializationTests.cs │ │ └── JsonSerializationTests.cs │ └── internal │ │ └── RequiredFieldsTest.cs ├── .gitignore └── src │ ├── io │ ├── properties │ │ └── AssemblyInfo.cs │ └── IO.csproj │ ├── json │ ├── properties │ │ └── AssemblyInfo.cs │ └── protocols │ │ └── IJsonReader.cs │ ├── core │ ├── expressions │ │ └── ISerializerGenerator.cs │ ├── io │ │ └── ICloneable.cs │ ├── protocols │ │ └── Exceptions.cs │ └── ISchemaField.cs │ ├── attributes │ └── Attributes.csproj │ └── reflection │ └── reflection.csproj ├── cpp ├── .gitignore ├── test │ ├── core │ │ ├── security.h │ │ ├── cmdargs.h │ │ ├── apply_tests.h │ │ ├── basic_tests.h │ │ ├── json_tests.h │ │ ├── maybe_tests.h │ │ ├── bonded_tests.h │ │ ├── exception_tests.h │ │ ├── metadata_tests.h │ │ ├── protocol_test.h │ │ ├── validate_tests.h │ │ ├── mafia_compat_tests.h │ │ ├── skip_tests.h │ │ ├── scope_test1.bond │ │ ├── security.bond │ │ ├── imports │ │ │ └── dir1 │ │ │ │ └── dir2 │ │ │ │ └── import_test2.bond │ │ ├── scope_test2.bond │ │ ├── import_test1.bond │ │ ├── unit_test_limits.h │ │ ├── precompiled.h │ │ └── main.cpp │ ├── CMakeLists.txt │ └── compat │ │ └── core │ │ └── compat.h ├── inc │ └── bond │ │ ├── core │ │ ├── containers.h │ │ ├── customize.h │ │ ├── detail │ │ │ ├── nonassignable.h │ │ │ ├── value_extern.h │ │ │ └── once.h │ │ ├── box.h │ │ ├── scalar_interface.h │ │ ├── cmdargs.h │ │ └── select_protocol_fwd.h │ │ ├── protocol │ │ └── detail │ │ │ └── rapidjson_utils.h │ │ └── ext │ │ └── capped_allocator_fwd.h └── src │ └── bond │ ├── protocol │ └── detail │ │ └── rapidjson_utils.cpp │ └── core │ ├── value.cpp │ └── select_protocol.cpp ├── java ├── core │ ├── .idea │ │ ├── .name │ │ ├── encodings.xml │ │ ├── dictionaries │ │ │ └── bond.xml │ │ ├── vcs.xml │ │ ├── modules.xml │ │ ├── compiler.xml │ │ └── gradle.xml │ ├── src │ │ ├── test │ │ │ ├── resources │ │ │ │ └── alphabet.txt │ │ │ └── bond │ │ │ │ ├── bonded.bond │ │ │ │ ├── imports │ │ │ │ └── dir1 │ │ │ │ │ └── dir2 │ │ │ │ │ └── common.bond │ │ │ │ └── equality.bond │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── bondlib │ │ │ ├── TwoPassProtocolWriter.java │ │ │ ├── BondSerializable.java │ │ │ ├── StructMetadata.java │ │ │ ├── InvalidBondDataException.java │ │ │ └── StreamNotCloneableException.java │ ├── settings.gradle │ └── CMakeLists.txt ├── gradle-plugin │ ├── .idea │ │ ├── .name │ │ ├── encodings.xml │ │ ├── vcs.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ ├── compiler.xml │ │ └── gradle.xml │ ├── settings.gradle │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── gradle-plugins │ │ │ │ └── org.bondlib.gradle.properties │ │ │ └── groovy │ │ │ └── org │ │ │ └── bondlib │ │ │ └── gradle │ │ │ ├── BondPlugin.groovy │ │ │ ├── BondProdCodegen.groovy │ │ │ └── BondTestCodegen.groovy │ ├── CMakeLists.txt │ └── README.md ├── compat │ ├── settings.gradle │ ├── .idea │ │ ├── encodings.xml │ │ ├── vcs.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ ├── compiler.xml │ │ └── gradle.xml │ └── CMakeLists.txt ├── json │ ├── settings.gradle │ └── .idea │ │ ├── vcs.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ ├── compiler.xml │ │ └── gradle.xml ├── .gitignore └── CMakeLists.txt ├── compiler ├── tests │ ├── generated │ │ ├── empty_concatenated.java │ │ ├── empty_types.cpp │ │ ├── generics_types.cpp │ │ ├── alloc_ctors │ │ │ ├── empty_types.cpp │ │ │ ├── generics_types.cpp │ │ │ ├── empty_reflection.h │ │ │ ├── import_types.cpp │ │ │ ├── maybe_blob_types.cpp │ │ │ ├── alias_key_types.cpp │ │ │ ├── empty_types.h │ │ │ ├── inheritance_types.cpp │ │ │ ├── bond_meta_types.cpp │ │ │ └── field_modifiers_types.cpp │ │ ├── allocator │ │ │ ├── empty_types.cpp │ │ │ ├── generics_types.cpp │ │ │ ├── empty_reflection.h │ │ │ ├── maybe_blob_types.cpp │ │ │ ├── import_types.cpp │ │ │ ├── alias_key_types.cpp │ │ │ ├── empty_types.h │ │ │ ├── inheritance_types.cpp │ │ │ ├── bond_meta_types.cpp │ │ │ └── field_modifiers_types.cpp │ │ ├── scoped_allocator │ │ │ ├── empty_types.cpp │ │ │ ├── generics_types.cpp │ │ │ ├── empty_reflection.h │ │ │ ├── import_types.cpp │ │ │ ├── maybe_blob_types.cpp │ │ │ ├── alias_key_types.cpp │ │ │ ├── empty_types.h │ │ │ ├── inheritance_types.cpp │ │ │ ├── bond_meta_types.cpp │ │ │ └── field_modifiers_types.cpp │ │ ├── type_aliases │ │ │ ├── empty_types.cpp │ │ │ ├── generics_types.cpp │ │ │ ├── empty_reflection.h │ │ │ ├── import_types.cpp │ │ │ ├── maybe_blob_types.cpp │ │ │ ├── alias_key_types.cpp │ │ │ ├── empty_types.h │ │ │ ├── inheritance_types.cpp │ │ │ ├── bond_meta_types.cpp │ │ │ └── field_modifiers_types.cpp │ │ ├── empty_reflection.h │ │ ├── maybe_blob_types.cpp │ │ ├── import_types.cpp │ │ ├── alias_key_types.cpp │ │ ├── schemadef │ │ │ ├── example.SomeStruct.json │ │ │ ├── maybe_blob.Foo.json │ │ │ ├── attributes.Foo.json │ │ │ ├── nullable_alias.foo.json │ │ │ ├── field_modifiers.Foo.json │ │ │ └── inheritance.Foo.json │ │ ├── empty_types.cs │ │ ├── collection-interfaces │ │ │ └── empty_types.cs │ │ ├── empty_types.h │ │ ├── inheritance_types.cpp │ │ ├── bond_meta_types.cpp │ │ ├── constructor-parameters │ │ │ ├── empty_struct_types.cs │ │ │ └── collection-interfaces │ │ │ │ └── empty_struct_types.cs │ │ └── field_modifiers_types.cpp │ ├── schema │ │ ├── empty.bond │ │ ├── empty_struct.bond │ │ ├── empty.json │ │ ├── imports │ │ │ └── dir1 │ │ │ │ └── dir2 │ │ │ │ └── empty.bond │ │ ├── maybe_blob.bond │ │ ├── example.bond │ │ ├── namespace_basic_types.bond │ │ ├── generics.bond │ │ ├── inheritance.bond │ │ ├── field_modifiers.bond │ │ ├── bond_meta.bond │ │ ├── alias_key.bond │ │ ├── error │ │ │ ├── int_out_of_range.bond │ │ │ ├── service_invalid_base_type_param.bond │ │ │ ├── aliases_default.bond │ │ │ ├── service_invalid_base_struct.bond │ │ │ ├── struct_nothing.bond │ │ │ ├── enum_no_default.bond │ │ │ └── duplicate_service_method.bond │ │ ├── nullable_alias.bond │ │ ├── metadata_edge_cases.bond │ │ ├── import.bond │ │ ├── service_attributes.bond │ │ ├── service_inheritance.bond │ │ ├── attributes.bond │ │ ├── generic_service.bond │ │ ├── complex_types.bond │ │ ├── aliases.bond │ │ ├── basic_types.bond │ │ ├── basic_types_nsmapped.bond │ │ ├── bond_meta.json │ │ ├── field_modifiers.json │ │ ├── custom_alias_with_allocator.bond │ │ ├── custom_alias_without_allocator.bond │ │ ├── immutable_collections.bond │ │ ├── alias_with_allocator.bond │ │ ├── attributes.json │ │ ├── schemadef.bond │ │ ├── streaming.bond │ │ ├── example.json │ │ ├── inheritance.json │ │ └── complex_inheritance.bond │ ├── .gitignore │ ├── .gitattributes │ └── Tests │ │ └── Codegen │ │ └── Util.hs ├── .gitignore ├── Setup.hs └── stack.yaml.lock ├── doc ├── .gitignore ├── .pandoc │ └── templates │ │ └── cmdargs.html ├── src │ ├── logos │ │ ├── bond-logo-64x64-white.png │ │ ├── bond-logo-743x543-white.png │ │ ├── bond-logo-743x743-white.png │ │ ├── bond-logo-64x64-transparent.png │ │ ├── bond-logo-743x543-transparent.png │ │ └── bond-logo-743x743-transparent.png │ └── reference_index.md └── doxygen │ ├── bond_reference.css │ └── doxygen.cmake ├── python ├── CMakeLists.txt └── test │ ├── CMakeLists.txt │ ├── compat │ ├── compat.cpp │ └── compat.cmake │ └── core │ ├── CMakeLists.txt │ └── unit_test.cpp ├── tools ├── ci-scripts │ └── linux │ │ ├── image-cleanup │ │ ├── .pylintrc │ │ ├── collector │ │ │ ├── __init__.py │ │ │ └── config.py │ │ ├── .gitignore │ │ └── mypy.ini │ │ ├── build_cpp-core.zsh │ │ ├── build_cpp-common.zsh │ │ └── build_hs.zsh └── syntax │ ├── SublimeText3 │ └── Readme.md │ ├── Notepad-plus-plus │ └── README.md │ └── VsCode │ ├── .vscode │ └── launch.json │ ├── bond.configuration.json │ ├── package.json │ └── README.md ├── examples ├── python │ ├── core │ │ ├── CMakeLists.txt │ │ └── extension │ │ │ ├── extension.bond │ │ │ ├── CMakeLists.txt │ │ │ └── extension.cpp │ └── CMakeLists.txt ├── cpp │ ├── core │ │ ├── trace │ │ │ └── CMakeLists.txt │ │ ├── variadic │ │ │ └── CMakeLists.txt │ │ ├── merge │ │ │ ├── CMakeLists.txt │ │ │ └── merge.bond │ │ ├── import │ │ │ ├── CMakeLists.txt │ │ │ └── import.bond │ │ ├── generics │ │ │ ├── CMakeLists.txt │ │ │ ├── generics.bond │ │ │ └── generics.cpp │ │ ├── transform │ │ │ ├── CMakeLists.txt │ │ │ └── transform.bond │ │ ├── attributes │ │ │ ├── CMakeLists.txt │ │ │ └── attributes.bond │ │ ├── marshaling │ │ │ ├── CMakeLists.txt │ │ │ └── marshaling.bond │ │ ├── generic_tree │ │ │ ├── CMakeLists.txt │ │ │ └── generic_tree.bond │ │ ├── inheritance │ │ │ ├── CMakeLists.txt │ │ │ └── inheritance.bond │ │ ├── schema_view │ │ │ ├── CMakeLists.txt │ │ │ ├── schema_view.bond │ │ │ └── schema_view.cpp │ │ ├── simple_json │ │ │ ├── CMakeLists.txt │ │ │ └── simple_json.bond │ │ ├── serialization │ │ │ ├── CMakeLists.txt │ │ │ └── serialization.bond │ │ ├── access_control │ │ │ ├── CMakeLists.txt │ │ │ └── access_control.bond │ │ ├── move_semantics │ │ │ ├── CMakeLists.txt │ │ │ └── move_semantics.bond │ │ ├── runtime_schema │ │ │ ├── CMakeLists.txt │ │ │ └── runtime_schema.bond │ │ ├── nothing_default │ │ │ ├── CMakeLists.txt │ │ │ └── nothing_default.bond │ │ ├── runtime_binding │ │ │ ├── CMakeLists.txt │ │ │ └── runtime_binding.bond │ │ ├── protocol_versions │ │ │ ├── CMakeLists.txt │ │ │ └── protocol_versions.bond │ │ ├── record_streaming │ │ │ ├── CMakeLists.txt │ │ │ └── record_streaming.bond │ │ ├── compile_time_schema │ │ │ ├── CMakeLists.txt │ │ │ └── compile_time_schema.bond │ │ ├── modifying_transform │ │ │ ├── CMakeLists.txt │ │ │ └── modifying_transform.bond │ │ ├── protocol_transcoding │ │ │ ├── CMakeLists.txt │ │ │ └── protocol_transcoding.bond │ │ ├── polymorphic_container │ │ │ ├── CMakeLists.txt │ │ │ └── polymorphic_container.bond │ │ ├── output_stream_allocator │ │ │ ├── CMakeLists.txt │ │ │ └── output_stream_allocator.bond │ │ ├── polymorphic_container_visitor │ │ │ ├── CMakeLists.txt │ │ │ └── polymorphic_container_visitor.bond │ │ ├── string_ref │ │ │ ├── string_ref.bond │ │ │ └── CMakeLists.txt │ │ ├── time_alias │ │ │ ├── time_alias.bond │ │ │ └── CMakeLists.txt │ │ ├── enumerations │ │ │ ├── CMakeLists.txt │ │ │ └── enumerations.bond │ │ ├── container_of_pointers │ │ │ ├── container_of_pointers.bond │ │ │ └── CMakeLists.txt │ │ ├── dll │ │ │ ├── dllexample_dynlink.h │ │ │ └── dll.bond │ │ ├── scoped_allocator │ │ │ ├── scoped_alloc.bond │ │ │ └── CMakeLists.txt │ │ ├── static_library │ │ │ ├── lib │ │ │ │ └── static_library.bond │ │ │ └── CMakeLists.txt │ │ ├── capped_allocator │ │ │ ├── capped_allocator.bond │ │ │ └── CMakeLists.txt │ │ ├── static_array │ │ │ ├── CMakeLists.txt │ │ │ ├── static_array.bond │ │ │ └── static_array.cpp │ │ ├── multiprecision │ │ │ ├── multiprecision.bond │ │ │ └── CMakeLists.txt │ │ └── bf │ │ │ └── bf_test.cmake │ └── CMakeLists.txt ├── CMakeLists.txt ├── codegen │ └── read-only │ │ ├── .gitignore │ │ └── rocs.cabal ├── java │ ├── .gitignore │ └── core │ │ ├── imports │ │ └── src │ │ │ └── main │ │ │ └── bond │ │ │ ├── common │ │ │ ├── common.bond │ │ │ └── protocol │ │ │ │ └── header.bond │ │ │ └── schema.bond │ │ ├── record_streaming │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── record_streaming.bond │ │ └── build.gradle │ │ ├── blob │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── schema.bond │ │ └── build.gradle │ │ ├── serialization │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── serialization.bond │ │ └── build.gradle │ │ ├── protocol_versions │ │ └── src │ │ │ └── main │ │ │ └── bond │ │ │ └── protocol_versions.bond │ │ ├── inheritance │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── inheritance.bond │ │ └── build.gradle │ │ ├── generics │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── generics.bond │ │ └── build.gradle │ │ ├── untagged_protocols │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── schema.bond │ │ └── build.gradle │ │ ├── runtime_schema │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── schema.bond │ │ └── build.gradle │ │ ├── enumerations │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── enumerations.bond │ │ └── build.gradle │ │ ├── nothing_default │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── nothing_default.bond │ │ └── build.gradle │ │ ├── schema_view │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── schema_view.bond │ │ └── build.gradle │ │ ├── generic_tree │ │ ├── src │ │ │ └── main │ │ │ │ └── bond │ │ │ │ └── generic_tree.bond │ │ └── build.gradle │ │ └── polymorphic_container │ │ ├── src │ │ └── main │ │ │ └── bond │ │ │ └── schema.bond │ │ └── build.gradle └── cs │ ├── core │ ├── import │ │ ├── common │ │ │ ├── common.bond │ │ │ └── protocol │ │ │ │ └── header.bond │ │ └── schema.bond │ ├── stream │ │ └── schema.bond │ ├── marshaling │ │ └── schema.bond │ ├── serializer │ │ └── schema.bond │ ├── simple_json │ │ └── schema.bond │ ├── simple_xml │ │ └── schema.bond │ ├── record_streaming │ │ └── record_streaming.bond │ ├── decimal │ │ └── schema.bond │ ├── date_time │ │ └── schema.bond │ ├── serialization │ │ └── schema.bond │ ├── blob │ │ └── schema.bond │ ├── container_alias │ │ └── schema.bond │ ├── protocol_versions │ │ └── protocol_versions.bond │ ├── protocol_transcoding │ │ └── schema.bond │ ├── inheritance │ │ └── inheritance.bond │ ├── untagged_protocols │ │ └── schema.bond │ ├── generics │ │ └── schema.bond │ ├── cloning │ │ └── schema.bond │ ├── runtime_schema │ │ └── schema.bond │ ├── guid │ │ └── schema.bond │ ├── enumerations │ │ ├── enumerations.bond │ │ └── program.cs │ ├── nothing_default │ │ └── nothing_default.bond │ ├── schema_view │ │ └── schema_view.bond │ ├── polymorphic_container │ │ └── schema.bond │ ├── generic_tree │ │ └── generic_tree.bond │ └── immutable_collections │ │ └── schema.bond │ └── .gitignore ├── test └── compat │ └── core │ ├── data │ ├── compat.fast.dat │ ├── compat.schema.dat │ ├── compat.simple.dat │ ├── compat.compact.dat │ ├── compat.compact2.dat │ └── compat.simple2.dat │ └── schemas │ ├── compat2.bond │ └── compat_no_generics.bond ├── .gitmodules ├── cmake ├── RunPythonTest.cmake ├── FindJavaBuildTools.cmake ├── NoDebug.cmake ├── FindStack.cmake ├── Folders.cmake └── Compiler.cmake ├── .gitignore ├── SECURITY.md ├── CONTRIBUTING.md └── NuGet.Config /cs/nuget/empty: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cpp/.gitignore: -------------------------------------------------------------------------------- 1 | generated 2 | -------------------------------------------------------------------------------- /java/core/.idea/.name: -------------------------------------------------------------------------------- 1 | bond -------------------------------------------------------------------------------- /java/gradle-plugin/.idea/.name: -------------------------------------------------------------------------------- 1 | bond-gradle -------------------------------------------------------------------------------- /compiler/tests/generated/empty_concatenated.java: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | # generated html 2 | html 3 | -------------------------------------------------------------------------------- /compiler/tests/schema/empty.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | -------------------------------------------------------------------------------- /python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory (test) 2 | -------------------------------------------------------------------------------- /tools/ci-scripts/linux/image-cleanup/.pylintrc: -------------------------------------------------------------------------------- 1 | [BASIC] 2 | -------------------------------------------------------------------------------- /tools/ci-scripts/linux/image-cleanup/collector/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/python/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory (extension) 2 | -------------------------------------------------------------------------------- /java/compat/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'compat' 2 | 3 | -------------------------------------------------------------------------------- /java/core/src/test/resources/alphabet.txt: -------------------------------------------------------------------------------- 1 | ABCDEFGHIJKLMNOPQRSTUVWXYZ -------------------------------------------------------------------------------- /java/json/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'bond-json' 2 | 3 | -------------------------------------------------------------------------------- /java/gradle-plugin/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'bond-gradle' 2 | -------------------------------------------------------------------------------- /examples/cpp/core/trace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (trace trace.cpp) 2 | -------------------------------------------------------------------------------- /examples/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subfolder (core "examples/python/core") 2 | -------------------------------------------------------------------------------- /examples/cpp/core/variadic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (variadic variadic.cpp) 2 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory (cpp) 2 | add_python_subdirectory (python) 3 | -------------------------------------------------------------------------------- /examples/cpp/core/merge/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (merge merge.bond merge.cpp) 2 | -------------------------------------------------------------------------------- /compiler/tests/schema/empty_struct.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct Empty 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp/core/import/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (import import.bond import.cpp) 2 | -------------------------------------------------------------------------------- /compiler/tests/schema/empty.json: -------------------------------------------------------------------------------- 1 | {"namespaces":[{"name":["tests"]}],"imports":[],"declarations":[]} -------------------------------------------------------------------------------- /compiler/tests/schema/imports/dir1/dir2/empty.bond: -------------------------------------------------------------------------------- 1 | namespace empty 2 | 3 | struct Empty { } 4 | -------------------------------------------------------------------------------- /examples/cpp/core/generics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (generics generics.bond generics.cpp) 2 | -------------------------------------------------------------------------------- /cs/build/internal/bond.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/cs/build/internal/bond.snk -------------------------------------------------------------------------------- /examples/cpp/core/transform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (transform transform.bond transform.cpp) 2 | -------------------------------------------------------------------------------- /examples/cpp/core/attributes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (attributes attributes.bond attributes.cpp) 2 | -------------------------------------------------------------------------------- /examples/cpp/core/marshaling/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (marshaling marshaling.bond marshaling.cpp) 2 | -------------------------------------------------------------------------------- /cpp/test/core/security.h: -------------------------------------------------------------------------------- 1 | 2 | class SecurityTest 3 | { 4 | public: 5 | static void Initialize(); 6 | }; 7 | -------------------------------------------------------------------------------- /examples/cpp/core/generic_tree/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (generic_tree generic_tree.bond generic_tree.cpp) 2 | -------------------------------------------------------------------------------- /examples/cpp/core/inheritance/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (inheritance inheritance.bond inheritance.cpp) 2 | -------------------------------------------------------------------------------- /examples/cpp/core/schema_view/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (schema_view schema_view.bond schema_view.cpp) 2 | -------------------------------------------------------------------------------- /examples/cpp/core/simple_json/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (simple_json simple_json.bond simple_json.cpp) 2 | -------------------------------------------------------------------------------- /compiler/tests/schema/maybe_blob.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct Foo 4 | { 5 | 0: blob b = nothing; 6 | } 7 | -------------------------------------------------------------------------------- /doc/.pandoc/templates/cmdargs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /examples/codegen/read-only/.gitignore: -------------------------------------------------------------------------------- 1 | # Cabal build artifacts 2 | dist 3 | .cabal-sandbox 4 | cabal.sandbox.config 5 | -------------------------------------------------------------------------------- /examples/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT BOND_SKIP_CORE_TESTS) 2 | add_subfolder (core "examples/core") 3 | endif() 4 | -------------------------------------------------------------------------------- /examples/cpp/core/serialization/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (serialization serialization.bond serialization.cpp) 2 | -------------------------------------------------------------------------------- /compiler/.gitignore: -------------------------------------------------------------------------------- 1 | # Cabal build artifacts 2 | dist/ 3 | .cabal-sandbox/ 4 | cabal.sandbox.config 5 | .stack-work/ 6 | -------------------------------------------------------------------------------- /cpp/test/core/cmdargs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CmdArgs 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | -------------------------------------------------------------------------------- /examples/cpp/core/access_control/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (access_control access_control.bond access_control.cpp) 2 | -------------------------------------------------------------------------------- /examples/cpp/core/move_semantics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (move_semantics move_semantics.bond move_semantics.cpp) 2 | -------------------------------------------------------------------------------- /examples/cpp/core/runtime_schema/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (runtime_schema runtime_schema.bond runtime_schema.cpp) 2 | -------------------------------------------------------------------------------- /tools/ci-scripts/linux/build_cpp-core.zsh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | set -eux 4 | source "$BUILD_SCRIPTS/build_cpp-common.zsh" 5 | -------------------------------------------------------------------------------- /tools/ci-scripts/linux/image-cleanup/.gitignore: -------------------------------------------------------------------------------- 1 | # Python pre-compiled stuff 2 | .mypy_cache/ 3 | __pycache__/ 4 | *.pyc 5 | -------------------------------------------------------------------------------- /compiler/Setup.hs: -------------------------------------------------------------------------------- 1 | module Main (main) where 2 | 3 | import Distribution.Simple 4 | 5 | main :: IO () 6 | main = defaultMain 7 | -------------------------------------------------------------------------------- /cpp/test/core/apply_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ApplyTest 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | -------------------------------------------------------------------------------- /cpp/test/core/basic_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class BasicTest 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | -------------------------------------------------------------------------------- /cpp/test/core/json_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class JSONTest 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | -------------------------------------------------------------------------------- /cpp/test/core/maybe_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class MaybeTest 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | -------------------------------------------------------------------------------- /doc/src/logos/bond-logo-64x64-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/doc/src/logos/bond-logo-64x64-white.png -------------------------------------------------------------------------------- /examples/cpp/core/nothing_default/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (nothing_default nothing_default.bond nothing_default.cpp) 2 | -------------------------------------------------------------------------------- /examples/cpp/core/runtime_binding/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (runtime_binding runtime_binding.bond runtime_binding.cpp) 2 | -------------------------------------------------------------------------------- /test/compat/core/data/compat.fast.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/test/compat/core/data/compat.fast.dat -------------------------------------------------------------------------------- /test/compat/core/data/compat.schema.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/test/compat/core/data/compat.schema.dat -------------------------------------------------------------------------------- /test/compat/core/data/compat.simple.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/test/compat/core/data/compat.simple.dat -------------------------------------------------------------------------------- /cpp/test/core/bonded_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class BondedTest 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | -------------------------------------------------------------------------------- /doc/src/logos/bond-logo-743x543-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/doc/src/logos/bond-logo-743x543-white.png -------------------------------------------------------------------------------- /doc/src/logos/bond-logo-743x743-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/doc/src/logos/bond-logo-743x743-white.png -------------------------------------------------------------------------------- /examples/cpp/core/protocol_versions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (protocol_versions protocol_versions.bond protocol_versions.cpp) 2 | -------------------------------------------------------------------------------- /examples/cpp/core/record_streaming/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (record_streaming record_streaming.bond record_streaming.cpp) 2 | -------------------------------------------------------------------------------- /test/compat/core/data/compat.compact.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/test/compat/core/data/compat.compact.dat -------------------------------------------------------------------------------- /test/compat/core/data/compat.compact2.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/test/compat/core/data/compat.compact2.dat -------------------------------------------------------------------------------- /test/compat/core/data/compat.simple2.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/test/compat/core/data/compat.simple2.dat -------------------------------------------------------------------------------- /compiler/tests/schema/example.bond: -------------------------------------------------------------------------------- 1 | namespace example.some 2 | 3 | struct SomeStruct 4 | { 5 | 0: int32 someField = 123; 6 | } 7 | -------------------------------------------------------------------------------- /compiler/tests/schema/namespace_basic_types.bond: -------------------------------------------------------------------------------- 1 | namespace tests2 2 | 3 | struct OtherBasicTypes 4 | { 5 | 0: bool _bool; 6 | } 7 | -------------------------------------------------------------------------------- /cpp/test/core/exception_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ExceptionTest 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | -------------------------------------------------------------------------------- /cpp/test/core/metadata_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class MetadataTest 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | -------------------------------------------------------------------------------- /cpp/test/core/protocol_test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ProtocolTest 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /cpp/test/core/validate_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class ValidateTest 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "thirdparty/rapidjson"] 2 | path = thirdparty/rapidjson 3 | url = https://github.com/Tencent/rapidjson.git 4 | -------------------------------------------------------------------------------- /cs/test/codegen/no-warnings/simple.bond: -------------------------------------------------------------------------------- 1 | namespace CodegenTest.NoWarnings; 2 | 3 | struct SimpleType 4 | { 5 | 0: int32 _int32; 6 | } 7 | -------------------------------------------------------------------------------- /doc/src/logos/bond-logo-64x64-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/doc/src/logos/bond-logo-64x64-transparent.png -------------------------------------------------------------------------------- /examples/cpp/core/compile_time_schema/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (compile_time_schema compile_time_schema.bond compile_time_schema.cpp) 2 | -------------------------------------------------------------------------------- /examples/cpp/core/modifying_transform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (modifying_transform modifying_transform.bond modifying_transform.cpp) 2 | -------------------------------------------------------------------------------- /compiler/tests/.gitignore: -------------------------------------------------------------------------------- 1 | generated/*_apply.* 2 | generated/allocator/*_apply.* 3 | generated/apply/*_types.* 4 | generated/apply/*_reflection.* 5 | -------------------------------------------------------------------------------- /cpp/test/core/mafia_compat_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class MafiaCompatTest 4 | { 5 | public: 6 | static void Initialize(); 7 | }; 8 | 9 | -------------------------------------------------------------------------------- /cs/test/codegen/output-no-slash/simple.bond: -------------------------------------------------------------------------------- 1 | namespace CodegenTest.OutputNoSlash; 2 | 3 | struct SimpleType 4 | { 5 | 0: int32 _int32; 6 | } 7 | -------------------------------------------------------------------------------- /cs/test/core/import dir with spaces/dir1/dir2/Bond File With Spaces.bond: -------------------------------------------------------------------------------- 1 | namespace UnitTest 2 | 3 | struct EnsureSpacesInPathsWork 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /doc/src/logos/bond-logo-743x543-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/doc/src/logos/bond-logo-743x543-transparent.png -------------------------------------------------------------------------------- /doc/src/logos/bond-logo-743x743-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/bond/HEAD/doc/src/logos/bond-logo-743x743-transparent.png -------------------------------------------------------------------------------- /examples/cpp/core/protocol_transcoding/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (protocol_transcoding protocol_transcoding.bond protocol_transcoding.cpp) 2 | -------------------------------------------------------------------------------- /examples/java/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | build/ 3 | 4 | .gradle/ 5 | gradle/ 6 | gradlew 7 | gradlew.bat 8 | 9 | *.iml 10 | .idea/ 11 | out/ 12 | -------------------------------------------------------------------------------- /java/gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.bondlib.gradle.properties: -------------------------------------------------------------------------------- 1 | implementation-class = org.bondlib.gradle.BondPlugin 2 | -------------------------------------------------------------------------------- /examples/cpp/core/polymorphic_container/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (polymorphic_container polymorphic_container.bond polymorphic_container.cpp) 2 | -------------------------------------------------------------------------------- /examples/cs/core/import/common/common.bond: -------------------------------------------------------------------------------- 1 | namespace Examples.Common 2 | 3 | enum Priority 4 | { 5 | Low; 6 | Normal; 7 | High; 8 | } 9 | -------------------------------------------------------------------------------- /examples/cpp/core/output_stream_allocator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (output_stream_allocator output_stream_allocator.bond output_stream_allocator.cpp) 2 | -------------------------------------------------------------------------------- /examples/cs/core/stream/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Example 4 | { 5 | 0: string Name; 6 | 1: vector Constants; 7 | } 8 | -------------------------------------------------------------------------------- /compiler/tests/schema/generics.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct Foo 4 | { 5 | 0: T2 t2; 6 | 1: nullable> n; 7 | } 8 | -------------------------------------------------------------------------------- /cs/test/codegen/default-ignore-output/simple.bond: -------------------------------------------------------------------------------- 1 | namespace CodegenTest.DefaultIgnoresOutput; 2 | 3 | struct SimpleType 4 | { 5 | 0: int32 _int32; 6 | } 7 | -------------------------------------------------------------------------------- /examples/cs/core/marshaling/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Example 4 | { 5 | 0: string Name; 6 | 1: vector Constants; 7 | } 8 | -------------------------------------------------------------------------------- /examples/cs/core/serializer/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Example 4 | { 5 | 0: string Name; 6 | 1: vector Constants; 7 | } 8 | -------------------------------------------------------------------------------- /examples/java/core/imports/src/main/bond/common/common.bond: -------------------------------------------------------------------------------- 1 | namespace Examples.Common 2 | 3 | enum Priority 4 | { 5 | Low; 6 | Normal; 7 | High; 8 | } 9 | -------------------------------------------------------------------------------- /examples/cpp/core/import/import.bond: -------------------------------------------------------------------------------- 1 | import "bond/core/bond.bond" 2 | 3 | namespace examples.imports 4 | 5 | struct Struct 6 | { 7 | 0: bond.TypeDef type; 8 | } 9 | -------------------------------------------------------------------------------- /compiler/tests/generated/empty_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "empty_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | } // namespace tests 9 | -------------------------------------------------------------------------------- /compiler/tests/schema/inheritance.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct Base 4 | { 5 | 0: int32 x; 6 | } 7 | 8 | struct Foo : Base 9 | { 10 | 0: int32 x; 11 | } 12 | -------------------------------------------------------------------------------- /examples/cpp/core/polymorphic_container_visitor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_test (polymorphic_container_visitor polymorphic_container_visitor.bond polymorphic_container_visitor.cpp) 2 | -------------------------------------------------------------------------------- /examples/cs/core/import/common/protocol/header.bond: -------------------------------------------------------------------------------- 1 | namespace Examples.Common.Protocol 2 | 3 | struct Header 4 | { 5 | 0: string Origin; 6 | 1: string Destination; 7 | } 8 | -------------------------------------------------------------------------------- /examples/cs/core/simple_json/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Config 4 | { 5 | 0: string Variant; 6 | 1: bool Enabled; 7 | 3: vector Urls; 8 | } 9 | -------------------------------------------------------------------------------- /examples/cs/core/simple_xml/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Config 4 | { 5 | 0: string Variant; 6 | 1: bool Enabled; 7 | 3: vector Urls; 8 | } 9 | -------------------------------------------------------------------------------- /compiler/tests/generated/generics_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "generics_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | } // namespace tests 9 | -------------------------------------------------------------------------------- /java/.gitignore: -------------------------------------------------------------------------------- 1 | */.gradle/ 2 | */gradle/ 3 | */gradlew 4 | */gradlew.bat 5 | */.idea/libraries 6 | */.idea/uiDesigner.xml 7 | */.idea/workspace.xml 8 | */build/ 9 | */out/ 10 | -------------------------------------------------------------------------------- /python/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT BOND_SKIP_CORE_TESTS) 2 | add_subfolder (core "tests/python/unit_test/core") 3 | add_subfolder (compat "tests/python/compat") 4 | endif() 5 | -------------------------------------------------------------------------------- /tools/ci-scripts/linux/image-cleanup/collector/config.py: -------------------------------------------------------------------------------- 1 | """Constants for the garbage image collector.""" 2 | 3 | REGISTRY_NAME = 'bondciimages' 4 | REPOSITORY_NAME = 'ubuntu-1604' 5 | -------------------------------------------------------------------------------- /tools/syntax/SublimeText3/Readme.md: -------------------------------------------------------------------------------- 1 | #Bond Syntax Highlighting for SublimeText 2 | 3 | Install by adding to your user's directory 4 | ```%AppData%\Roaming\Sublime Text 3\Packages\User``` -------------------------------------------------------------------------------- /compiler/tests/generated/alloc_ctors/empty_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "empty_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | } // namespace tests 9 | -------------------------------------------------------------------------------- /compiler/tests/generated/allocator/empty_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "empty_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | } // namespace tests 9 | -------------------------------------------------------------------------------- /compiler/tests/schema/field_modifiers.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct Foo 4 | { 5 | 0: optional bool o; 6 | 1: required int16 r; 7 | 2: required_optional double ro; 8 | } 9 | -------------------------------------------------------------------------------- /cs/test/codegen/default-ignore-output/bin/should-not-be-compiled.bond: -------------------------------------------------------------------------------- 1 | This file should not be automatically added by the codegen targets because 2 | it is in one of the output directories. 3 | -------------------------------------------------------------------------------- /cs/test/codegen/default-ignore-output/obj/should-not-be-compiled.bond: -------------------------------------------------------------------------------- 1 | This file should not be automatically added by the codegen targets because 2 | it is in one of the output directories. 3 | -------------------------------------------------------------------------------- /examples/cpp/core/record_streaming/record_streaming.bond: -------------------------------------------------------------------------------- 1 | namespace examples.record_streaming 2 | 3 | struct Struct 4 | { 5 | 0: uint32 n; 6 | 1: string str; 7 | } 8 | -------------------------------------------------------------------------------- /examples/cs/core/record_streaming/record_streaming.bond: -------------------------------------------------------------------------------- 1 | namespace examples.record_streaming 2 | 3 | struct Struct 4 | { 5 | 0: uint32 n; 6 | 1: string str; 7 | } 8 | -------------------------------------------------------------------------------- /compiler/tests/.gitattributes: -------------------------------------------------------------------------------- 1 | # For the generated files in the compiler test suite, we need these files to 2 | # be treated as-is to avoid spurious test failures. 3 | 4 | generated/** -text 5 | -------------------------------------------------------------------------------- /compiler/tests/generated/allocator/generics_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "generics_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | } // namespace tests 9 | -------------------------------------------------------------------------------- /compiler/tests/generated/scoped_allocator/empty_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "empty_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | } // namespace tests 9 | -------------------------------------------------------------------------------- /compiler/tests/generated/type_aliases/empty_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "empty_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | } // namespace tests 9 | -------------------------------------------------------------------------------- /compiler/tests/schema/bond_meta.bond: -------------------------------------------------------------------------------- 1 | namespace deprecated.bondmeta; 2 | 3 | struct HasMetaFields 4 | { 5 | 0: bond_meta::full_name full_name; 6 | 1: bond_meta::name name; 7 | } 8 | -------------------------------------------------------------------------------- /cpp/test/core/skip_tests.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class SkipTest 4 | { 5 | public: 6 | static void InitializeMismatchedIdTests(); 7 | static void InitializeMismatchedTypeTests(); 8 | }; 9 | -------------------------------------------------------------------------------- /examples/cs/core/decimal/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | using decimal = blob; 4 | 5 | struct Example 6 | { 7 | 0: decimal Price; 8 | 1: vector Numbers; 9 | } 10 | -------------------------------------------------------------------------------- /compiler/tests/generated/alloc_ctors/generics_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "generics_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | } // namespace tests 9 | -------------------------------------------------------------------------------- /compiler/tests/generated/type_aliases/generics_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "generics_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | } // namespace tests 9 | -------------------------------------------------------------------------------- /examples/cpp/core/string_ref/string_ref.bond: -------------------------------------------------------------------------------- 1 | namespace examples.string_ref 2 | 3 | using string_ref = string; 4 | 5 | struct Example 6 | { 7 | 0: vector words; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /examples/cs/core/date_time/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | using DateTime = int64; 4 | 5 | struct Example 6 | { 7 | 0: DateTime Now; 8 | 1: vector Dates; 9 | } 10 | -------------------------------------------------------------------------------- /examples/java/core/imports/src/main/bond/common/protocol/header.bond: -------------------------------------------------------------------------------- 1 | namespace Examples.Common.Protocol 2 | 3 | struct Header 4 | { 5 | 0: string Origin; 6 | 1: string Destination; 7 | } 8 | -------------------------------------------------------------------------------- /compiler/tests/generated/scoped_allocator/generics_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "generics_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | } // namespace tests 9 | -------------------------------------------------------------------------------- /compiler/tests/schema/alias_key.bond: -------------------------------------------------------------------------------- 1 | namespace test 2 | 3 | using String = string; 4 | using Int = int32; 5 | 6 | struct foo 7 | { 8 | 0: map m; 9 | 1: set s; 10 | } 11 | -------------------------------------------------------------------------------- /compiler/tests/schema/error/int_out_of_range.bond: -------------------------------------------------------------------------------- 1 | 2 | //this bond file is invalid; do not use as example 3 | 4 | 5 | namespace tests 6 | 7 | struct Test 8 | { 9 | 0: int16 i = 32768; 10 | } -------------------------------------------------------------------------------- /compiler/tests/schema/error/service_invalid_base_type_param.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | // Invalid service definition with type param as base 4 | service Foo : T 5 | { 6 | nothing bar(); 7 | } 8 | -------------------------------------------------------------------------------- /examples/java/core/record_streaming/src/main/bond/record_streaming.bond: -------------------------------------------------------------------------------- 1 | namespace examples.record_streaming 2 | 3 | struct Struct 4 | { 5 | 0: uint32 n; 6 | 1: string str; 7 | } 8 | -------------------------------------------------------------------------------- /java/core/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /tools/syntax/Notepad-plus-plus/README.md: -------------------------------------------------------------------------------- 1 | #Installation Instructions for the Bond UDL: 2 | 3 | 4 | Import "bond.xml" via the Notepad++ menu, 5 | 6 | ```Language > Define your Language... > Import``` 7 | -------------------------------------------------------------------------------- /compiler/tests/generated/empty_reflection.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "empty_types.h" 5 | #include 6 | 7 | namespace tests 8 | { 9 | 10 | } // namespace tests 11 | -------------------------------------------------------------------------------- /cs/test/codegen/default-ignore-output/obj/debug/netstandard1.0/should-not-be-compiled.bond: -------------------------------------------------------------------------------- 1 | This file should not be automatically added by the codegen targets because 2 | it is in one of the output directories. 3 | -------------------------------------------------------------------------------- /cs/test/core/Partial.cs: -------------------------------------------------------------------------------- 1 | namespace UnitTest 2 | { 3 | public partial class BasicTypes 4 | { 5 | // static constructor 6 | static BasicTypes() 7 | { } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/cs/core/serialization/schema.bond: -------------------------------------------------------------------------------- 1 | namespace examples.serialization 2 | 3 | struct Struct 4 | { 5 | 0: uint32 n; 6 | 1: string str; 7 | 2: vector items; 8 | } 9 | -------------------------------------------------------------------------------- /java/compat/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /test/compat/core/schemas/compat2.bond: -------------------------------------------------------------------------------- 1 | namespace unittest.compat.another 2 | 3 | enum EnumType 4 | { 5 | EnumValue1 = 6, 6 | }; 7 | 8 | 9 | struct Another 10 | { 11 | 10: double d; 12 | }; 13 | -------------------------------------------------------------------------------- /compiler/tests/schema/nullable_alias.bond: -------------------------------------------------------------------------------- 1 | namespace test 2 | 3 | using LargeInt=int64; 4 | using time=int64; 5 | 6 | struct foo 7 | { 8 | 1: nullable l; 9 | 2: time t = nothing; 10 | } 11 | -------------------------------------------------------------------------------- /cs/test/codegen/default-ignore-output/obj/retail/netstandard1.0/should-not-be-compiled.bond: -------------------------------------------------------------------------------- 1 | This file should not be automatically added by the codegen targets because 2 | it is in one of the output directories. 3 | -------------------------------------------------------------------------------- /examples/cpp/core/serialization/serialization.bond: -------------------------------------------------------------------------------- 1 | namespace examples.serialization 2 | 3 | struct Struct 4 | { 5 | 0: uint32 n; 6 | 1: string str; 7 | 2: vector items; 8 | } 9 | -------------------------------------------------------------------------------- /examples/cs/core/blob/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Example 4 | { 5 | 0: vector ListOfBlobs; 6 | 1: nullable NullableBlob; 7 | 2: blob UninitializedBlob = nothing; 8 | } 9 | -------------------------------------------------------------------------------- /examples/cs/core/container_alias/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | using CustomList = list; 4 | 5 | struct Example 6 | { 7 | 0: string Name; 8 | 1: CustomList Constants; 9 | } 10 | -------------------------------------------------------------------------------- /java/gradle-plugin/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /compiler/tests/generated/allocator/empty_reflection.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "empty_types.h" 5 | #include 6 | 7 | namespace tests 8 | { 9 | 10 | } // namespace tests 11 | -------------------------------------------------------------------------------- /java/core/settings.gradle: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | rootProject.name = 'bond' 5 | -------------------------------------------------------------------------------- /compiler/tests/generated/alloc_ctors/empty_reflection.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "empty_types.h" 5 | #include 6 | 7 | namespace tests 8 | { 9 | 10 | } // namespace tests 11 | -------------------------------------------------------------------------------- /compiler/tests/generated/type_aliases/empty_reflection.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "empty_types.h" 5 | #include 6 | 7 | namespace tests 8 | { 9 | 10 | } // namespace tests 11 | -------------------------------------------------------------------------------- /compiler/tests/schema/metadata_edge_cases.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct Foo 4 | { 5 | 0: int32 id; 6 | 1: int32 metadata; 7 | 2: int32 id_type; 8 | 3: int32 x; 9 | 4: int32 x_type; 10 | } 11 | -------------------------------------------------------------------------------- /compiler/tests/generated/scoped_allocator/empty_reflection.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "empty_types.h" 5 | #include 6 | 7 | namespace tests 8 | { 9 | 10 | } // namespace tests 11 | -------------------------------------------------------------------------------- /compiler/tests/schema/import.bond: -------------------------------------------------------------------------------- 1 | // Uses mixed slashes to test gbc can deal with that 2 | import "dir1/dir2\empty.bond" 3 | 4 | namespace import_test; 5 | 6 | struct HasEmpty 7 | { 8 | 0: empty.Empty e; 9 | } 10 | -------------------------------------------------------------------------------- /examples/cpp/core/protocol_versions/protocol_versions.bond: -------------------------------------------------------------------------------- 1 | namespace examples.protocol_versions 2 | 3 | struct Struct 4 | { 5 | 0: uint32 n; 6 | 1: string str; 7 | 2: vector items; 8 | } 9 | -------------------------------------------------------------------------------- /examples/cs/core/protocol_versions/protocol_versions.bond: -------------------------------------------------------------------------------- 1 | namespace examples.protocol_versions 2 | 3 | struct Struct 4 | { 5 | 0: uint32 n; 6 | 1: string str; 7 | 2: vector items; 8 | } 9 | -------------------------------------------------------------------------------- /examples/java/core/blob/src/main/bond/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Example 4 | { 5 | 0: vector ListOfBlobs; 6 | 1: nullable NullableBlob; 7 | 2: blob UninitializedBlob = nothing; 8 | } 9 | -------------------------------------------------------------------------------- /examples/java/core/serialization/src/main/bond/serialization.bond: -------------------------------------------------------------------------------- 1 | namespace examples.serialization 2 | 3 | struct Struct 4 | { 5 | 0: uint32 n; 6 | 1: string str; 7 | 2: vector items; 8 | } 9 | -------------------------------------------------------------------------------- /java/compat/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /java/compat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8.12) 2 | 3 | set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake) 4 | 5 | include (Java) 6 | 7 | add_gradle_build (java-compat 8 | DEPENDS java-core) 9 | -------------------------------------------------------------------------------- /java/core/.idea/dictionaries/bond.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | codegen 5 | struct 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /java/core/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /java/json/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /compiler/tests/schema/error/aliases_default.bond: -------------------------------------------------------------------------------- 1 | 2 | //this bond file is invalid; do not use as example 3 | 4 | 5 | namespace tests 6 | 7 | using String = string; 8 | 9 | struct Test 10 | { 11 | 0: String s = 6; 12 | } -------------------------------------------------------------------------------- /java/gradle-plugin/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /cmake/RunPythonTest.cmake: -------------------------------------------------------------------------------- 1 | set (ENV{PYTHONPATH} ${PYTHONPATH}) 2 | 3 | execute_process ( 4 | COMMAND ${PYTHON_EXECUTABLE} ${SCRIPT} 5 | RESULT_VARIABLE error) 6 | 7 | if (error) 8 | message (FATAL_ERROR) 9 | endif() 10 | -------------------------------------------------------------------------------- /examples/cs/core/protocol_transcoding/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Widget 4 | { 5 | 0: string Name; 6 | 1: double Number; 7 | } 8 | 9 | struct Example 10 | { 11 | 0: vector Widgets; 12 | } 13 | -------------------------------------------------------------------------------- /cpp/test/core/scope_test1.bond: -------------------------------------------------------------------------------- 1 | namespace x.y 2 | 3 | enum Enumeration 4 | { 5 | standard = 1, 6 | custom = 2, 7 | }; 8 | 9 | struct Struct 10 | { 11 | 1: double value; 12 | 2: Enumeration field = standard; 13 | }; 14 | -------------------------------------------------------------------------------- /examples/java/core/protocol_versions/src/main/bond/protocol_versions.bond: -------------------------------------------------------------------------------- 1 | namespace examples.protocol_versions 2 | 3 | struct Struct 4 | { 5 | 0: uint32 n; 6 | 1: string str; 7 | 2: vector items; 8 | } 9 | -------------------------------------------------------------------------------- /java/gradle-plugin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8.12) 2 | 3 | set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake) 4 | 5 | include (Java) 6 | 7 | add_gradle_build (gradle-plugin 8 | GRADLE_TARGET install) 9 | -------------------------------------------------------------------------------- /cs/build/nuget/Bond.CSharp.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/cpp/core/inheritance/inheritance.bond: -------------------------------------------------------------------------------- 1 | namespace examples.inheritance 2 | 3 | struct Base 4 | { 5 | 1: string str = "base default"; 6 | } 7 | 8 | struct Derived : Base 9 | { 10 | 1: string str = "derived default"; 11 | } 12 | -------------------------------------------------------------------------------- /examples/cpp/core/output_stream_allocator/output_stream_allocator.bond: -------------------------------------------------------------------------------- 1 | namespace examples.output_stream_allocator 2 | 3 | struct Struct 4 | { 5 | 0: uint32 num; 6 | 1: string str; 7 | 2: vector items; 8 | } 9 | -------------------------------------------------------------------------------- /examples/cpp/core/time_alias/time_alias.bond: -------------------------------------------------------------------------------- 1 | namespace examples.time 2 | 3 | // Define time to be an alias of int64 4 | using time = int64; 5 | 6 | struct Example 7 | { 8 | 0: time when; 9 | 1: map bdays; 10 | } 11 | -------------------------------------------------------------------------------- /examples/cs/core/inheritance/inheritance.bond: -------------------------------------------------------------------------------- 1 | namespace examples.inheritance 2 | 3 | struct Base 4 | { 5 | 1: string str = "base default"; 6 | } 7 | 8 | struct Derived : Base 9 | { 10 | 1: string str = "derived default"; 11 | } 12 | -------------------------------------------------------------------------------- /cpp/test/core/security.bond: -------------------------------------------------------------------------------- 1 | namespace security 2 | 3 | struct Base 4 | { 5 | 0: T x; 6 | } 7 | 8 | struct Struct : Base 9 | { 10 | 0: T3 n; 11 | 1: T1 y; 12 | 2: vector items; 13 | } 14 | -------------------------------------------------------------------------------- /examples/cpp/core/enumerations/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_codegen (enumerations.bond 2 | ENUM_HEADER) 3 | 4 | add_bond_test (enumerations 5 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/enumerations_types.cpp 6 | enumerations.cpp) 7 | 8 | -------------------------------------------------------------------------------- /compiler/tests/schema/service_attributes.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct Result{} 4 | struct Param{} 5 | 6 | [FooAttribute("Bar")] 7 | service Foo 8 | { 9 | [foo("method")] 10 | [method("")] 11 | Result foo(Param); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /cs/build/nuget/Bond.Compiler.CSharp.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/cpp/core/move_semantics/move_semantics.bond: -------------------------------------------------------------------------------- 1 | namespace examples.move_semantics 2 | 3 | struct Item 4 | { 5 | 0: string name; 6 | } 7 | 8 | struct Struct 9 | { 10 | 0: uint32 value; 11 | 1: optional vector items; 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # CMake 2 | # Our documentation recommends that the root directory /build/ be used for 3 | # CMake files. 4 | /build/ 5 | 6 | # Emacs 7 | *~ 8 | \#*\# 9 | 10 | # Vim 11 | *.swp 12 | *.swo 13 | *.swm 14 | 15 | # VS 16 | .vs/ 17 | .vscode/ 18 | -------------------------------------------------------------------------------- /compiler/tests/schema/error/service_invalid_base_struct.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct dummy { 4 | 0: int32 count; 5 | } 6 | 7 | // Invalid service definition with struct as a base 8 | service Foo : dummy 9 | { 10 | nothing bar(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/java/core/inheritance/src/main/bond/inheritance.bond: -------------------------------------------------------------------------------- 1 | namespace examples.inheritance 2 | 3 | struct Base 4 | { 5 | 1: string str = "base default"; 6 | } 7 | 8 | struct Derived : Base 9 | { 10 | 1: string str = "derived default"; 11 | } 12 | -------------------------------------------------------------------------------- /java/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8.12) 2 | 3 | set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake) 4 | 5 | include (Java) 6 | 7 | add_gradle_build (java-core 8 | GRADLE_TARGET install 9 | DEPENDS gradle-plugin) 10 | -------------------------------------------------------------------------------- /examples/cpp/core/generics/generics.bond: -------------------------------------------------------------------------------- 1 | namespace examples.generics 2 | 3 | struct Base 4 | { 5 | 0: T x; 6 | } 7 | 8 | struct Struct : Base 9 | { 10 | 0: T3 n; 11 | 1: T1 y; 12 | 2: vector items; 13 | } 14 | -------------------------------------------------------------------------------- /java/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Top-level meta-target to build the entire Java world. Implicitly depends on 2 | # all targets created by add_gradle_build. 3 | add_custom_target (java) 4 | 5 | add_subdirectory (gradle-plugin) 6 | add_subdirectory (core) 7 | add_subdirectory (compat) 8 | -------------------------------------------------------------------------------- /compiler/tests/schema/error/struct_nothing.bond: -------------------------------------------------------------------------------- 1 | 2 | //this bond file is invalid; do not use as example 3 | 4 | 5 | namespace tests 6 | 7 | struct BasicTypes 8 | { 9 | 0: bool _bool; 10 | } 11 | 12 | struct Test 13 | { 14 | 0: BasicTypes bt = nothing; 15 | } -------------------------------------------------------------------------------- /compiler/tests/schema/error/enum_no_default.bond: -------------------------------------------------------------------------------- 1 | 2 | //this bond file is invalid; do not use as example 3 | 4 | 5 | namespace tests 6 | 7 | enum Priority 8 | { 9 | Low; 10 | Normal; 11 | High; 12 | } 13 | 14 | struct Test 15 | { 16 | 0: Priority p; 17 | } -------------------------------------------------------------------------------- /compiler/tests/schema/error/duplicate_service_method.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct dummy { 4 | 0: int32 count; 5 | } 6 | 7 | // Invalid service definition with two methods with the same name 8 | service Foo 9 | { 10 | void bar(dummy); 11 | nothing bar(); 12 | } -------------------------------------------------------------------------------- /examples/java/core/generics/src/main/bond/generics.bond: -------------------------------------------------------------------------------- 1 | namespace examples.generics 2 | 3 | struct Base 4 | { 5 | 0: T x; 6 | } 7 | 8 | struct Struct : Base 9 | { 10 | 0: T3 n; 11 | 1: T1 y; 12 | 2: vector items; 13 | } 14 | -------------------------------------------------------------------------------- /python/test/compat/compat.cpp: -------------------------------------------------------------------------------- 1 | #include "compat_reflection.h" 2 | #include 3 | 4 | BOOST_PYTHON_MODULE(python_compatibility_test) 5 | { 6 | using namespace unittest::compat; 7 | 8 | bond::python::struct_() 9 | .def(); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Bond project has ended 2 | 3 | As of March 2025, the Bond open-source project has ended. 4 | 5 | There will be no further activity in this project. no new features, no bug 6 | fixes, and, importantly, no security fixes. 7 | 8 | See the [README](README.md) for more details. 9 | -------------------------------------------------------------------------------- /cs/test/codegen/default-ignore-output/README.md: -------------------------------------------------------------------------------- 1 | This test ensures that the .bond files automatically added to BondCodegen 2 | exclude files in the project's output paths. 3 | 4 | This directory has some files intentionally committed under the 5 | typically-ignored `bin/` and `obj/` paths. 6 | -------------------------------------------------------------------------------- /examples/cs/core/untagged_protocols/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Example1 4 | { 5 | 0: bool Enabled; 6 | 1: string Name; 7 | } 8 | 9 | struct Example2 10 | { 11 | 0: bool Enabled; 12 | 1: string Name; 13 | 2: nullable> Numbers; 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/core/container_of_pointers/container_of_pointers.bond: -------------------------------------------------------------------------------- 1 | namespace examples.container_of_pointers 2 | 3 | struct Item 4 | { 5 | 1: string foo; 6 | 2: uint16 bar; 7 | } 8 | 9 | using PtrList=list; 10 | 11 | struct Struct 12 | { 13 | 2: PtrList items; 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp/core/marshaling/marshaling.bond: -------------------------------------------------------------------------------- 1 | namespace examples.marshaling 2 | 3 | struct A 4 | { 5 | 0: int32 x; 6 | } 7 | 8 | struct Struct 9 | { 10 | 0: uint32 n; 11 | 1: string str; 12 | 2: vector items; 13 | 3: bonded a; 14 | } 15 | -------------------------------------------------------------------------------- /examples/cs/core/generics/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Generic1 4 | { 5 | 0: nullable Field; 6 | } 7 | 8 | struct Generic2 9 | { 10 | 0: T Field = nothing; 11 | } 12 | 13 | struct Example 14 | { 15 | 0: Generic1> Field; 16 | } 17 | -------------------------------------------------------------------------------- /java/compat/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /cpp/test/core/imports/dir1/dir2/import_test2.bond: -------------------------------------------------------------------------------- 1 | namespace import2 2 | 3 | enum ImportedEnum 4 | { 5 | ImportedEnum1 = 13, 6 | ImportedEnum2 = 23 7 | } 8 | 9 | struct Recursive; 10 | 11 | struct Recursive 12 | { 13 | 0: nullable> next; 14 | } 15 | -------------------------------------------------------------------------------- /examples/java/core/untagged_protocols/src/main/bond/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Example1 4 | { 5 | 0: bool Enabled; 6 | 1: string Name; 7 | } 8 | 9 | struct Example2 10 | { 11 | 0: bool Enabled; 12 | 1: string Name; 13 | 2: nullable> Numbers; 14 | } 15 | -------------------------------------------------------------------------------- /java/gradle-plugin/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /java/json/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | The Bond open-source project ended in March 2025. Contributions to this 4 | project are no longer being accepted. 5 | 6 | Microsoft has no affiliation with other open-source implementations of Bond. 7 | We cannot endorse any of them, and Microsoft will not provide any support. 8 | -------------------------------------------------------------------------------- /NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/cpp/core/dll/dllexample_dynlink.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(BUILDING_DLLEXAMPLE_DLL) 4 | #define DLLEXAMPLE_DYNLINK __declspec(dllexport) 5 | #elif defined(USING_DLLEXAMPLE_DLL) 6 | #define DLLEXAMPLE_DYNLINK __declspec(dllimport) 7 | #else 8 | #define DLLEXAMPLE_DYNLINK 9 | #endif 10 | -------------------------------------------------------------------------------- /examples/cpp/core/scoped_allocator/scoped_alloc.bond: -------------------------------------------------------------------------------- 1 | namespace examples.scoped_allocator 2 | 3 | struct Strings 4 | { 5 | 0: vector strings; 6 | } 7 | 8 | struct Struct 9 | { 10 | 0: vector ints; 11 | 1: Strings strings; 12 | 2: vector strings_vector; 13 | } 14 | -------------------------------------------------------------------------------- /examples/cpp/core/static_library/lib/static_library.bond: -------------------------------------------------------------------------------- 1 | namespace examples.static_library 2 | 3 | struct Item 4 | { 5 | 0: string str = "default string value"; 6 | 1: list numbers; 7 | } 8 | 9 | struct MyStruct 10 | { 11 | 0: vector items; 12 | 1: bonded item; 13 | } 14 | -------------------------------------------------------------------------------- /examples/cs/core/cloning/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Document 4 | { 5 | 0: string Title; 6 | 1: set Authors; 7 | 2: vector Tags; 8 | 3: vector Content; 9 | } 10 | 11 | struct Outline 12 | { 13 | 0: string Title; 14 | 2: list Tags; 15 | } 16 | -------------------------------------------------------------------------------- /tools/ci-scripts/linux/build_cpp-common.zsh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | set -eux 4 | 5 | cmake -DBOND_STACK_OPTIONS="--allow-different-user" \ 6 | -DCMAKE_CXX_FLAGS="$BOND_CXX_FLAGS" \ 7 | -DCMAKE_C_FLAGS="$BOND_CC_FLAGS" \ 8 | ${=BOND_CMAKE_FLAGS} \ 9 | /root/bond 10 | 11 | make --jobs 2 check 12 | -------------------------------------------------------------------------------- /examples/cpp/core/capped_allocator/capped_allocator.bond: -------------------------------------------------------------------------------- 1 | namespace examples.capped_allocator 2 | 3 | struct Strings 4 | { 5 | 0: vector strings; 6 | } 7 | 8 | struct Struct 9 | { 10 | 0: vector ints; 11 | 1: Strings strings; 12 | 2: vector strings_vector; 13 | } 14 | -------------------------------------------------------------------------------- /java/core/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /java/core/src/test/bond/bonded.bond: -------------------------------------------------------------------------------- 1 | // Uses mixed slashes to test gbc can deal with that 2 | import "dir1\dir2/common.bond" 3 | 4 | namespace org.bondlib.test 5 | 6 | struct HasBondedField { 7 | 0: bonded bondedField; 8 | } 9 | 10 | struct BondedCollection { 11 | 0: list> bondeds; 12 | } 13 | -------------------------------------------------------------------------------- /compiler/tests/schema/service_inheritance.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct Params {} 4 | struct Result {} 5 | 6 | service Foo 7 | { 8 | Result foo(Params); 9 | } 10 | 11 | service Bar : Foo 12 | { 13 | Result bar(T); 14 | } 15 | 16 | service Bux : Bar 17 | { 18 | Result bux(Params); 19 | } 20 | -------------------------------------------------------------------------------- /cpp/test/core/scope_test2.bond: -------------------------------------------------------------------------------- 1 | import "scope_test1.bond" 2 | 3 | namespace a.x.y 4 | 5 | enum Enumeration 6 | { 7 | standard = 2, 8 | }; 9 | 10 | struct Struct 11 | { 12 | 1: Enumeration member = standard; 13 | }; 14 | 15 | struct Derived : x.y.Struct 16 | { 17 | 1: x.y.Enumeration thing = custom; 18 | }; 19 | -------------------------------------------------------------------------------- /examples/cpp/core/modifying_transform/modifying_transform.bond: -------------------------------------------------------------------------------- 1 | namespace examples.modifying_transform 2 | 3 | struct Nested 4 | { 5 | 1: string str; 6 | } 7 | 8 | 9 | struct Base 10 | { 11 | 2: string str; 12 | } 13 | 14 | 15 | struct Struct : Base 16 | { 17 | 0: Nested n; 18 | 1: string str; 19 | } 20 | -------------------------------------------------------------------------------- /examples/cpp/core/static_array/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_codegen (static_array.bond 2 | OPTIONS 3 | --using=\"array=std::array<{0}, {1}>\" 4 | --header=\"\") 5 | 6 | add_bond_test (static_array 7 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/static_array_types.cpp 8 | static_array.cpp) 9 | -------------------------------------------------------------------------------- /java/compat/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /cs/test/core/NamespaceConflictBond.bond: -------------------------------------------------------------------------------- 1 | namespace SomeNamespace.Bond 2 | 3 | // Having both namespaces UnitTest and UnitTest.Bond might cause compilation failures if the 4 | // codegen does not handle the global::Bond namespace correctly. The purpose of this file is 5 | // to ensure that this does not happen. 6 | struct Foo 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /examples/cs/core/runtime_schema/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Struct 4 | { 5 | 0: string String = "this is a string"; 6 | } 7 | 8 | [StructAttribute("Value of the attribute")] 9 | struct Example 10 | { 11 | [FieldAttribute("Value of the attribute")] 12 | 0: map mapStruct1; 13 | } 14 | -------------------------------------------------------------------------------- /examples/java/core/runtime_schema/src/main/bond/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | struct Struct 4 | { 5 | 0: string String = "this is a string"; 6 | } 7 | 8 | [StructAttribute("struct attribute")] 9 | struct Example 10 | { 11 | [FieldAttribute("field attribute")] 12 | 0: map mapStruct1; 13 | } 14 | -------------------------------------------------------------------------------- /java/json/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /cpp/inc/bond/core/containers.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "bond_fwd.h" 9 | #include "maybe.h" 10 | #include "stl_containers.h" 11 | -------------------------------------------------------------------------------- /cs/build/nuget/Bond.CSharp.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /compiler/tests/schema/attributes.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | [EnumAttribute1("one")] 4 | [EnumAttribute2("two")] 5 | enum Enum 6 | { 7 | Value1 8 | } 9 | 10 | [StructAttribute1("one")] 11 | [StructAttribute2("two")] 12 | struct Foo 13 | { 14 | [FieldAttribute1("one")] 15 | [FieldAttribute2("two")] 16 | 0: string f; 17 | } 18 | -------------------------------------------------------------------------------- /doc/doxygen/bond_reference.css: -------------------------------------------------------------------------------- 1 | /* Customize doxygen CSS for Bond */ 2 | 3 | .memTemplParams { 4 | font-size: 100%; 5 | } 6 | 7 | .memtemplate { 8 | font-size: 100%; 9 | } 10 | 11 | .memItemLeft, .memItemRight, .memTemplItemLeft, .memTemplItemRight, .memTemplParams, .memname, .memtemplate { 12 | font-family: monospace; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /examples/cpp/core/runtime_binding/runtime_binding.bond: -------------------------------------------------------------------------------- 1 | namespace examples.runtime_binding 2 | 3 | struct Struct 4 | { 5 | 0: uint32 number; 6 | 1: string name; 7 | 2: string address; 8 | 3: int16 age; 9 | } 10 | 11 | 12 | struct MyView 13 | { 14 | 5: string some_string; 15 | 8: int32 some_number; 16 | } 17 | -------------------------------------------------------------------------------- /examples/cs/core/guid/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | // Two flavors of storing a GUID are demonstrated here: 4 | // the first uses a string and the second uses a binary blob. 5 | 6 | using guid_str = string; 7 | using guid_bin = blob; 8 | 9 | struct Example 10 | { 11 | 0: guid_str id_str; 12 | 1: guid_bin id_bin; 13 | } 14 | -------------------------------------------------------------------------------- /java/gradle-plugin/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /cpp/test/core/import_test1.bond: -------------------------------------------------------------------------------- 1 | // Uses mixed slashes to test gbc can deal with that 2 | import "dir1/dir2\import_test2.bond" 3 | 4 | namespace import1 5 | namespace csharp Microsoft.Import1 6 | 7 | struct ImportedStruct 8 | { 9 | 10: required_optional int32 x; 10 | 20: required_optional import2.ImportedEnum e = ImportedEnum2; 11 | }; 12 | -------------------------------------------------------------------------------- /cs/build/nuget/Bond.Compiler.CSharp.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /examples/cpp/core/string_ref/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_codegen (string_ref.bond 2 | OPTIONS 3 | --using=\"string_ref=boost::string_ref\" 4 | --header=\"\" 5 | --type-aliases) 6 | 7 | add_bond_test (string_ref 8 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/string_ref_types.cpp 9 | string_ref.cpp) 10 | -------------------------------------------------------------------------------- /examples/cpp/core/attributes/attributes.bond: -------------------------------------------------------------------------------- 1 | namespace examples.attributes 2 | 3 | struct Nested 4 | { 5 | [Min("10")] 6 | [Max("20")] 7 | 0: uint32 n; 8 | 9 | [Min("-3")] 10 | [Max("+3")] 11 | 1: int16 f; 12 | } 13 | 14 | 15 | struct Base 16 | { 17 | 2: Nested s; 18 | } 19 | 20 | 21 | struct Struct : Base 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /java/gradle-plugin/README.md: -------------------------------------------------------------------------------- 1 | To build with a development version of this plugin, enter the directory 2 | containing this README and repeat as follows: 3 | 4 | * write some code 5 | * `gradle build install` 6 | 7 | This will install the plugin to your local maven repository, which the other 8 | Java projects' build.gradles will use in preference to maven central. 9 | -------------------------------------------------------------------------------- /compiler/tests/schema/generic_service.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct SomeBox 4 | { 5 | 0: T value; 6 | } 7 | 8 | service Foo 9 | { 10 | void foo31(Payload); 11 | Payload foo32(void); 12 | Payload foo33(Payload); 13 | 14 | void ConsumesGeneric1(SomeBox); 15 | void ConsumesGeneric2(SomeBox>); 16 | } 17 | -------------------------------------------------------------------------------- /examples/cs/core/enumerations/enumerations.bond: -------------------------------------------------------------------------------- 1 | namespace Examples; 2 | 3 | enum Color 4 | { 5 | Orange = 1, 6 | Yellow = 2, 7 | } 8 | 9 | enum Fruit 10 | { 11 | Apple = 1, 12 | Orange = 2, 13 | } 14 | 15 | enum Limits 16 | { 17 | Int32Min = -2147483648, 18 | Int32Max = 2147483647, 19 | UInt32Min = 0, 20 | UInt32Max = 0xFFFFFFFF, 21 | } 22 | -------------------------------------------------------------------------------- /examples/cpp/core/merge/merge.bond: -------------------------------------------------------------------------------- 1 | namespace examples.merge 2 | 3 | struct Base 4 | { 5 | 0: string str; 6 | } 7 | 8 | struct Item : Base 9 | { 10 | 0: float f; 11 | } 12 | 13 | struct Struct 14 | { 15 | 0: vector items; 16 | 1: Item item; 17 | } 18 | 19 | struct StructView 20 | { 21 | 0: vector items; 22 | 1: bonded item; 23 | } 24 | -------------------------------------------------------------------------------- /compiler/tests/schema/complex_types.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct Foo {}; 4 | struct Bar; 5 | 6 | struct ComplexTypes 7 | { 8 | 0: list li8; 9 | 1: set sb; 10 | 2: vector vb; 11 | 3: nullable nf; 12 | 4: map msws; 13 | 5: bonded bfoo; 14 | 6: map>>>> m; 15 | } 16 | -------------------------------------------------------------------------------- /examples/cs/core/import/schema.bond: -------------------------------------------------------------------------------- 1 | import "common.bond" 2 | import "protocol/header.bond" 3 | 4 | namespace Examples 5 | 6 | struct Message 7 | { 8 | // To use a type from a different namespace, use its fully qualified name. 9 | 0: Examples.Common.Protocol.Header Header; 10 | 1: Examples.Common.Priority Priority = Normal; 11 | 2: uint32 MessagePayload; 12 | } 13 | -------------------------------------------------------------------------------- /examples/cpp/core/dll/dll.bond: -------------------------------------------------------------------------------- 1 | namespace examples.dll 2 | 3 | enum Color 4 | { 5 | Red = 1; 6 | Blue = 2; 7 | } 8 | 9 | struct Item 10 | { 11 | 0: string str = "default string value"; 12 | 1: list numbers; 13 | 3: Color color = Blue; 14 | } 15 | 16 | struct MyStruct 17 | { 18 | 0: vector> items; 19 | 1: bonded> item; 20 | } 21 | -------------------------------------------------------------------------------- /examples/cpp/core/enumerations/enumerations.bond: -------------------------------------------------------------------------------- 1 | namespace examples.enumerations 2 | 3 | enum Color 4 | { 5 | Orange = 1, 6 | Yellow = 2, 7 | } 8 | 9 | enum Fruit 10 | { 11 | Apple = 1, 12 | Orange = 2, 13 | } 14 | 15 | enum Limits 16 | { 17 | Int32Min = -2147483648, 18 | Int32Max = 2147483647, 19 | UInt32Min = 0, 20 | UInt32Max = 0xFFFFFFFF, 21 | } 22 | -------------------------------------------------------------------------------- /examples/java/core/enumerations/src/main/bond/enumerations.bond: -------------------------------------------------------------------------------- 1 | namespace Examples; 2 | 3 | enum Color 4 | { 5 | Orange = 1, 6 | Yellow = 2, 7 | } 8 | 9 | enum Fruit 10 | { 11 | Apple = 1, 12 | Orange = 2, 13 | } 14 | 15 | enum Limits 16 | { 17 | Int32Min = -2147483648, 18 | Int32Max = 2147483647, 19 | UInt32Min = 0, 20 | UInt32Max = 0xFFFFFFFF, 21 | } 22 | -------------------------------------------------------------------------------- /examples/cpp/core/container_of_pointers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_codegen (container_of_pointers.bond 2 | OPTIONS 3 | --using=\"PtrList=std::list >\" 4 | --header=\"\") 5 | 6 | add_bond_test (container_of_pointers 7 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/container_of_pointers_types.cpp 8 | container_of_pointers.cpp) 9 | 10 | -------------------------------------------------------------------------------- /cpp/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Core unit tests don't build under VS2013 without this. 2 | cxx_add_compile_options(MSVC /EHa) 3 | 4 | if (NOT BOND_SKIP_COMPAT_TESTS) 5 | add_subfolder (compat/core "tests/compat/core") 6 | endif() 7 | 8 | if (Boost_UNIT_TEST_FRAMEWORK_FOUND) 9 | if (NOT BOND_SKIP_CORE_TESTS) 10 | add_subfolder (core "tests/unit_test/core") 11 | endif() 12 | endif() 13 | -------------------------------------------------------------------------------- /examples/java/core/imports/src/main/bond/schema.bond: -------------------------------------------------------------------------------- 1 | import "common.bond" 2 | import "protocol/header.bond" 3 | 4 | namespace Examples 5 | 6 | struct Message 7 | { 8 | // To use a type from a different namespace, use its fully qualified name. 9 | 0: Examples.Common.Protocol.Header Header; 10 | 1: Examples.Common.Priority Priority = Normal; 11 | 2: uint32 MessagePayload; 12 | } 13 | -------------------------------------------------------------------------------- /compiler/tests/schema/aliases.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | using array = vector; 4 | using array10 = array<10, T>; 5 | 6 | struct Foo 7 | { 8 | 0: array10> aa; 9 | } 10 | 11 | using Wrapper = T; 12 | 13 | enum EnumToWrap 14 | { 15 | anEnumValue 16 | } 17 | 18 | struct WrappingAnEnum 19 | { 20 | 0: Wrapper aWrappedEnum = anEnumValue; 21 | } 22 | -------------------------------------------------------------------------------- /examples/cpp/core/multiprecision/multiprecision.bond: -------------------------------------------------------------------------------- 1 | namespace examples.multiprecision 2 | 3 | // Type aliases for large integers 4 | using uint512 = blob; 5 | using uint1024 = blob; 6 | 7 | // Type alias for arbitrary precision integer 8 | using integer = blob; 9 | 10 | struct Example 11 | { 12 | 0: uint1024 private_key; 13 | 1: uint512 public_key; 14 | 2: integer product; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /examples/cpp/core/protocol_transcoding/protocol_transcoding.bond: -------------------------------------------------------------------------------- 1 | namespace examples.protocol_transcoding 2 | 3 | struct User 4 | { 5 | 0: string name; 6 | 1: string address; 7 | } 8 | 9 | struct Struct 10 | { 11 | 0: uint32 n; 12 | 1: string str; 13 | 2: vector items; 14 | 3: map users; 15 | } 16 | -------------------------------------------------------------------------------- /examples/cpp/core/simple_json/simple_json.bond: -------------------------------------------------------------------------------- 1 | namespace examples.simple_json 2 | 3 | struct Window 4 | { 5 | 0: string title = "Sample Konfabulator Widget"; 6 | 2: int16 width = 500; 7 | 3: int16 height = 500; 8 | } 9 | 10 | enum Mode 11 | { 12 | on, 13 | off 14 | } 15 | 16 | struct Widget 17 | { 18 | 0: Mode debug = on; 19 | 1: vector windows; 20 | } 21 | -------------------------------------------------------------------------------- /cs/build/internal/DevVersions.cs: -------------------------------------------------------------------------------- 1 | // For development builds, we set the versions to 0.0.0.1. Official builds 2 | // generate different versions based on the package version and do not 3 | // actually compile this file. 4 | [assembly: System.Reflection.AssemblyVersion("0.0.0.1")] 5 | [assembly: System.Reflection.AssemblyFileVersion("0.0.0.1")] 6 | [assembly: System.Reflection.AssemblyInformationalVersion("0.0.0.1")] 7 | -------------------------------------------------------------------------------- /examples/cpp/core/nothing_default/nothing_default.bond: -------------------------------------------------------------------------------- 1 | namespace examples.nothing_default 2 | 3 | 4 | struct Struct_v1 5 | { 6 | 1: required int32 foo = nothing; 7 | 2: optional list baz = nothing; 8 | } 9 | 10 | 11 | struct Struct_v2 12 | { 13 | 1: required int32 foo = nothing; 14 | 2: optional list baz = nothing; 15 | 3: optional double bar = nothing; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /examples/cpp/core/transform/transform.bond: -------------------------------------------------------------------------------- 1 | namespace examples.transform 2 | 3 | struct Struct_1_0 4 | { 5 | 10: uint32 n; 6 | 20: string name; 7 | 30: vector items; 8 | }; 9 | 10 | 11 | struct Struct_2_0 12 | { 13 | 10: uint32 n; 14 | 21: string first_name; 15 | 22: string last_name; 16 | 30: vector items; 17 | }; 18 | -------------------------------------------------------------------------------- /examples/cs/core/nothing_default/nothing_default.bond: -------------------------------------------------------------------------------- 1 | namespace examples.nothing_default 2 | 3 | 4 | struct Struct_v1 5 | { 6 | 1: required int32 foo = nothing; 7 | 2: optional list baz = nothing; 8 | } 9 | 10 | 11 | struct Struct_v2 12 | { 13 | 1: required int32 foo = nothing; 14 | 2: optional list baz = nothing; 15 | 3: optional double bar = nothing; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /cpp/test/core/unit_test_limits.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef _DEBUG 6 | const uint32_t c_max_string_length = 20; 7 | const uint32_t c_max_list_size = 10; 8 | const uint32_t c_iterations = 1; 9 | #else 10 | const uint32_t c_max_string_length = 50; 11 | const uint32_t c_max_list_size = 20; 12 | const uint32_t c_iterations = 5; 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /examples/cpp/core/scoped_allocator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_codegen (scoped_alloc.bond 2 | OPTIONS 3 | --allocator=\"examples::scoped_allocator::MyAllocator\" 4 | --header=\\\"allocator.h\\\" 5 | --alloc-ctors 6 | --scoped-alloc) 7 | 8 | add_bond_test (scoped_alloc 9 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/scoped_alloc_types.cpp 10 | scoped_alloc.cpp) 11 | -------------------------------------------------------------------------------- /examples/java/core/nothing_default/src/main/bond/nothing_default.bond: -------------------------------------------------------------------------------- 1 | namespace examples.nothing_default 2 | 3 | 4 | struct Struct_v1 5 | { 6 | 1: required int32 foo = nothing; 7 | 2: optional list baz = nothing; 8 | } 9 | 10 | 11 | struct Struct_v2 12 | { 13 | 1: required int32 foo = nothing; 14 | 2: optional list baz = nothing; 15 | 3: optional double bar = nothing; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /cpp/inc/bond/core/customize.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "traits.h" 9 | 10 | namespace bond 11 | { 12 | 13 | 14 | template struct 15 | is_protocol_enabled 16 | : std::false_type {}; 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /examples/cpp/core/runtime_schema/runtime_schema.bond: -------------------------------------------------------------------------------- 1 | namespace examples.runtime_schema 2 | 3 | struct Struct1 4 | { 5 | 0: uint32 n; 6 | 1: string str = "this is a string"; 7 | 2: vector items; 8 | } 9 | 10 | 11 | struct Struct2 12 | { 13 | [MyAttribute("Value of the attribute")] 14 | 0: map mapStruct1; 15 | 1: nullable nullableStruct1; 16 | } 17 | -------------------------------------------------------------------------------- /cs/.gitignore: -------------------------------------------------------------------------------- 1 | # Build and test artifacts 2 | bin/ 3 | obj/ 4 | TestResults/ 5 | tools/ 6 | Debug/ 7 | Release/ 8 | 9 | # Nuget packages 10 | packages/ 11 | 12 | # Profiler artifacts 13 | *.exe.manifest 14 | *.vsp 15 | 16 | # Resharper cache 17 | _ReSharper.* 18 | 19 | # Visual Studio 20 | *.sdf 21 | *.suo 22 | *.user 23 | *.opendb 24 | *.opensdf 25 | *.psess 26 | *.VC.db 27 | 28 | # MSBuild binary log 29 | msbuild.binlog 30 | -------------------------------------------------------------------------------- /examples/python/core/extension/extension.bond: -------------------------------------------------------------------------------- 1 | namespace example.python 2 | 3 | enum Color 4 | { 5 | Blue, 6 | Hazelnut, 7 | Green, 8 | Brown, 9 | Red 10 | } 11 | 12 | 13 | struct Person 14 | { 15 | 0: string first_name; 16 | 1: string last_name; 17 | 2: Color eyes = Brown; 18 | 3: blob hash; 19 | } 20 | 21 | 22 | struct Example 23 | { 24 | 0: map people; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /java/gradle-plugin/src/main/groovy/org/bondlib/gradle/BondPlugin.groovy: -------------------------------------------------------------------------------- 1 | package org.bondlib.gradle 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | 6 | class BondPlugin implements Plugin { 7 | @Override 8 | void apply(Project project) { 9 | project.tasks.create("compileBond", BondProdCodegen) 10 | project.tasks.create("compileTestBond", BondTestCodegen) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cmake/FindJavaBuildTools.cmake: -------------------------------------------------------------------------------- 1 | find_program (GRADLE_EXECUTABLE gradle) 2 | 3 | if (GRADLE_EXECUTABLE) 4 | execute_process ( 5 | COMMAND ${GRADLE_EXECUTABLE} --version 6 | OUTPUT_VARIABLE gradle_version) 7 | message (STATUS "gradle found at ${GRADLE_EXECUTABLE}") 8 | message (STATUS "${gradle_version}") 9 | else() 10 | message (FATAL_ERROR "gradle was not found. Java code cannot be built.") 11 | endif() 12 | -------------------------------------------------------------------------------- /compiler/tests/generated/maybe_blob_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "maybe_blob_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Foo::Schema::metadata 9 | = Foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Foo::Schema::s_b_metadata 12 | = ::bond::reflection::MetadataInit(::bond::nothing, "b"); 13 | 14 | 15 | } // namespace tests 16 | -------------------------------------------------------------------------------- /cs/src/io/properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | 6 | [assembly: AssemblyTitle("Bond.IO")] 7 | [assembly: AssemblyCompany("Microsoft")] 8 | [assembly: AssemblyProduct("Bond")] 9 | [assembly: AssemblyCopyright("Copyright (C) Microsoft. All rights reserved.")] 10 | -------------------------------------------------------------------------------- /examples/cs/.gitignore: -------------------------------------------------------------------------------- 1 | # Build and test artifacts 2 | bin/ 3 | obj/ 4 | TestResults/ 5 | tools/ 6 | Debug/ 7 | Release/ 8 | 9 | # Nuget packages 10 | packages/ 11 | 12 | # Profiler artifacts 13 | *.exe.manifest 14 | *.vsp 15 | 16 | # Resharper cache 17 | _ReSharper.* 18 | 19 | # Visual Studio 20 | *.sdf 21 | *.suo 22 | *.user 23 | *.opendb 24 | *.opensdf 25 | *.psess 26 | *.VC.db 27 | 28 | # MSBuild binary log 29 | msbuild.binlog 30 | -------------------------------------------------------------------------------- /examples/python/core/extension/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_python_module (python_extension 2 | extension.cpp 3 | extension.bond 4 | example.py) 5 | 6 | target_compile_definitions (python_extension PRIVATE 7 | -DBOND_COMPACT_BINARY_PROTOCOL 8 | -DBOND_SIMPLE_JSON_PROTOCOL) 9 | 10 | add_python_test ( 11 | NAME python_extension 12 | MODULE python_extension 13 | SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/example.py) 14 | -------------------------------------------------------------------------------- /cmake/NoDebug.cmake: -------------------------------------------------------------------------------- 1 | macro (_debug_none var) 2 | string (REPLACE /debug /debug:None ${var} ${${var}}) 3 | endmacro() 4 | 5 | macro (no_pdb) 6 | if (MSVC) 7 | _debug_none (CMAKE_EXE_LINKER_FLAGS_DEBUG) 8 | _debug_none (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO) 9 | _debug_none (CMAKE_MODULE_LINKER_FLAGS_DEBUG) 10 | _debug_none (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO) 11 | endif() 12 | endmacro() 13 | -------------------------------------------------------------------------------- /compiler/tests/generated/import_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "import_reflection.h" 3 | #include 4 | 5 | namespace import_test 6 | { 7 | 8 | const ::bond::Metadata HasEmpty::Schema::metadata 9 | = HasEmpty::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata HasEmpty::Schema::s_e_metadata 12 | = ::bond::reflection::MetadataInit("e"); 13 | 14 | 15 | } // namespace import_test 16 | -------------------------------------------------------------------------------- /cpp/test/core/precompiled.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef ENABLE_TEST_CASE 9 | # include 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | using namespace unittest; 16 | 17 | #include "unit_test_util.h" 18 | -------------------------------------------------------------------------------- /cs/src/json/properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | 6 | [assembly: AssemblyTitle("Bond.JSON")] 7 | [assembly: AssemblyCompany("Microsoft")] 8 | [assembly: AssemblyProduct("Bond")] 9 | [assembly: AssemblyCopyright("Copyright (C) Microsoft. All rights reserved.")] 10 | -------------------------------------------------------------------------------- /doc/src/reference_index.md: -------------------------------------------------------------------------------- 1 | Bond project has ended 2 | ====================== 3 | 4 | As of March 2025, the Bond open-source project has ended. There will be no 5 | further activity in this project: no new features, no bug fixes, and, 6 | importantly, no security fixes. 7 | 8 | The documentation as it existed at the time of the end of the project 9 | follows. 10 | 11 | Bond Reference 12 | ============== 13 | 14 | - [C++](cpp\index.html) 15 | -------------------------------------------------------------------------------- /examples/cpp/core/compile_time_schema/compile_time_schema.bond: -------------------------------------------------------------------------------- 1 | namespace examples.compile_time_schema 2 | 3 | struct Struct1 4 | { 5 | 0: uint32 n; 6 | 1: string str = "this is a string"; 7 | 2: vector items; 8 | } 9 | 10 | 11 | struct Struct2 12 | { 13 | [MyAttribute("Value of the attribute")] 14 | 0: map mapStruct1; 15 | 1: nullable nullableStruct1; 16 | } 17 | -------------------------------------------------------------------------------- /examples/cpp/core/time_alias/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_codegen (time_alias.bond 2 | OPTIONS 3 | --using=\"time=boost::posix_time::ptime\" 4 | --header=\"\" 5 | --type-aliases) 6 | 7 | add_bond_test (time_alias 8 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/time_alias_types.cpp 9 | time_alias.cpp) 10 | 11 | target_link_libraries (time_alias PRIVATE 12 | ${Boost_DATE_TIME_LIBRARY}) 13 | -------------------------------------------------------------------------------- /examples/python/core/extension/extension.cpp: -------------------------------------------------------------------------------- 1 | #include "extension_reflection.h" 2 | #include 3 | 4 | BOOST_PYTHON_MODULE(python_extension) 5 | { 6 | using namespace example::python; 7 | 8 | // Expose the Example struct to Python. 9 | // Any other structs or enums referenced by Example are automatically 10 | // exposed as well. 11 | bond::python::struct_() 12 | .def(); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /compiler/tests/generated/allocator/maybe_blob_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "maybe_blob_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Foo::Schema::metadata 9 | = Foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Foo::Schema::s_b_metadata 12 | = ::bond::reflection::MetadataInit(::bond::nothing, "b"); 13 | 14 | 15 | } // namespace tests 16 | -------------------------------------------------------------------------------- /compiler/tests/generated/alloc_ctors/import_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "import_reflection.h" 3 | #include 4 | 5 | namespace import_test 6 | { 7 | 8 | const ::bond::Metadata HasEmpty::Schema::metadata 9 | = HasEmpty::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata HasEmpty::Schema::s_e_metadata 12 | = ::bond::reflection::MetadataInit("e"); 13 | 14 | 15 | } // namespace import_test 16 | -------------------------------------------------------------------------------- /compiler/tests/generated/alloc_ctors/maybe_blob_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "maybe_blob_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Foo::Schema::metadata 9 | = Foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Foo::Schema::s_b_metadata 12 | = ::bond::reflection::MetadataInit(::bond::nothing, "b"); 13 | 14 | 15 | } // namespace tests 16 | -------------------------------------------------------------------------------- /compiler/tests/generated/allocator/import_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "import_reflection.h" 3 | #include 4 | 5 | namespace import_test 6 | { 7 | 8 | const ::bond::Metadata HasEmpty::Schema::metadata 9 | = HasEmpty::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata HasEmpty::Schema::s_e_metadata 12 | = ::bond::reflection::MetadataInit("e"); 13 | 14 | 15 | } // namespace import_test 16 | -------------------------------------------------------------------------------- /compiler/tests/generated/type_aliases/import_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "import_reflection.h" 3 | #include 4 | 5 | namespace import_test 6 | { 7 | 8 | const ::bond::Metadata HasEmpty::Schema::metadata 9 | = HasEmpty::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata HasEmpty::Schema::s_e_metadata 12 | = ::bond::reflection::MetadataInit("e"); 13 | 14 | 15 | } // namespace import_test 16 | -------------------------------------------------------------------------------- /compiler/tests/generated/type_aliases/maybe_blob_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "maybe_blob_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Foo::Schema::metadata 9 | = Foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Foo::Schema::s_b_metadata 12 | = ::bond::reflection::MetadataInit(::bond::nothing, "b"); 13 | 14 | 15 | } // namespace tests 16 | -------------------------------------------------------------------------------- /tools/ci-scripts/linux/build_hs.zsh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | 3 | set -eux 4 | 5 | local BOND_CMAKE_FLAGS="$BOND_CMAKE_FLAGS -DBOND_SKIP_CORE_TESTS=TRUE" 6 | cmake \ 7 | -DBOND_STACK_OPTIONS="--allow-different-user" \ 8 | -DCMAKE_CXX_FLAGS="$BOND_CXX_FLAGS" -DCMAKE_C_FLAGS="$BOND_CC_FLAGS" \ 9 | ${=BOND_CMAKE_FLAGS} \ 10 | $BOND_ROOT 11 | 12 | make gbc-tests 13 | 14 | cd $BOND_ROOT/compiler 15 | $BUILD_ROOT/compiler/build/gbc-tests/gbc-tests 16 | -------------------------------------------------------------------------------- /compiler/tests/generated/scoped_allocator/import_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "import_reflection.h" 3 | #include 4 | 5 | namespace import_test 6 | { 7 | 8 | const ::bond::Metadata HasEmpty::Schema::metadata 9 | = HasEmpty::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata HasEmpty::Schema::s_e_metadata 12 | = ::bond::reflection::MetadataInit("e"); 13 | 14 | 15 | } // namespace import_test 16 | -------------------------------------------------------------------------------- /compiler/tests/generated/scoped_allocator/maybe_blob_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "maybe_blob_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Foo::Schema::metadata 9 | = Foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Foo::Schema::s_b_metadata 12 | = ::bond::reflection::MetadataInit(::bond::nothing, "b"); 13 | 14 | 15 | } // namespace tests 16 | -------------------------------------------------------------------------------- /examples/cpp/core/schema_view/schema_view.bond: -------------------------------------------------------------------------------- 1 | namespace examples.schema_view 2 | 3 | 4 | struct Example 5 | { 6 | 0: uint32 num; 7 | 1: string str; 8 | 2: vector items; 9 | } 10 | 11 | 12 | // ExampleView is a view of Example containing two fields: num and str. 13 | // In every other respect struct ExampleView will be identical to Example. 14 | struct ExampleView view_of Example 15 | { 16 | num, str; 17 | } 18 | -------------------------------------------------------------------------------- /examples/cs/core/schema_view/schema_view.bond: -------------------------------------------------------------------------------- 1 | namespace examples.schema_view 2 | 3 | 4 | struct Example 5 | { 6 | 0: uint32 num; 7 | 1: string str; 8 | 2: vector items; 9 | } 10 | 11 | 12 | // ExampleView is a view of Example containing two fields: num and str. 13 | // In every other respect struct ExampleView will be identical to Example. 14 | struct ExampleView view_of Example 15 | { 16 | num, str; 17 | } 18 | -------------------------------------------------------------------------------- /doc/doxygen/doxygen.cmake: -------------------------------------------------------------------------------- 1 | # Doxygen doesn't allow specifying output directory via command line arguments 2 | # so we need this silly workaround to set environment variable that is then 3 | # used in the .doxygen file. 4 | set (ENV{BOND_DOXYGEN_OUTPUT_DIR} ${Doxygen_OUTPUT_DIR}) 5 | 6 | execute_process ( 7 | COMMAND ${Doxygen_EXECUTABLE} doxygen/bond.doxygen 8 | RESULT_VARIABLE error) 9 | 10 | if (error) 11 | message (FATAL_ERROR) 12 | endif() 13 | -------------------------------------------------------------------------------- /compiler/tests/schema/basic_types.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct BasicTypes 4 | { 5 | 0: bool _bool; 6 | 2: string _str; 7 | 3: wstring _wstr; 8 | 14: int8 _int8; 9 | 15: int16 _int16; 10 | 16: int32 _int32; 11 | 17: int64 _int64; 12 | 13: uint8 _uint8; 13 | 11: uint16 _uint16; 14 | 12: uint32 _uint32; 15 | 10: uint64 _uint64; 16 | 18: double _double; 17 | 20: float _float; 18 | 21: blob _blob; 19 | } 20 | -------------------------------------------------------------------------------- /examples/java/core/schema_view/src/main/bond/schema_view.bond: -------------------------------------------------------------------------------- 1 | namespace examples.schema_view 2 | 3 | 4 | struct Example 5 | { 6 | 0: uint32 num; 7 | 1: string str; 8 | 2: vector items; 9 | } 10 | 11 | 12 | // ExampleView is a view of Example containing two fields: num and str. 13 | // In every other respect struct ExampleView will be identical to Example. 14 | struct ExampleView view_of Example 15 | { 16 | num, str; 17 | } 18 | -------------------------------------------------------------------------------- /python/test/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_python_module (python_unit_test 2 | unit_test.cpp 3 | unit_test.bond 4 | unit_test.py) 5 | 6 | target_compile_definitions (python_unit_test PRIVATE 7 | -DBOND_COMPACT_BINARY_PROTOCOL) 8 | 9 | # disable generation of debug symbols to speed up build 10 | no_pdb() 11 | 12 | add_python_test ( 13 | NAME python_unit_test 14 | MODULE python_unit_test 15 | SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/unit_test.py) 16 | -------------------------------------------------------------------------------- /compiler/tests/schema/basic_types_nsmapped.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | struct BasicTypes 4 | { 5 | 0: bool _bool; 6 | 2: string _str; 7 | 3: wstring _wstr; 8 | 14: int8 _int8; 9 | 15: int16 _int16; 10 | 16: int32 _int32; 11 | 17: int64 _int64; 12 | 13: uint8 _uint8; 13 | 11: uint16 _uint16; 14 | 12: uint32 _uint32; 15 | 10: uint64 _uint64; 16 | 18: double _double; 17 | 20: float _float; 18 | 21: blob _blob; 19 | } 20 | -------------------------------------------------------------------------------- /java/core/src/test/bond/imports/dir1/dir2/common.bond: -------------------------------------------------------------------------------- 1 | namespace org.bondlib.test 2 | 3 | enum MonthOfYear { 4 | January = 1, 5 | February, 6 | March, 7 | April, 8 | May, 9 | June, 10 | July, 11 | August, 12 | September, 13 | October, 14 | November, 15 | December 16 | } 17 | 18 | struct Empty {} 19 | 20 | struct Base { 21 | 0: int32 baseInt; 22 | } 23 | 24 | struct Derived : Base { 25 | 0: int32 derivedInt; 26 | } 27 | -------------------------------------------------------------------------------- /examples/cs/core/polymorphic_container/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | enum Type 4 | { 5 | Unknown, 6 | Circle, 7 | Rectangle 8 | } 9 | 10 | struct Shape 11 | { 12 | 0: Type Type = Unknown; 13 | } 14 | 15 | struct Circle : Shape 16 | { 17 | 0: double Radius; 18 | } 19 | 20 | struct Rectangle : Shape 21 | { 22 | 0: double Width; 23 | 1: double Height; 24 | } 25 | 26 | struct Polymorphic 27 | { 28 | 0: vector> Shapes; 29 | } 30 | -------------------------------------------------------------------------------- /examples/cpp/core/generic_tree/generic_tree.bond: -------------------------------------------------------------------------------- 1 | namespace examples.generic_tree 2 | 3 | // For recursive data structures, a forward declaration is needed so Node 4 | // can refer back to itself. 5 | struct Node; 6 | 7 | struct Node 8 | { 9 | // In order to prevent infinite recursion, a nullable> field 10 | // must be used to hold other Nodes. 11 | 0: nullable> left; 12 | 1: nullable> right; 13 | 2: T data; 14 | } 15 | -------------------------------------------------------------------------------- /examples/cs/core/generic_tree/generic_tree.bond: -------------------------------------------------------------------------------- 1 | namespace examples.generic_tree 2 | 3 | // For recursive data structures, a forward declaration is needed so Node 4 | // can refer back to itself. 5 | struct Node; 6 | 7 | struct Node 8 | { 9 | // In order to prevent infinite recursion, a nullable> field 10 | // must be used to hold other Nodes. 11 | 0: nullable> left; 12 | 1: nullable> right; 13 | 2: T data; 14 | } 15 | -------------------------------------------------------------------------------- /tools/syntax/VsCode/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /cmake/FindStack.cmake: -------------------------------------------------------------------------------- 1 | FIND_PROGRAM(STACK_EXECUTABLE stack) 2 | 3 | SET(STACK_FOUND FALSE) 4 | 5 | IF (STACK_EXECUTABLE) 6 | SET(STACK_FOUND TRUE) 7 | 8 | execute_process ( 9 | COMMAND ${STACK_EXECUTABLE} --version 10 | OUTPUT_VARIABLE stack_version) 11 | 12 | string (STRIP ${stack_version} stack_version) 13 | 14 | MESSAGE(STATUS "Stack found at ${STACK_EXECUTABLE}. ${stack_version}") 15 | ELSE() 16 | MESSAGE(FATAL_ERROR "Stack was not found.") 17 | ENDIF() 18 | -------------------------------------------------------------------------------- /cpp/src/bond/protocol/detail/rapidjson_utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #include 5 | 6 | #if BOND_LIB_TYPE == BOND_LIB_TYPE_HEADER 7 | #error This source file should not be compiled for BOND_LIB_TYPE_HEADER 8 | #endif 9 | 10 | #include 11 | #include 12 | -------------------------------------------------------------------------------- /cs/test/core/Containers.bond: -------------------------------------------------------------------------------- 1 | import "UnitTest.bond" 2 | 3 | namespace UnitTest 4 | 5 | struct NestedContainers 6 | { 7 | 0: vector> vvb; 8 | 1: list>> vnc; 9 | 2: vector> vvbt; 10 | 3: vector> vln; 11 | 4: list> lvs; 12 | 5: list> lsf; 13 | 6: vector> vsb; 14 | 7: map> mslb; 15 | 8: map> mimbn; 16 | } 17 | -------------------------------------------------------------------------------- /examples/java/core/generic_tree/src/main/bond/generic_tree.bond: -------------------------------------------------------------------------------- 1 | namespace examples.generic_tree 2 | 3 | // For recursive data structures, a forward declaration is needed so Node 4 | // can refer back to itself. 5 | struct Node; 6 | 7 | struct Node 8 | { 9 | // In order to prevent infinite recursion, a nullable> field 10 | // must be used to hold other Nodes. 11 | 0: nullable> left; 12 | 1: nullable> right; 13 | 2: T data; 14 | } 15 | -------------------------------------------------------------------------------- /examples/java/core/polymorphic_container/src/main/bond/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | enum Type 4 | { 5 | Unknown, 6 | Circle, 7 | Rectangle 8 | } 9 | 10 | struct Shape 11 | { 12 | 0: Type Type = Unknown; 13 | } 14 | 15 | struct Circle : Shape 16 | { 17 | 0: double Radius; 18 | } 19 | 20 | struct Rectangle : Shape 21 | { 22 | 0: double Width; 23 | 1: double Height; 24 | } 25 | 26 | struct Polymorphic 27 | { 28 | 0: vector> Shapes; 29 | } 30 | -------------------------------------------------------------------------------- /python/test/compat/compat.cmake: -------------------------------------------------------------------------------- 1 | set (ENV{PYTHONPATH} ${PYTHON_COMPAT}) 2 | 3 | function (run) 4 | execute_process ( 5 | COMMAND ${ARGV} 6 | RESULT_VARIABLE error) 7 | if (error) 8 | message (FATAL_ERROR) 9 | endif() 10 | endfunction() 11 | 12 | run (${PYTHON_EXECUTABLE} ${SOURCE_DIR}/compat.py -d ${COMPAT_DATA}/compat.${TEST}.dat -s compat.${TEST}.py.dat ${TEST}) 13 | run (${BOND_COMPAT} ${TEST} -d compat.${TEST}.py.dat expected.py.${TEST} deserialized.py.${TEST}) 14 | -------------------------------------------------------------------------------- /cs/src/core/expressions/ISerializerGenerator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace Bond.Expressions 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq.Expressions; 9 | 10 | public interface ISerializerGenerator 11 | { 12 | IEnumerable>> Generate(IParser parser); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /cs/test/codegen/default-ignore-output/ConsumeCodegen.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace CodegenTest.DefaultIgnoresOutput 5 | { 6 | public static class UsesCodegen 7 | { 8 | public static SimpleType Make() 9 | { 10 | return new SimpleType 11 | { 12 | _int32 = 42, 13 | }; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/cpp/core/static_array/static_array.bond: -------------------------------------------------------------------------------- 1 | namespace examples.static_array 2 | 3 | // Define array as an alias of vector 4 | using array = vector; 5 | 6 | struct Example 7 | { 8 | // Static array of 64 32-bit integers 9 | // Since std::array does not have a concept of default value we need to 10 | // make the field required in order to avoid debug assert saying that we 11 | // are trying to deserialize into non-clean object. 12 | 0: required array features; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /cs/test/core/ReadOnly.bond: -------------------------------------------------------------------------------- 1 | import "UnitTest.bond" 2 | 3 | namespace UnitTest.Readonly 4 | 5 | struct BasicTypes view_of UnitTest.BasicTypes 6 | { 7 | _bool; 8 | _str; 9 | _wstr; 10 | _int8; 11 | _int16; 12 | _int32; 13 | _int64; 14 | _uint8; 15 | _uint16; 16 | _uint32; 17 | _uint64; 18 | _double; 19 | _float; 20 | _enum1; 21 | }; 22 | 23 | struct SimpleContainers view_of UnitTest.SimpleContainers 24 | { 25 | strings; 26 | basics; 27 | numbers; 28 | }; 29 | -------------------------------------------------------------------------------- /java/core/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /java/json/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /tools/ci-scripts/linux/image-cleanup/mypy.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | warn_no_return=True 3 | warn_unused_configs=True 4 | 5 | # The same set of flags as enabled by --strict 6 | check-untyped-defs=True 7 | disallow-incomplete-defs=True 8 | disallow-subclassing-any=True 9 | disallow-untyped-calls=True 10 | disallow-untyped-decorators=True 11 | disallow-untyped-defs=True 12 | no-implicit-optional=True 13 | strict-optional=True 14 | warn-redundant-casts=True 15 | warn-return-any=True 16 | warn-unused-configs=True 17 | warn-unused-ignores=True 18 | -------------------------------------------------------------------------------- /compiler/tests/generated/alias_key_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "alias_key_reflection.h" 3 | #include 4 | 5 | namespace test 6 | { 7 | 8 | const ::bond::Metadata foo::Schema::metadata 9 | = foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata foo::Schema::s_m_metadata 12 | = ::bond::reflection::MetadataInit("m"); 13 | 14 | const ::bond::Metadata foo::Schema::s_s_metadata 15 | = ::bond::reflection::MetadataInit("s"); 16 | 17 | 18 | } // namespace test 19 | -------------------------------------------------------------------------------- /cpp/test/compat/core/compat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "compat_types.h" 4 | #include "compat_no_generics_types.h" 5 | #include "cmd_arg_types.h" 6 | #include 7 | 8 | using namespace unittest::compat; 9 | 10 | void Init(Test test, Compat& obj); 11 | bond::blob Serialize(Test test, const Compat& obj); 12 | void Deserialize(Test test, const bond::blob& buffer, Compat& obj, bond::SchemaDef& schema); 13 | void Convert(const Compat& from, CompatNoGenerics& to); 14 | 15 | const int MAX_SIZE = 6 * 1024 * 1024; 16 | -------------------------------------------------------------------------------- /java/compat/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /java/gradle-plugin/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /compiler/tests/generated/allocator/alias_key_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "alias_key_reflection.h" 3 | #include 4 | 5 | namespace test 6 | { 7 | 8 | const ::bond::Metadata foo::Schema::metadata 9 | = foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata foo::Schema::s_m_metadata 12 | = ::bond::reflection::MetadataInit("m"); 13 | 14 | const ::bond::Metadata foo::Schema::s_s_metadata 15 | = ::bond::reflection::MetadataInit("s"); 16 | 17 | 18 | } // namespace test 19 | -------------------------------------------------------------------------------- /cpp/inc/bond/core/detail/nonassignable.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace bond 9 | { 10 | namespace detail 11 | { 12 | class nonassignable 13 | { 14 | protected: 15 | nonassignable() {} 16 | ~nonassignable() {} 17 | private: 18 | nonassignable& operator=(const nonassignable&); 19 | }; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /compiler/tests/generated/alloc_ctors/alias_key_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "alias_key_reflection.h" 3 | #include 4 | 5 | namespace test 6 | { 7 | 8 | const ::bond::Metadata foo::Schema::metadata 9 | = foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata foo::Schema::s_m_metadata 12 | = ::bond::reflection::MetadataInit("m"); 13 | 14 | const ::bond::Metadata foo::Schema::s_s_metadata 15 | = ::bond::reflection::MetadataInit("s"); 16 | 17 | 18 | } // namespace test 19 | -------------------------------------------------------------------------------- /compiler/tests/generated/type_aliases/alias_key_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "alias_key_reflection.h" 3 | #include 4 | 5 | namespace test 6 | { 7 | 8 | const ::bond::Metadata foo::Schema::metadata 9 | = foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata foo::Schema::s_m_metadata 12 | = ::bond::reflection::MetadataInit("m"); 13 | 14 | const ::bond::Metadata foo::Schema::s_s_metadata 15 | = ::bond::reflection::MetadataInit("s"); 16 | 17 | 18 | } // namespace test 19 | -------------------------------------------------------------------------------- /compiler/tests/schema/bond_meta.json: -------------------------------------------------------------------------------- 1 | {"namespaces":[{"name":["deprecated","bondmeta"]}],"imports":[],"declarations":[{"structBase":null,"tag":"Struct","structFields":[{"fieldModifier":"Optional","fieldDefault":null,"fieldType":"bond_meta::full_name","fieldName":"full_name","fieldAttributes":[],"fieldOrdinal":0},{"fieldModifier":"Optional","fieldDefault":null,"fieldType":"bond_meta::name","fieldName":"name","fieldAttributes":[],"fieldOrdinal":1}],"declParams":[],"declNamespaces":[{"name":["deprecated","bondmeta"]}],"declName":"HasMetaFields","declAttributes":[]}]} -------------------------------------------------------------------------------- /cs/src/core/io/ICloneable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace Bond.IO 5 | { 6 | /// 7 | /// Clones an input stream or protocol reader 8 | /// 9 | /// Object type 10 | public interface ICloneable 11 | { 12 | /// 13 | /// Create a clone 14 | /// 15 | T Clone(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tools/syntax/VsCode/bond.configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | // symbol used for single line comment. Remove this entry if your language does not support line comments 4 | "lineComment": "//", 5 | // symbols used for start and end a block comment. Remove this entry if your language does not support block comments 6 | "blockComment": [ "/*", "*/" ] 7 | }, 8 | // symbols used as brackets 9 | "brackets": [ 10 | ["{", "}"], 11 | ["[", "]"], 12 | ["(", ")"] 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /compiler/tests/generated/scoped_allocator/alias_key_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "alias_key_reflection.h" 3 | #include 4 | 5 | namespace test 6 | { 7 | 8 | const ::bond::Metadata foo::Schema::metadata 9 | = foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata foo::Schema::s_m_metadata 12 | = ::bond::reflection::MetadataInit("m"); 13 | 14 | const ::bond::Metadata foo::Schema::s_s_metadata 15 | = ::bond::reflection::MetadataInit("s"); 16 | 17 | 18 | } // namespace test 19 | -------------------------------------------------------------------------------- /examples/cpp/core/access_control/access_control.bond: -------------------------------------------------------------------------------- 1 | namespace examples.access_control 2 | 3 | struct Person 4 | { 5 | [ACL("identity")] 6 | 0: string name; 7 | } 8 | 9 | struct Employee : Person 10 | { 11 | [ACL("location")] 12 | 0: string address; 13 | } 14 | 15 | struct Company 16 | { 17 | [ACL("identity")] 18 | 0: string ticker; 19 | 20 | [ACL("location")] 21 | 1: string city; 22 | 23 | [ACL("all")] 24 | 2: vector employees; 25 | 26 | [ACL("identity")] 27 | 3: Employee ceo; 28 | } 29 | -------------------------------------------------------------------------------- /compiler/tests/generated/schemadef/example.SomeStruct.json: -------------------------------------------------------------------------------- 1 | { 2 | "structs": [ 3 | { 4 | "fields": [ 5 | { 6 | "id": 0, 7 | "metadata": { 8 | "default_value": { 9 | "int_value": 123 10 | }, 11 | "name": "someField" 12 | }, 13 | "type": { 14 | "id": 16 15 | } 16 | } 17 | ], 18 | "metadata": { 19 | "name": "SomeStruct", 20 | "qualified_name": "example.some.SomeStruct" 21 | } 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /cs/test/core/NamespaceConflict.bond: -------------------------------------------------------------------------------- 1 | namespace SomeNamespace 2 | 3 | // Having both namespaces X and X.Bond might cause compilation failures if the 4 | // codegen does not handle the global::Bond namespace correctly. The purpose of this file is 5 | // to ensure that this does not happen. 6 | [someAttribute("foo")] 7 | struct Foo 8 | { 9 | [someAttribute("bar")] 10 | 1: wstring wstring_field; 11 | 12 | 2: nullable nullable_field; 13 | 14 | 3: required bonded generic_field; 15 | 16 | 4: required_optional bool required_optional_field; 17 | } 18 | -------------------------------------------------------------------------------- /cs/nuget/.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;;; Directory Local Variables 2 | ;;; For more information see (info "(emacs) Directory Variables") 3 | 4 | ( 5 | ; In the .nuspec files we want line sorting for things like to 6 | ; be CASE SENSITIVE, otherwise Bond.dll and Bond.xml get sorted really far 7 | ; away from each other. 8 | (nil . ((sort-fold-case . nil))) 9 | ; The nuspec files in this directory are indented with four spaces per 10 | ; level, instead of the typical two for XML-things in the .NET world (like 11 | ; .csproj files). 12 | (nxml-mode . ((nxml-child-indent . 4)))) 13 | -------------------------------------------------------------------------------- /cpp/inc/bond/core/box.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | 12 | 13 | namespace bond 14 | { 15 | 16 | template 17 | Box::type> make_box(T&& value) 18 | { 19 | Box::type> b; 20 | b.value = std::forward(value); 21 | return b; 22 | } 23 | 24 | } // namespace bond 25 | -------------------------------------------------------------------------------- /cpp/inc/bond/core/detail/value_extern.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "extern_macro.h" 8 | 9 | 10 | namespace bond 11 | { 12 | 13 | #define BOND_DETAIL_ValueVoid_Apply(Reader, Writer) \ 14 | void value::_Apply(const Serializer&) const; 15 | 16 | BOND_DETAIL_EXTERN(BOND_DETAIL_ValueVoid_Apply, BOND_DETAIL_BUILTIN_READERS_WRITERS) 17 | 18 | 19 | } // namespace bond 20 | -------------------------------------------------------------------------------- /compiler/tests/generated/empty_types.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | // suppress "Missing XML comment for publicly visible type or member" 4 | #pragma warning disable 1591 5 | 6 | 7 | #region ReSharper warnings 8 | // ReSharper disable PartialTypeWithSinglePart 9 | // ReSharper disable RedundantNameQualifier 10 | // ReSharper disable InconsistentNaming 11 | // ReSharper disable CheckNamespace 12 | // ReSharper disable UnusedParameter.Local 13 | // ReSharper disable RedundantUsingDirective 14 | #endregion 15 | 16 | namespace tests 17 | { 18 | using System.Collections.Generic; 19 | 20 | 21 | } // tests 22 | -------------------------------------------------------------------------------- /compiler/tests/schema/field_modifiers.json: -------------------------------------------------------------------------------- 1 | {"namespaces":[{"name":["tests"]}],"imports":[],"declarations":[{"structBase":null,"tag":"Struct","structFields":[{"fieldModifier":"Optional","fieldDefault":null,"fieldType":"bool","fieldName":"o","fieldAttributes":[],"fieldOrdinal":0},{"fieldModifier":"Required","fieldDefault":null,"fieldType":"int16","fieldName":"r","fieldAttributes":[],"fieldOrdinal":1},{"fieldModifier":"RequiredOptional","fieldDefault":null,"fieldType":"double","fieldName":"ro","fieldAttributes":[],"fieldOrdinal":2}],"declParams":[],"declNamespaces":[{"name":["tests"]}],"declName":"Foo","declAttributes":[]}]} -------------------------------------------------------------------------------- /cpp/src/bond/core/value.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #include 5 | 6 | #if BOND_LIB_TYPE == BOND_LIB_TYPE_HEADER 7 | #error This source file should not be compiled for BOND_LIB_TYPE_HEADER 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | 14 | namespace bond 15 | { 16 | 17 | BOND_DETAIL_INSTANTIATE(BOND_DETAIL_ValueVoid_Apply, BOND_DETAIL_BUILTIN_READERS_WRITERS) 18 | 19 | } // namespace bond 20 | -------------------------------------------------------------------------------- /test/compat/core/schemas/compat_no_generics.bond: -------------------------------------------------------------------------------- 1 | import "compat.bond" 2 | 3 | namespace unittest.compat 4 | 5 | struct CompatNoGenerics view_of Compat 6 | { 7 | m_basicTypes; 8 | m_containers; 9 | m_withBase; 10 | m_nullable_string; 11 | m_nullable_uint64; 12 | // m_generic2; 13 | // m_generic1; 14 | // m_generic0; 15 | // m_generic_another_struct; 16 | // m_generic_another_enum; 17 | // m_defaults; 18 | m_basicUnintialized; 19 | m_enum1; 20 | m_enum2; 21 | m_enum3; 22 | m_enum4; 23 | m_enum5; 24 | m_enum6; 25 | m_nullable; 26 | }; 27 | -------------------------------------------------------------------------------- /compiler/tests/generated/collection-interfaces/empty_types.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | // suppress "Missing XML comment for publicly visible type or member" 4 | #pragma warning disable 1591 5 | 6 | 7 | #region ReSharper warnings 8 | // ReSharper disable PartialTypeWithSinglePart 9 | // ReSharper disable RedundantNameQualifier 10 | // ReSharper disable InconsistentNaming 11 | // ReSharper disable CheckNamespace 12 | // ReSharper disable UnusedParameter.Local 13 | // ReSharper disable RedundantUsingDirective 14 | #endregion 15 | 16 | namespace tests 17 | { 18 | using System.Collections.Generic; 19 | 20 | 21 | } // tests 22 | -------------------------------------------------------------------------------- /examples/cpp/core/polymorphic_container/polymorphic_container.bond: -------------------------------------------------------------------------------- 1 | namespace examples.polymorphic_containers 2 | 3 | enum StructKind 4 | { 5 | StructKind_Unknown; 6 | StructKind_Struct1; 7 | StructKind_Struct2; 8 | } 9 | 10 | struct Base 11 | { 12 | 0: StructKind kind = StructKind_Unknown; 13 | } 14 | 15 | 16 | struct Struct1 : Base 17 | { 18 | 0: string str; 19 | 1: uint16 n; 20 | } 21 | 22 | 23 | struct Struct2 : Base 24 | { 25 | 1: bool b; 26 | 2: int32 n; 27 | 3: string str; 28 | } 29 | 30 | 31 | struct Polymorphic 32 | { 33 | 0: list> items; 34 | } 35 | -------------------------------------------------------------------------------- /java/core/src/main/java/org/bondlib/TwoPassProtocolWriter.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package org.bondlib; 5 | 6 | /** 7 | * Provides interface to a writer to pre-run for protocols (like Compact Binary v2) which need two passes. 8 | */ 9 | public interface TwoPassProtocolWriter extends ProtocolWriter { 10 | 11 | /** 12 | * Provide the first-pass writer. 13 | * 14 | * @return the first-pass writer 15 | */ 16 | ProtocolWriter getFirstPassWriter(); 17 | } 18 | -------------------------------------------------------------------------------- /compiler/tests/generated/empty_types.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #if BOND_VERSION < 0x0b00 7 | #error This file was generated by a newer version of the Bond compiler and is incompatible with your version of the Bond library. 8 | #endif 9 | 10 | #if BOND_MIN_CODEGEN_VERSION > 0x0d00 11 | #error This file was generated by an older version of the Bond compiler and is incompatible with your version of the Bond library. 12 | #endif 13 | 14 | #include 15 | #include 16 | 17 | 18 | 19 | namespace tests 20 | { 21 | 22 | } // namespace tests 23 | -------------------------------------------------------------------------------- /cs/src/json/protocols/IJsonReader.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace Bond.Protocols 5 | { 6 | using System; 7 | using Newtonsoft.Json; 8 | 9 | public interface IJsonReader 10 | { 11 | void Read(); 12 | 13 | void Skip(); 14 | 15 | bool EOF { get; } 16 | 17 | JsonToken TokenType { get; } 18 | 19 | object Value { get; } 20 | 21 | int LineNumber { get; } 22 | 23 | int LinePosition { get; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/cpp/core/polymorphic_container_visitor/polymorphic_container_visitor.bond: -------------------------------------------------------------------------------- 1 | namespace examples.polymorphic_containers 2 | 3 | enum StructKind 4 | { 5 | StructKind_Unknown; 6 | StructKind_Struct1; 7 | StructKind_Struct2; 8 | } 9 | 10 | struct Base 11 | { 12 | 0: StructKind kind = StructKind_Unknown; 13 | } 14 | 15 | 16 | struct Struct1 : Base 17 | { 18 | 0: string str; 19 | 1: uint16 n; 20 | } 21 | 22 | 23 | struct Struct2 : Base 24 | { 25 | 1: bool b; 26 | 2: int32 n; 27 | 3: string str; 28 | } 29 | 30 | 31 | struct Polymorphic 32 | { 33 | 0: list> items; 34 | } 35 | -------------------------------------------------------------------------------- /examples/cpp/core/static_library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_codegen (lib/static_library.bond 2 | OPTIONS --apply=compact) 3 | 4 | add_library (static_library_lib EXCLUDE_FROM_ALL 5 | STATIC 6 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/static_library_types.cpp 7 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/static_library_apply.cpp) 8 | 9 | add_target_to_folder (static_library_lib) 10 | 11 | target_link_libraries (static_library_lib PUBLIC 12 | bond) 13 | 14 | add_bond_test (static_library 15 | exe/static_library.cpp) 16 | 17 | target_link_libraries (static_library PRIVATE 18 | static_library_lib) 19 | -------------------------------------------------------------------------------- /compiler/tests/generated/allocator/empty_types.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #if BOND_VERSION < 0x0b00 7 | #error This file was generated by a newer version of the Bond compiler and is incompatible with your version of the Bond library. 8 | #endif 9 | 10 | #if BOND_MIN_CODEGEN_VERSION > 0x0d00 11 | #error This file was generated by an older version of the Bond compiler and is incompatible with your version of the Bond library. 12 | #endif 13 | 14 | #include 15 | #include 16 | 17 | 18 | 19 | namespace tests 20 | { 21 | 22 | } // namespace tests 23 | -------------------------------------------------------------------------------- /compiler/tests/generated/alloc_ctors/empty_types.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #if BOND_VERSION < 0x0b00 7 | #error This file was generated by a newer version of the Bond compiler and is incompatible with your version of the Bond library. 8 | #endif 9 | 10 | #if BOND_MIN_CODEGEN_VERSION > 0x0d00 11 | #error This file was generated by an older version of the Bond compiler and is incompatible with your version of the Bond library. 12 | #endif 13 | 14 | #include 15 | #include 16 | 17 | 18 | 19 | namespace tests 20 | { 21 | 22 | } // namespace tests 23 | -------------------------------------------------------------------------------- /compiler/tests/generated/type_aliases/empty_types.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #if BOND_VERSION < 0x0b00 7 | #error This file was generated by a newer version of the Bond compiler and is incompatible with your version of the Bond library. 8 | #endif 9 | 10 | #if BOND_MIN_CODEGEN_VERSION > 0x0d00 11 | #error This file was generated by an older version of the Bond compiler and is incompatible with your version of the Bond library. 12 | #endif 13 | 14 | #include 15 | #include 16 | 17 | 18 | 19 | namespace tests 20 | { 21 | 22 | } // namespace tests 23 | -------------------------------------------------------------------------------- /compiler/tests/generated/schemadef/maybe_blob.Foo.json: -------------------------------------------------------------------------------- 1 | { 2 | "structs": [ 3 | { 4 | "fields": [ 5 | { 6 | "id": 0, 7 | "metadata": { 8 | "default_value": { 9 | "nothing": true 10 | }, 11 | "name": "b" 12 | }, 13 | "type": { 14 | "element": [ 15 | { 16 | "id": 14 17 | } 18 | ], 19 | "id": 11 20 | } 21 | } 22 | ], 23 | "metadata": { 24 | "name": "Foo", 25 | "qualified_name": "tests.Foo" 26 | } 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /compiler/tests/generated/scoped_allocator/empty_types.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #if BOND_VERSION < 0x0b00 7 | #error This file was generated by a newer version of the Bond compiler and is incompatible with your version of the Bond library. 8 | #endif 9 | 10 | #if BOND_MIN_CODEGEN_VERSION > 0x0d00 11 | #error This file was generated by an older version of the Bond compiler and is incompatible with your version of the Bond library. 12 | #endif 13 | 14 | #include 15 | #include 16 | 17 | 18 | 19 | namespace tests 20 | { 21 | 22 | } // namespace tests 23 | -------------------------------------------------------------------------------- /compiler/tests/generated/inheritance_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "inheritance_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Base::Schema::metadata 9 | = Base::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Base::Schema::s_x_metadata 12 | = ::bond::reflection::MetadataInit("x"); 13 | 14 | 15 | const ::bond::Metadata Foo::Schema::metadata 16 | = Foo::Schema::GetMetadata(); 17 | 18 | const ::bond::Metadata Foo::Schema::s_x_metadata 19 | = ::bond::reflection::MetadataInit("x"); 20 | 21 | 22 | } // namespace tests 23 | -------------------------------------------------------------------------------- /compiler/tests/generated/alloc_ctors/inheritance_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "inheritance_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Base::Schema::metadata 9 | = Base::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Base::Schema::s_x_metadata 12 | = ::bond::reflection::MetadataInit("x"); 13 | 14 | 15 | const ::bond::Metadata Foo::Schema::metadata 16 | = Foo::Schema::GetMetadata(); 17 | 18 | const ::bond::Metadata Foo::Schema::s_x_metadata 19 | = ::bond::reflection::MetadataInit("x"); 20 | 21 | 22 | } // namespace tests 23 | -------------------------------------------------------------------------------- /compiler/tests/generated/allocator/inheritance_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "inheritance_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Base::Schema::metadata 9 | = Base::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Base::Schema::s_x_metadata 12 | = ::bond::reflection::MetadataInit("x"); 13 | 14 | 15 | const ::bond::Metadata Foo::Schema::metadata 16 | = Foo::Schema::GetMetadata(); 17 | 18 | const ::bond::Metadata Foo::Schema::s_x_metadata 19 | = ::bond::reflection::MetadataInit("x"); 20 | 21 | 22 | } // namespace tests 23 | -------------------------------------------------------------------------------- /compiler/tests/generated/bond_meta_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "bond_meta_reflection.h" 3 | #include 4 | 5 | namespace deprecated 6 | { 7 | namespace bondmeta 8 | { 9 | 10 | const ::bond::Metadata HasMetaFields::Schema::metadata 11 | = HasMetaFields::Schema::GetMetadata(); 12 | 13 | const ::bond::Metadata HasMetaFields::Schema::s_full_name_metadata 14 | = ::bond::reflection::MetadataInit("full_name"); 15 | 16 | const ::bond::Metadata HasMetaFields::Schema::s_name_metadata 17 | = ::bond::reflection::MetadataInit("name"); 18 | 19 | 20 | } // namespace bondmeta 21 | } // namespace deprecated 22 | -------------------------------------------------------------------------------- /compiler/tests/generated/type_aliases/inheritance_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "inheritance_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Base::Schema::metadata 9 | = Base::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Base::Schema::s_x_metadata 12 | = ::bond::reflection::MetadataInit("x"); 13 | 14 | 15 | const ::bond::Metadata Foo::Schema::metadata 16 | = Foo::Schema::GetMetadata(); 17 | 18 | const ::bond::Metadata Foo::Schema::s_x_metadata 19 | = ::bond::reflection::MetadataInit("x"); 20 | 21 | 22 | } // namespace tests 23 | -------------------------------------------------------------------------------- /cmake/Folders.cmake: -------------------------------------------------------------------------------- 1 | set_property (GLOBAL PROPERTY USE_FOLDERS On) 2 | 3 | # 4 | # Add the target to "current" folder 5 | # 6 | function (add_target_to_folder target) 7 | set_property (GLOBAL APPEND PROPERTY bond_targets ${target}) 8 | endfunction() 9 | 10 | # 11 | # add_subfolder (subdirectory folder) 12 | # similar to built-in add_subdirectory but groups targets in specified folder 13 | # 14 | macro (add_subfolder dir folder) 15 | set_property (GLOBAL PROPERTY bond_targets) 16 | add_subdirectory (${dir}) 17 | get_property (targets GLOBAL PROPERTY bond_targets) 18 | set_target_properties (${targets} PROPERTIES FOLDER ${folder}) 19 | endmacro() 20 | 21 | -------------------------------------------------------------------------------- /compiler/tests/generated/scoped_allocator/inheritance_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "inheritance_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Base::Schema::metadata 9 | = Base::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Base::Schema::s_x_metadata 12 | = ::bond::reflection::MetadataInit("x"); 13 | 14 | 15 | const ::bond::Metadata Foo::Schema::metadata 16 | = Foo::Schema::GetMetadata(); 17 | 18 | const ::bond::Metadata Foo::Schema::s_x_metadata 19 | = ::bond::reflection::MetadataInit("x"); 20 | 21 | 22 | } // namespace tests 23 | -------------------------------------------------------------------------------- /compiler/tests/generated/allocator/bond_meta_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "bond_meta_reflection.h" 3 | #include 4 | 5 | namespace deprecated 6 | { 7 | namespace bondmeta 8 | { 9 | 10 | const ::bond::Metadata HasMetaFields::Schema::metadata 11 | = HasMetaFields::Schema::GetMetadata(); 12 | 13 | const ::bond::Metadata HasMetaFields::Schema::s_full_name_metadata 14 | = ::bond::reflection::MetadataInit("full_name"); 15 | 16 | const ::bond::Metadata HasMetaFields::Schema::s_name_metadata 17 | = ::bond::reflection::MetadataInit("name"); 18 | 19 | 20 | } // namespace bondmeta 21 | } // namespace deprecated 22 | -------------------------------------------------------------------------------- /compiler/tests/generated/alloc_ctors/bond_meta_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "bond_meta_reflection.h" 3 | #include 4 | 5 | namespace deprecated 6 | { 7 | namespace bondmeta 8 | { 9 | 10 | const ::bond::Metadata HasMetaFields::Schema::metadata 11 | = HasMetaFields::Schema::GetMetadata(); 12 | 13 | const ::bond::Metadata HasMetaFields::Schema::s_full_name_metadata 14 | = ::bond::reflection::MetadataInit("full_name"); 15 | 16 | const ::bond::Metadata HasMetaFields::Schema::s_name_metadata 17 | = ::bond::reflection::MetadataInit("name"); 18 | 19 | 20 | } // namespace bondmeta 21 | } // namespace deprecated 22 | -------------------------------------------------------------------------------- /compiler/tests/generated/type_aliases/bond_meta_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "bond_meta_reflection.h" 3 | #include 4 | 5 | namespace deprecated 6 | { 7 | namespace bondmeta 8 | { 9 | 10 | const ::bond::Metadata HasMetaFields::Schema::metadata 11 | = HasMetaFields::Schema::GetMetadata(); 12 | 13 | const ::bond::Metadata HasMetaFields::Schema::s_full_name_metadata 14 | = ::bond::reflection::MetadataInit("full_name"); 15 | 16 | const ::bond::Metadata HasMetaFields::Schema::s_name_metadata 17 | = ::bond::reflection::MetadataInit("name"); 18 | 19 | 20 | } // namespace bondmeta 21 | } // namespace deprecated 22 | -------------------------------------------------------------------------------- /compiler/tests/generated/scoped_allocator/bond_meta_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "bond_meta_reflection.h" 3 | #include 4 | 5 | namespace deprecated 6 | { 7 | namespace bondmeta 8 | { 9 | 10 | const ::bond::Metadata HasMetaFields::Schema::metadata 11 | = HasMetaFields::Schema::GetMetadata(); 12 | 13 | const ::bond::Metadata HasMetaFields::Schema::s_full_name_metadata 14 | = ::bond::reflection::MetadataInit("full_name"); 15 | 16 | const ::bond::Metadata HasMetaFields::Schema::s_name_metadata 17 | = ::bond::reflection::MetadataInit("name"); 18 | 19 | 20 | } // namespace bondmeta 21 | } // namespace deprecated 22 | -------------------------------------------------------------------------------- /cs/build/nuget/cps/ProjectItemsSchema.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /cmake/Compiler.cmake: -------------------------------------------------------------------------------- 1 | function (cxx_target_compile_options compiler) 2 | list (REMOVE_AT ARGV 0) 3 | if (${CMAKE_CXX_COMPILER_ID} STREQUAL ${compiler}) 4 | target_compile_options (${ARGV}) 5 | endif() 6 | endfunction() 7 | 8 | function (cxx_target_compile_definitions compiler) 9 | list (REMOVE_AT ARGV 0) 10 | if (${CMAKE_CXX_COMPILER_ID} STREQUAL ${compiler}) 11 | target_compile_definitions (${ARGV}) 12 | endif() 13 | endfunction() 14 | 15 | function (cxx_add_compile_options compiler) 16 | list (REMOVE_AT ARGV 0) 17 | if (${CMAKE_CXX_COMPILER_ID} STREQUAL ${compiler}) 18 | add_compile_options (${ARGV}) 19 | endif() 20 | endfunction() 21 | -------------------------------------------------------------------------------- /compiler/tests/schema/custom_alias_with_allocator.bond: -------------------------------------------------------------------------------- 1 | namespace test 2 | 3 | using List = list; 4 | using Vector = vector; 5 | using Set = set; 6 | using Map = map; 7 | using String = string; 8 | using NestedAliases = Set>>; 9 | 10 | struct foo 11 | { 12 | 0: List l; 13 | 1: Vector v; 14 | 2: Set s; 15 | 3: Map m; 16 | 4: String st; 17 | 5: String d = "foo"; 18 | 10: List l1 = nothing; 19 | 11: Vector v1 = nothing; 20 | 12: Set s1 = nothing; 21 | 13: Map m1 = nothing; 22 | 14: String st1 = nothing; 23 | 15: NestedAliases na; 24 | } 25 | -------------------------------------------------------------------------------- /compiler/tests/schema/custom_alias_without_allocator.bond: -------------------------------------------------------------------------------- 1 | namespace test 2 | 3 | using List = list; 4 | using Vector = vector; 5 | using Set = set; 6 | using Map = map; 7 | using String = string; 8 | using NestedAliases = Set>>; 9 | 10 | struct foo 11 | { 12 | 0: List l; 13 | 1: Vector v; 14 | 2: Set s; 15 | 3: Map m; 16 | 4: String st; 17 | 5: String d = "foo"; 18 | 10: List l1 = nothing; 19 | 11: Vector v1 = nothing; 20 | 12: Set s1 = nothing; 21 | 13: Map m1 = nothing; 22 | 14: String st1 = nothing; 23 | 15: NestedAliases na; 24 | } 25 | -------------------------------------------------------------------------------- /cs/src/attributes/Attributes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {92915BD9-8AB1-4E4D-A2AC-95BBF4F82D89} 6 | net462;netstandard1.0;netstandard1.6 7 | Debug;Release 8 | Bond 9 | Bond.Attributes 10 | true 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /cs/test/codegen/default-ignore-output/default-ignore-output.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug;Release 5 | Library 6 | 98BF6B10-F821-4402-8923-5F7B726BBFC8 7 | netstandard1.0 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /cs/src/reflection/reflection.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {40452223-3a34-4841-9a69-e0b6640b4108} 6 | net462;netstandard1.0;netstandard1.6 7 | Debug;Release 8 | Bond.Reflection 9 | Bond.Reflection 10 | true 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/cpp/core/static_array/static_array.cpp: -------------------------------------------------------------------------------- 1 | #include "static_array_reflection.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace examples::static_array; 7 | 8 | int main() 9 | { 10 | Example obj, obj2; 11 | 12 | obj.features.fill(13); 13 | 14 | // Serialize the object 15 | bond::OutputBuffer output; 16 | bond::CompactBinaryWriter writer(output); 17 | Serialize(obj, writer); 18 | 19 | // De-serialize the object 20 | bond::CompactBinaryReader reader(output.GetBuffer()); 21 | Deserialize(reader, obj2); 22 | 23 | BOOST_ASSERT(obj2 == obj); 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /java/core/src/main/java/org/bondlib/BondSerializable.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package org.bondlib; 5 | 6 | import java.io.Externalizable; 7 | 8 | /** 9 | * Denotes a Bond struct type. 10 | * All generated Bond struct classes implement this interface. 11 | */ 12 | public interface BondSerializable extends Externalizable { 13 | 14 | /** 15 | * Returns the {@link BondType} type descriptor for the current struct type. 16 | * 17 | * @return the type descriptor 18 | */ 19 | StructBondType getBondType(); 20 | } 21 | -------------------------------------------------------------------------------- /examples/cpp/core/multiprecision/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_codegen (multiprecision.bond 2 | OPTIONS 3 | --using=uint512=boost::multiprecision::uint512_t 4 | --using=uint1024=boost::multiprecision::uint1024_t 5 | --using=integer=boost::multiprecision::cpp_int 6 | --header=\"\" 7 | --type-aliases) 8 | 9 | add_bond_test (multiprecision 10 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/multiprecision_types.cpp 11 | multiprecision.cpp) 12 | 13 | # Deep in the guts of Boost we get a warning about not using a "secure" 14 | # routine. Suppress them for this example. 15 | cxx_target_compile_options(MSVC multiprecision PRIVATE -D_SCL_SECURE_NO_WARNINGS) 16 | -------------------------------------------------------------------------------- /java/gradle-plugin/src/main/groovy/org/bondlib/gradle/BondProdCodegen.groovy: -------------------------------------------------------------------------------- 1 | package org.bondlib.gradle 2 | 3 | import org.gradle.api.plugins.JavaPlugin 4 | import org.gradle.api.tasks.SourceSet 5 | 6 | class BondProdCodegen extends BondCodegen { 7 | @Override 8 | String dependentTaskName() { 9 | return JavaPlugin.COMPILE_JAVA_TASK_NAME 10 | } 11 | 12 | @Override 13 | SourceSet dependentSourceSet() { 14 | return project.sourceSets.main 15 | } 16 | 17 | @Override 18 | String bondSrcRootPath() { 19 | return "src/main/bond" 20 | } 21 | 22 | @Override 23 | String outputDirName() { 24 | return "generated-bond-main-src" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java/gradle-plugin/src/main/groovy/org/bondlib/gradle/BondTestCodegen.groovy: -------------------------------------------------------------------------------- 1 | package org.bondlib.gradle 2 | 3 | import org.gradle.api.plugins.JavaPlugin 4 | import org.gradle.api.tasks.SourceSet 5 | 6 | class BondTestCodegen extends BondCodegen { 7 | @Override 8 | String dependentTaskName() { 9 | return JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME 10 | } 11 | 12 | @Override 13 | SourceSet dependentSourceSet() { 14 | return project.sourceSets.test 15 | } 16 | 17 | @Override 18 | String bondSrcRootPath() { 19 | return "src/test/bond" 20 | } 21 | 22 | @Override 23 | String outputDirName() { 24 | return "generated-bond-test-src" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java/core/src/main/java/org/bondlib/StructMetadata.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package org.bondlib; 5 | 6 | /** 7 | * A metadata describing a struct, used by {@link ProtocolWriter} for certain protocol types. 8 | */ 9 | public interface StructMetadata { 10 | 11 | /** 12 | * Retrieves the struct name not qualified with namespace. 13 | * 14 | * @return struct name 15 | */ 16 | String getName(); 17 | 18 | /** 19 | * Retrieves the struct name qualified with namespace. 20 | * 21 | * @return struct qualified name 22 | */ 23 | String getQualifiedName(); 24 | } 25 | -------------------------------------------------------------------------------- /examples/cpp/core/capped_allocator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_bond_codegen (capped_allocator.bond 2 | OPTIONS 3 | --allocator=\"bond::ext::capped_allocator<>\" 4 | --header=\"\") 5 | 6 | add_bond_test (capped_allocator 7 | ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/capped_allocator_types.cpp 8 | capped_allocator.cpp) 9 | 10 | # MSVC has bugs in some containers (e.g. std::string) where constructors 11 | # accepting an allocator are marked as `noexcept` while they do allocate 12 | # data when checked iterators are enabled (Debug builds by default). This 13 | # terminates the application when `bond::ext::capped_allocator` throws. 14 | if (MSVC) 15 | add_definitions (-D_ITERATOR_DEBUG_LEVEL=0) 16 | endif() 17 | -------------------------------------------------------------------------------- /java/core/src/main/java/org/bondlib/InvalidBondDataException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package org.bondlib; 5 | 6 | import java.io.IOException; 7 | 8 | /** 9 | * Indicates that Bond data is in invalid format. 10 | */ 11 | public class InvalidBondDataException extends IOException { 12 | 13 | public InvalidBondDataException(String message) { 14 | super(message); 15 | } 16 | 17 | public InvalidBondDataException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | 21 | public InvalidBondDataException(Throwable cause) { 22 | super(cause); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/codegen/read-only/rocs.cabal: -------------------------------------------------------------------------------- 1 | -- Copyright (c) Microsoft. All rights reserved. 2 | -- Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | name: rocs 5 | version: 0.0.0.1 6 | cabal-version: >= 1.8 7 | synopsis: Bond custom codegen example 8 | license: MIT 9 | copyright: Copyright (c) Microsoft. All rights reserved. 10 | build-type: Simple 11 | 12 | executable rocs 13 | main-is: Main.hs 14 | build-depends: bond, 15 | base >= 4.5 && < 5, 16 | shakespeare >= 2.0, 17 | directory >= 1.1, 18 | filepath >= 1.0, 19 | text >= 0.11 20 | -------------------------------------------------------------------------------- /compiler/tests/generated/schemadef/attributes.Foo.json: -------------------------------------------------------------------------------- 1 | { 2 | "structs": [ 3 | { 4 | "fields": [ 5 | { 6 | "id": 0, 7 | "metadata": { 8 | "attributes": [ 9 | "FieldAttribute1", 10 | "one", 11 | "FieldAttribute2", 12 | "two" 13 | ], 14 | "name": "f" 15 | }, 16 | "type": { 17 | "id": 9 18 | } 19 | } 20 | ], 21 | "metadata": { 22 | "attributes": [ 23 | "StructAttribute1", 24 | "one", 25 | "StructAttribute2", 26 | "two" 27 | ], 28 | "name": "Foo", 29 | "qualified_name": "tests.Foo" 30 | } 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /tools/syntax/VsCode/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "language-bond", 3 | "displayName": "Bond", 4 | "description": "Bond Language Support", 5 | "version": "0.0.1", 6 | "publisher": "robrodi", 7 | "engines": { 8 | "vscode": "^0.10.1" 9 | }, 10 | "categories": [ 11 | "Languages" 12 | ], 13 | "contributes": { 14 | "languages": [{ 15 | "id": "bond", 16 | "aliases": ["Bond", "bond"], 17 | "extensions": [".bond"], 18 | "configuration": "./bond.configuration.json" 19 | }], 20 | "grammars": [{ 21 | "language": "bond", 22 | "scopeName": "source.bond", 23 | "path": "./syntaxes/bond.tmLanguage" 24 | }] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /compiler/tests/schema/immutable_collections.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | using ImmutableArray = list; 4 | using ImmutableList = list; 5 | using ImmutableHashSet = set; 6 | using ImmutableSortedSet = set; 7 | using ImmutableDictionary = map; 8 | using ImmutableSortedDictionary = map; 9 | 10 | struct ImmutableCollectionsHolder 11 | { 12 | 0: ImmutableArray ImmutableArrayString; 13 | 1: ImmutableList ImmutableListString; 14 | 2: ImmutableHashSet ImmutableHashSetString; 15 | 3: ImmutableSortedSet ImmutableSortedSetInt; 16 | 4: ImmutableDictionary ImmutableDictionaryStringMap; 17 | 5: ImmutableSortedDictionary ImmutableSortedDictionaryStringMap; 18 | } 19 | -------------------------------------------------------------------------------- /python/test/core/unit_test.cpp: -------------------------------------------------------------------------------- 1 | #include "unit_test_reflection.h" 2 | #include 3 | 4 | BOOST_PYTHON_MODULE(python_unit_test) 5 | { 6 | using namespace unittest; 7 | using namespace bond::python; 8 | 9 | bonded_() 10 | .def(); 11 | 12 | struct_() 13 | .def(); 14 | 15 | struct_() 16 | .def(); 17 | 18 | struct_() 19 | .def(); 20 | 21 | struct_() 22 | .def(bond::qualified_name); 23 | 24 | struct_ >() 25 | .def(); 26 | 27 | struct_() 28 | .def(); 29 | 30 | struct_() 31 | .def(); 32 | 33 | bonded_() 34 | .def(); 35 | } 36 | -------------------------------------------------------------------------------- /cpp/inc/bond/protocol/detail/rapidjson_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | namespace bond 12 | { 13 | namespace detail 14 | { 15 | 16 | std::basic_string utf_to_utf(const char* begin, const char* end); 17 | 18 | bool try_lexical_convert(const char* str, uint16_t& result); 19 | 20 | 21 | } // namespace detail 22 | 23 | } // namespace bond 24 | 25 | 26 | #ifdef BOND_LIB_TYPE 27 | #if BOND_LIB_TYPE == BOND_LIB_TYPE_HEADER 28 | #include "rapidjson_utils_impl.h" 29 | #endif 30 | #else 31 | #error BOND_LIB_TYPE is undefined 32 | #endif 33 | -------------------------------------------------------------------------------- /examples/cpp/core/bf/bf_test.cmake: -------------------------------------------------------------------------------- 1 | function (run) 2 | execute_process ( 3 | COMMAND ${ARGV} 4 | RESULT_VARIABLE error) 5 | if (error) 6 | message (FATAL_ERROR) 7 | endif() 8 | endfunction() 9 | 10 | run (${BF} ${COMPAT_DATA}/compat.simple2.dat --to=compact2 --output=bf.compact2.dat --from=simple2 --schema=${COMPAT_DATA}/compat.schema.dat) 11 | run (${BF} bf.compact2.dat --to=fast --output=bf.fast.dat --from=compact2) 12 | run (${BF} bf.fast.dat --to=compact --output=bf.compact.dat) 13 | run (${BF} bf.compact.dat --to=simple --output=bf.simple.dat --schema=${COMPAT_DATA}/compat.schema.dat) 14 | 15 | run (${BOND_COMPAT} simple -d bf.simple.dat expected.bf.simple deserialized.bf.simple) 16 | -------------------------------------------------------------------------------- /cs/test/core/ImmutableCollections.bond: -------------------------------------------------------------------------------- 1 | namespace UnitTest.ImmutableCollections 2 | 3 | using ImmutableArray = list; 4 | using ImmutableList = list; 5 | using ImmutableHashSet = set; 6 | using ImmutableSortedSet = set; 7 | using ImmutableDictionary = map; 8 | using ImmutableSortedDictionary = map; 9 | 10 | struct ImmutableCollectionsHolder 11 | { 12 | 0: ImmutableArray ImmutableArrayString; 13 | 1: ImmutableList ImmutableListString; 14 | 2: ImmutableHashSet ImmutableHashSetString; 15 | 3: ImmutableSortedSet ImmutableSortedSetInt; 16 | 4: ImmutableDictionary ImmutableDictionaryStringMap; 17 | 5: ImmutableSortedDictionary ImmutableSortedDictionaryStringMap; 18 | } 19 | -------------------------------------------------------------------------------- /compiler/tests/schema/alias_with_allocator.bond: -------------------------------------------------------------------------------- 1 | namespace test 2 | 3 | using List = list; 4 | using Vector = vector; 5 | using Set = set; 6 | using Map = map; 7 | using String = string; 8 | using NestedAliases = Set>>; 9 | 10 | struct foo 11 | { 12 | 0: List l; 13 | 1: Vector v; 14 | 2: Set s; 15 | 3: Map m; 16 | 4: String st; 17 | 5: String d = "foo"; 18 | 10: List l1 = nothing; 19 | 11: Vector v1 = nothing; 20 | 12: Set s1 = nothing; 21 | 13: Map m1 = nothing; 22 | 14: String st1 = nothing; 23 | 15: NestedAliases na; 24 | } 25 | 26 | using TheFoo = foo; 27 | 28 | struct withFoo 29 | { 30 | 0: TheFoo f; 31 | 1: foo f1; 32 | } 33 | -------------------------------------------------------------------------------- /compiler/tests/schema/attributes.json: -------------------------------------------------------------------------------- 1 | {"namespaces":[{"name":["tests"]}],"imports":[],"declarations":[{"tag":"Enum","enumConstants":[{"constantValue":null,"constantName":"Value1"}],"declNamespaces":[{"name":["tests"]}],"declName":"Enum","declAttributes":[{"attrName":["EnumAttribute1"],"attrValue":"one"},{"attrName":["EnumAttribute2"],"attrValue":"two"}]},{"structBase":null,"tag":"Struct","structFields":[{"fieldModifier":"Optional","fieldDefault":null,"fieldType":"string","fieldName":"f","fieldAttributes":[{"attrName":["FieldAttribute1"],"attrValue":"one"},{"attrName":["FieldAttribute2"],"attrValue":"two"}],"fieldOrdinal":0}],"declParams":[],"declNamespaces":[{"name":["tests"]}],"declName":"Foo","declAttributes":[{"attrName":["StructAttribute1"],"attrValue":"one"},{"attrName":["StructAttribute2"],"attrValue":"two"}]}]} -------------------------------------------------------------------------------- /examples/cs/core/immutable_collections/schema.bond: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | 3 | using ImmutableArray = list; 4 | using ImmutableList = list; 5 | using ImmutableHashSet = set; 6 | using ImmutableSortedSet = set; 7 | using ImmutableDictionary = map; 8 | using ImmutableSortedDictionary = map; 9 | 10 | struct ImmutableCollectionsHolder 11 | { 12 | 0: ImmutableArray ImmutableArrayOfStrings; 13 | 1: ImmutableList ImmutableListOfStrings; 14 | 2: ImmutableHashSet ImmutableHashSetOfStrings; 15 | 3: ImmutableSortedSet ImmutableSortedSetOfInts; 16 | 4: ImmutableDictionary ImmutableStringToStringDictionary; 17 | 5: ImmutableSortedDictionary ImmutableSortedIntToStringDictionary; 18 | } 19 | -------------------------------------------------------------------------------- /cpp/inc/bond/core/detail/once.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #if !defined(BOND_NO_CX11_HDR_MUTEX) 9 | 10 | // Use std::call_once when building with a sane compiler. 11 | #include 12 | 13 | namespace bond 14 | { 15 | namespace detail 16 | { 17 | 18 | using std::once_flag; 19 | using std::call_once; 20 | 21 | } // namespace detail 22 | } // namespace bond 23 | 24 | #else 25 | 26 | #include 27 | 28 | namespace bond 29 | { 30 | namespace detail 31 | { 32 | 33 | using boost::once_flag; 34 | using boost::call_once; 35 | 36 | } // namespace detail 37 | } // namespace bond 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /cpp/inc/bond/core/scalar_interface.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace bond 9 | { 10 | 11 | 12 | // Trait defining what built-it type is aliased by T 13 | template struct 14 | aliased_type 15 | { 16 | typedef void type; 17 | }; 18 | 19 | #if 0 20 | 21 | // Overloaded function to set variable to an aliased value 22 | template 23 | void set_aliased_value(T& var, typename aliased_type::type value); 24 | 25 | 26 | // Overloaded function to get an aliased value 27 | template 28 | typename aliased_type::type get_aliased_value(const T& value); 29 | 30 | #endif 31 | 32 | } 33 | -------------------------------------------------------------------------------- /java/core/src/main/java/org/bondlib/StreamNotCloneableException.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package org.bondlib; 5 | 6 | import java.io.IOException; 7 | 8 | /** 9 | * Indicates that a stream cannot be cloned because the original stream is not cloneable. 10 | */ 11 | public class StreamNotCloneableException extends IOException { 12 | 13 | public StreamNotCloneableException(String message) { 14 | super(message); 15 | } 16 | 17 | public StreamNotCloneableException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | 21 | public StreamNotCloneableException(Throwable cause) { 22 | super(cause); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /compiler/tests/schema/schemadef.bond: -------------------------------------------------------------------------------- 1 | namespace tests 2 | 3 | using Just = T; 4 | using List = list; 5 | 6 | struct Generic : T 7 | { 8 | 0: list> l; 9 | } 10 | 11 | using Alias = Generic; 12 | 13 | struct Foo 14 | {} 15 | 16 | struct AliasBase : Alias 17 | {} 18 | 19 | enum Consts 20 | { 21 | Zero, 22 | One, 23 | Three = 3, 24 | Four, 25 | Six = 6 26 | } 27 | 28 | struct EnumDefault 29 | { 30 | 0: Consts c0 = Zero; 31 | 1: Just c1 = One; 32 | 3: Consts c3 = Three; 33 | 4: Consts c4 = Four; 34 | 6: Consts c6 = Six; 35 | } 36 | 37 | struct Node; 38 | 39 | struct Node 40 | { 41 | 0: nullable> left; 42 | 1: nullable> right; 43 | } 44 | 45 | struct StringTree 46 | { 47 | 0: Node root; 48 | } 49 | -------------------------------------------------------------------------------- /compiler/tests/schema/streaming.bond: -------------------------------------------------------------------------------- 1 | import "basic_types.bond"; 2 | 3 | namespace tests; 4 | 5 | // A struct can be named stream and not conflict with the keyword 6 | struct stream { } 7 | 8 | // Service with permutations of streaming 9 | service Foo 10 | { 11 | stream BasicTypes foo31(); 12 | stream BasicTypes foo32(void); 13 | void foo33(stream BasicTypes); 14 | BasicTypes foo34(stream BasicTypes); 15 | stream BasicTypes foo35(stream BasicTypes); 16 | 17 | // validate that the keyword stream can be determed contextually 18 | stream shouldBeUnary(stream); 19 | stream stream shouldBeStreaming(stream stream); 20 | } 21 | 22 | service Bar 23 | { 24 | BasicTypes ClientStreaming(stream T); 25 | stream T ServerStreaming(BasicTypes); 26 | stream T DuplexStreaming(stream T); 27 | } 28 | -------------------------------------------------------------------------------- /cs/src/io/IO.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {2E6E238C-9017-445C-9611-66DA780609BE} 6 | net462;netstandard1.3;netstandard1.6 7 | Debug;Release 8 | Bond.IO 9 | Bond.IO 10 | true 11 | true 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/cpp/core/schema_view/schema_view.cpp: -------------------------------------------------------------------------------- 1 | #include "schema_view_reflection.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace examples::schema_view; 7 | 8 | 9 | int main() 10 | { 11 | Example example; 12 | 13 | example.num = 42; 14 | example.str = "test"; 15 | example.items.push_back(3.14); 16 | example.items.push_back(0); 17 | 18 | bond::OutputBuffer output; 19 | bond::CompactBinaryWriter writer(output); 20 | 21 | Marshal(example, writer); 22 | 23 | ExampleView view; 24 | 25 | bond::InputBuffer input(output.GetBuffer()); 26 | 27 | Unmarshal(input, view); 28 | 29 | BOOST_ASSERT(example.num == view.num); 30 | BOOST_ASSERT(example.str == view.str); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /compiler/tests/schema/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "imports": [], 3 | "namespaces": [ 4 | { 5 | "name": [ 6 | "example", 7 | "some" 8 | ] 9 | } 10 | ], 11 | "declarations": [ 12 | { 13 | "tag": "Struct", 14 | "declNamespaces": [ 15 | { 16 | "name": [ 17 | "example", 18 | "some" 19 | ] 20 | } 21 | ], 22 | "declAttributes": [], 23 | "declParams": [], 24 | "declName": "SomeStruct", 25 | "structFields": [ 26 | { 27 | "fieldOrdinal": 0, 28 | "fieldType": "int32", 29 | "fieldName": "someField", 30 | "fieldDefault": { 31 | "value": 123, 32 | "type": "integer" 33 | } 34 | } 35 | ] 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /compiler/tests/generated/schemadef/nullable_alias.foo.json: -------------------------------------------------------------------------------- 1 | { 2 | "structs": [ 3 | { 4 | "fields": [ 5 | { 6 | "id": 1, 7 | "metadata": { 8 | "name": "l" 9 | }, 10 | "type": { 11 | "element": [ 12 | { 13 | "id": 17 14 | } 15 | ], 16 | "id": 11 17 | } 18 | }, 19 | { 20 | "id": 2, 21 | "metadata": { 22 | "default_value": { 23 | "nothing": true 24 | }, 25 | "name": "t" 26 | }, 27 | "type": { 28 | "id": 17 29 | } 30 | } 31 | ], 32 | "metadata": { 33 | "name": "foo", 34 | "qualified_name": "test.foo" 35 | } 36 | } 37 | ] 38 | } -------------------------------------------------------------------------------- /cs/src/core/protocols/Exceptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace Bond.Protocols 5 | { 6 | using System.IO; 7 | using System.Runtime.CompilerServices; 8 | 9 | internal static class Throw 10 | { 11 | [MethodImpl(MethodImplOptions.NoInlining)] 12 | public static void InvalidBondDataType(BondDataType type) 13 | { 14 | throw new InvalidDataException(string.Format("Invalid BondDataType {0}", type)); 15 | } 16 | 17 | [MethodImpl(MethodImplOptions.NoInlining)] 18 | public static void EndOfStreamException() 19 | { 20 | throw new EndOfStreamException("Unexpected end of stream reached."); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/cs/core/enumerations/program.cs: -------------------------------------------------------------------------------- 1 | namespace Examples 2 | { 3 | using System; 4 | 5 | static class Program 6 | { 7 | static void Main() 8 | { 9 | var yellow = Color.Yellow; 10 | ThrowIfFalse((int)yellow == 2); 11 | 12 | var apple = Fruit.Apple; 13 | ThrowIfFalse((int)apple == 1); 14 | 15 | ThrowIfFalse((Int32)Limits.Int32Min == Int32.MinValue); 16 | ThrowIfFalse((Int32)Limits.Int32Max == Int32.MaxValue); 17 | ThrowIfFalse((UInt32)Limits.UInt32Min == UInt32.MinValue); 18 | ThrowIfFalse(unchecked((UInt32)Limits.UInt32Max) == UInt32.MaxValue); 19 | } 20 | 21 | static void ThrowIfFalse(bool b) 22 | { 23 | if (!b) throw new Exception("Assertion failed"); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java/compat/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /compiler/stack.yaml.lock: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by Stack. 2 | # You should not edit this file by hand. 3 | # For more information, please see the documentation at: 4 | # https://docs.haskellstack.org/en/stable/lock_files 5 | 6 | packages: 7 | - completed: 8 | hackage: quickcheck-arbitrary-template-0.2.1.0@sha256:01f9deb34f8af3e6b879ee984b0be8803eb9c31e389490b5ddb8ca5fde32957c,2026 9 | pantry-tree: 10 | sha256: a79d0b9f39f1096774a34f502c209dc70c85bc43f164e2925cb6b7a3f7ad82c8 11 | size: 625 12 | original: 13 | hackage: quickcheck-arbitrary-template-0.2.1.0 14 | snapshots: 15 | - completed: 16 | sha256: 16f24be248b42c9e16d59db84378836b1e7c239448a041cae46d32daffa45a8b 17 | size: 523884 18 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/4.yaml 19 | original: lts-14.4 20 | -------------------------------------------------------------------------------- /compiler/tests/generated/constructor-parameters/empty_struct_types.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | // suppress "Missing XML comment for publicly visible type or member" 4 | #pragma warning disable 1591 5 | 6 | 7 | #region ReSharper warnings 8 | // ReSharper disable PartialTypeWithSinglePart 9 | // ReSharper disable RedundantNameQualifier 10 | // ReSharper disable InconsistentNaming 11 | // ReSharper disable CheckNamespace 12 | // ReSharper disable UnusedParameter.Local 13 | // ReSharper disable RedundantUsingDirective 14 | #endregion 15 | 16 | namespace tests 17 | { 18 | using System.Collections.Generic; 19 | 20 | [global::Bond.Schema] 21 | [System.CodeDom.Compiler.GeneratedCode("gbc", "0.13.0.0")] 22 | public partial class Empty 23 | { 24 | 25 | public Empty() 26 | { 27 | 28 | } 29 | } 30 | } // tests 31 | -------------------------------------------------------------------------------- /java/gradle-plugin/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /cs/test/internal/RequiredFieldsTest.cs: -------------------------------------------------------------------------------- 1 | namespace InternalTest 2 | { 3 | using Bond.Expressions; 4 | using NUnit.Framework; 5 | 6 | [TestFixture] 7 | public class RequiredFieldsTest 8 | { 9 | void TestBitmap(int count) 10 | { 11 | var b = new RequiredFields.Bitmap(count); 12 | Assert.IsTrue(b.IsAnySet); 13 | 14 | for (var i = 0; i < count; ++i) 15 | { 16 | Assert.AreEqual(i, b.FirstSet); 17 | b.Reset(i >> 6, 1L << (i % 64)); 18 | } 19 | 20 | Assert.IsFalse(b.IsAnySet); 21 | } 22 | 23 | [Test] 24 | public void BitmapTest() 25 | { 26 | for (var i = 1; i < 129; ++i) 27 | { 28 | TestBitmap(i); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /java/core/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /java/json/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /compiler/tests/Tests/Codegen/Util.hs: -------------------------------------------------------------------------------- 1 | -- Copyright (c) Microsoft. All rights reserved. 2 | -- Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | {-# OPTIONS_GHC -fno-warn-missing-signatures #-} 5 | 6 | module Tests.Codegen.Util 7 | ( 8 | utilTestGroup 9 | ) where 10 | 11 | import Language.Bond.Codegen.Util(uniqueName) 12 | import Test.Tasty 13 | import Test.Tasty.QuickCheck 14 | 15 | utilTestGroup = testGroup "Codegen Utils" 16 | [ testGroup "uniqueName" [ testProperty "unique when taken" prop_collisionReturnsNotSame, 17 | testProperty "given when not taken" prop_noCollisionReturnsSame]] 18 | 19 | prop_collisionReturnsNotSame xs = not (null xs) ==> uniqueName (head xs) xs /= head xs 20 | prop_noCollisionReturnsSame xs = not ("some" `elem` xs) ==> uniqueName "some" xs == "some" 21 | -------------------------------------------------------------------------------- /compiler/tests/generated/constructor-parameters/collection-interfaces/empty_struct_types.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | // suppress "Missing XML comment for publicly visible type or member" 4 | #pragma warning disable 1591 5 | 6 | 7 | #region ReSharper warnings 8 | // ReSharper disable PartialTypeWithSinglePart 9 | // ReSharper disable RedundantNameQualifier 10 | // ReSharper disable InconsistentNaming 11 | // ReSharper disable CheckNamespace 12 | // ReSharper disable UnusedParameter.Local 13 | // ReSharper disable RedundantUsingDirective 14 | #endregion 15 | 16 | namespace tests 17 | { 18 | using System.Collections.Generic; 19 | 20 | [global::Bond.Schema] 21 | [System.CodeDom.Compiler.GeneratedCode("gbc", "0.13.0.0")] 22 | public partial class Empty 23 | { 24 | 25 | public Empty() 26 | { 27 | 28 | } 29 | } 30 | } // tests 31 | -------------------------------------------------------------------------------- /examples/java/core/nothing_default/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.NothingDefault' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | options '--namespace', 'examples.nothing_default=org.bondlib.examples.nothingdefault' 33 | } 34 | 35 | jar { 36 | manifest { 37 | attributes 'Main-Class': mainClassName 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/java/core/polymorphic_container/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.PolymorphicContainer' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | options '--namespace', 'Examples=org.bondlib.examples.polymorphiccontainer' 33 | } 34 | 35 | jar { 36 | manifest { 37 | attributes 'Main-Class': mainClassName 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/java/core/blob/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.BlobExample' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | bondfiles 'src/main/bond/schema.bond' 33 | options '--namespace', 'Examples=org.bondlib.examples.blob' 34 | } 35 | 36 | jar { 37 | manifest { 38 | attributes 'Main-Class': mainClassName 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/java/core/record_streaming/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.RecordStreaming' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | options '--namespace', 'examples.record_streaming=org.bondlib.examples.recordstreaming' 33 | } 34 | 35 | jar { 36 | manifest { 37 | attributes 'Main-Class': mainClassName 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /compiler/tests/generated/field_modifiers_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "field_modifiers_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Foo::Schema::metadata 9 | = Foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Foo::Schema::s_o_metadata 12 | = ::bond::reflection::MetadataInit("o"); 13 | 14 | const ::bond::Metadata Foo::Schema::s_r_metadata 15 | = ::bond::reflection::MetadataInit("r", ::bond::reflection::required_field_modifier::value, 16 | ::bond::reflection::Attributes()); 17 | 18 | const ::bond::Metadata Foo::Schema::s_ro_metadata 19 | = ::bond::reflection::MetadataInit("ro", ::bond::reflection::required_optional_field_modifier::value, 20 | ::bond::reflection::Attributes()); 21 | 22 | 23 | } // namespace tests 24 | -------------------------------------------------------------------------------- /compiler/tests/generated/alloc_ctors/field_modifiers_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "field_modifiers_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Foo::Schema::metadata 9 | = Foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Foo::Schema::s_o_metadata 12 | = ::bond::reflection::MetadataInit("o"); 13 | 14 | const ::bond::Metadata Foo::Schema::s_r_metadata 15 | = ::bond::reflection::MetadataInit("r", ::bond::reflection::required_field_modifier::value, 16 | ::bond::reflection::Attributes()); 17 | 18 | const ::bond::Metadata Foo::Schema::s_ro_metadata 19 | = ::bond::reflection::MetadataInit("ro", ::bond::reflection::required_optional_field_modifier::value, 20 | ::bond::reflection::Attributes()); 21 | 22 | 23 | } // namespace tests 24 | -------------------------------------------------------------------------------- /compiler/tests/generated/allocator/field_modifiers_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "field_modifiers_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Foo::Schema::metadata 9 | = Foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Foo::Schema::s_o_metadata 12 | = ::bond::reflection::MetadataInit("o"); 13 | 14 | const ::bond::Metadata Foo::Schema::s_r_metadata 15 | = ::bond::reflection::MetadataInit("r", ::bond::reflection::required_field_modifier::value, 16 | ::bond::reflection::Attributes()); 17 | 18 | const ::bond::Metadata Foo::Schema::s_ro_metadata 19 | = ::bond::reflection::MetadataInit("ro", ::bond::reflection::required_optional_field_modifier::value, 20 | ::bond::reflection::Attributes()); 21 | 22 | 23 | } // namespace tests 24 | -------------------------------------------------------------------------------- /compiler/tests/generated/schemadef/field_modifiers.Foo.json: -------------------------------------------------------------------------------- 1 | { 2 | "structs": [ 3 | { 4 | "fields": [ 5 | { 6 | "id": 0, 7 | "metadata": { 8 | "name": "o" 9 | }, 10 | "type": { 11 | "id": 2 12 | } 13 | }, 14 | { 15 | "id": 1, 16 | "metadata": { 17 | "modifier": 1, 18 | "name": "r" 19 | }, 20 | "type": { 21 | "id": 15 22 | } 23 | }, 24 | { 25 | "id": 2, 26 | "metadata": { 27 | "modifier": 2, 28 | "name": "ro" 29 | }, 30 | "type": { 31 | "id": 8 32 | } 33 | } 34 | ], 35 | "metadata": { 36 | "name": "Foo", 37 | "qualified_name": "tests.Foo" 38 | } 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /compiler/tests/generated/schemadef/inheritance.Foo.json: -------------------------------------------------------------------------------- 1 | { 2 | "structs": [ 3 | { 4 | "base_def": [ 5 | { 6 | "struct_def": 1 7 | } 8 | ], 9 | "fields": [ 10 | { 11 | "id": 0, 12 | "metadata": { 13 | "name": "x" 14 | }, 15 | "type": { 16 | "id": 16 17 | } 18 | } 19 | ], 20 | "metadata": { 21 | "name": "Foo", 22 | "qualified_name": "tests.Foo" 23 | } 24 | }, 25 | { 26 | "fields": [ 27 | { 28 | "id": 0, 29 | "metadata": { 30 | "name": "x" 31 | }, 32 | "type": { 33 | "id": 16 34 | } 35 | } 36 | ], 37 | "metadata": { 38 | "name": "Base", 39 | "qualified_name": "tests.Base" 40 | } 41 | } 42 | ] 43 | } -------------------------------------------------------------------------------- /compiler/tests/generated/type_aliases/field_modifiers_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "field_modifiers_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Foo::Schema::metadata 9 | = Foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Foo::Schema::s_o_metadata 12 | = ::bond::reflection::MetadataInit("o"); 13 | 14 | const ::bond::Metadata Foo::Schema::s_r_metadata 15 | = ::bond::reflection::MetadataInit("r", ::bond::reflection::required_field_modifier::value, 16 | ::bond::reflection::Attributes()); 17 | 18 | const ::bond::Metadata Foo::Schema::s_ro_metadata 19 | = ::bond::reflection::MetadataInit("ro", ::bond::reflection::required_optional_field_modifier::value, 20 | ::bond::reflection::Attributes()); 21 | 22 | 23 | } // namespace tests 24 | -------------------------------------------------------------------------------- /compiler/tests/schema/inheritance.json: -------------------------------------------------------------------------------- 1 | {"namespaces":[{"name":["tests"]}],"imports":[],"declarations":[{"structBase":null,"tag":"Struct","structFields":[{"fieldModifier":"Optional","fieldDefault":null,"fieldType":"int32","fieldName":"x","fieldAttributes":[],"fieldOrdinal":0}],"declParams":[],"declNamespaces":[{"name":["tests"]}],"declName":"Base","declAttributes":[]},{"structBase":{"declaration":{"structBase":null,"tag":"Struct","structFields":[{"fieldModifier":"Optional","fieldDefault":null,"fieldType":"int32","fieldName":"x","fieldAttributes":[],"fieldOrdinal":0}],"declParams":[],"declNamespaces":[{"name":["tests"]}],"declName":"Base","declAttributes":[]},"type":"user"},"tag":"Struct","structFields":[{"fieldModifier":"Optional","fieldDefault":null,"fieldType":"int32","fieldName":"x","fieldAttributes":[],"fieldOrdinal":0}],"declParams":[],"declNamespaces":[{"name":["tests"]}],"declName":"Foo","declAttributes":[]}]} -------------------------------------------------------------------------------- /cpp/inc/bond/core/cmdargs.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "bond.h" 9 | #include "detail/cmdargs.h" 10 | 11 | namespace bond 12 | { 13 | namespace cmd 14 | { 15 | // Output usage help to std::cerr 16 | template 17 | void ShowUsage(const char* program) 18 | { 19 | Options options; 20 | Apply(detail::Usage(program), options); 21 | } 22 | 23 | // Read command line arguments 24 | template 25 | Options GetArgs(int argc, char** argv, bool partial = false) 26 | { 27 | Options options; 28 | Apply(detail::CmdArg(argc, argv, partial), options); 29 | return options; 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /cpp/test/core/main.cpp: -------------------------------------------------------------------------------- 1 | #define BOOST_TEST_NO_MAIN 2 | #define BOOST_TEST_ALTERNATIVE_INIT_API 3 | /* 4 | * We need to include different boost unit test headers on Windows and *nix. 5 | * 6 | * Using boost/test/unit_test.hpp on Windows causes linker errors. 7 | * 8 | * Using boost/test/included/unit_test.hpp on *nix causes segfaults during 9 | * teardown in some suites. 10 | */ 11 | 12 | #ifdef _MSC_VER 13 | #pragma warning(push) 14 | #pragma warning(disable: 4702) // C4702: unreachable code 15 | #endif 16 | 17 | #if defined(_WIN32) 18 | #include 19 | #else 20 | #include 21 | #endif 22 | 23 | #ifdef _MSC_VER 24 | #pragma warning(pop) 25 | #endif 26 | 27 | extern bool init_unit_test(); 28 | 29 | int main(int argc, char* argv[]) 30 | { 31 | return ::boost::unit_test::unit_test_main(&init_unit_test, argc, argv); 32 | } 33 | -------------------------------------------------------------------------------- /cs/test/core/XmlSerializationTests.cs: -------------------------------------------------------------------------------- 1 | namespace UnitTest 2 | { 3 | using System; 4 | using System.Text; 5 | using System.Xml; 6 | using Bond; 7 | using Bond.Protocols; 8 | using NUnit.Framework; 9 | 10 | [TestFixture] 11 | class XmlSerializationTests 12 | { 13 | [Test] 14 | public void XmlSerialization_NullNonNullableString_Throws() 15 | { 16 | var xmlString = new StringBuilder(); 17 | var xmlWriter = new SimpleXmlWriter(XmlWriter.Create(xmlString)); 18 | 19 | var nullString = new BasicTypes {_str = null}; 20 | Assert.Throws(() => Serialize.To(xmlWriter, nullString)); 21 | 22 | var nullWString = new BasicTypes {_wstr = null}; 23 | Assert.Throws(() => Serialize.To(xmlWriter, nullWString)); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/java/core/generics/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.Generics' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | bondfiles 'src/main/bond/generics.bond' 33 | options '--namespace', 'examples.generics=org.bondlib.examples.generics' 34 | } 35 | 36 | jar { 37 | manifest { 38 | attributes 'Main-Class': mainClassName 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /compiler/tests/generated/scoped_allocator/field_modifiers_types.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "field_modifiers_reflection.h" 3 | #include 4 | 5 | namespace tests 6 | { 7 | 8 | const ::bond::Metadata Foo::Schema::metadata 9 | = Foo::Schema::GetMetadata(); 10 | 11 | const ::bond::Metadata Foo::Schema::s_o_metadata 12 | = ::bond::reflection::MetadataInit("o"); 13 | 14 | const ::bond::Metadata Foo::Schema::s_r_metadata 15 | = ::bond::reflection::MetadataInit("r", ::bond::reflection::required_field_modifier::value, 16 | ::bond::reflection::Attributes()); 17 | 18 | const ::bond::Metadata Foo::Schema::s_ro_metadata 19 | = ::bond::reflection::MetadataInit("ro", ::bond::reflection::required_optional_field_modifier::value, 20 | ::bond::reflection::Attributes()); 21 | 22 | 23 | } // namespace tests 24 | -------------------------------------------------------------------------------- /cpp/inc/bond/ext/capped_allocator_fwd.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | namespace bond { namespace ext 12 | { 13 | template 14 | class single_threaded_counter; 15 | 16 | template 17 | class multi_threaded_counter; 18 | 19 | template > 20 | class shared_counter; 21 | 22 | template < 23 | typename Alloc = std::allocator, 24 | typename Counter = shared_counter< 25 | multi_threaded_counter::size_type>>> 26 | class capped_allocator; 27 | 28 | } } // namespace bond::ext 29 | -------------------------------------------------------------------------------- /cs/src/core/ISchemaField.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace Bond 5 | { 6 | using System; 7 | using System.Reflection; 8 | 9 | /// 10 | /// ISchemaField abstracts a field or property representing a schema field. 11 | /// 12 | /// 13 | /// Schema fields on a compiled Type may be represented as class fields or as properties. An ISchemaField may represent either one. 14 | /// 15 | public interface ISchemaField 16 | { 17 | ushort Id { get; } 18 | 19 | string Name { get; } 20 | 21 | Type MemberType { get; } 22 | 23 | Type DeclaringType { get; } 24 | 25 | MemberInfo MemberInfo { get; } 26 | 27 | object GetValue(object o); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /java/core/src/test/bond/equality.bond: -------------------------------------------------------------------------------- 1 | import "dir1/dir2/common.bond" 2 | 3 | namespace org.bondlib.test 4 | 5 | struct Primitives { 6 | 0: int8 iint8; 7 | 1: int16 iint16; 8 | 2: int32 iint32; 9 | 3: int64 iint64; 10 | 4: uint8 iuint8; 11 | 5: uint16 iuint16; 12 | 6: uint32 iuint32; 13 | 7: uint64 iuint64; 14 | 8: float ffloat; 15 | 9: double fdouble; 16 | 10: bool bbool; 17 | 11: string str; 18 | 12: wstring wstr; 19 | } 20 | 21 | struct Containers { 22 | 0: list intList; 23 | 1: vector intVector; 24 | 2: set intSet; 25 | 3: map intMap; 26 | 4: list primitivesList; 27 | 5: blob dataBlob; 28 | } 29 | 30 | struct Recursive { 31 | 0: nullable r; 32 | 1: int32 depth; 33 | } 34 | 35 | using datetime = int64; 36 | 37 | struct Aliased { 38 | 0: datetime d; 39 | } 40 | -------------------------------------------------------------------------------- /compiler/tests/schema/complex_inheritance.bond: -------------------------------------------------------------------------------- 1 | namespace Test 2 | 3 | using CustomList = vector; 4 | using BaseText = wstring; 5 | 6 | enum TestEnum 7 | { 8 | EnumVal1, 9 | EnumVal2, 10 | EnumVal3 11 | }; 12 | 13 | struct Simple 14 | { 15 | 0: int32 someInt; 16 | 1: int32 anotherInt; 17 | 2: wstring someString; 18 | }; 19 | 20 | struct Foo 21 | { 22 | 0: BaseText someText = "BaseText1"; 23 | } 24 | 25 | struct Bar: Foo 26 | { 27 | 0: TestEnum testEnum = Val2; 28 | 1: wstring someText = "DerivedText1"; 29 | 2: int32 someInt; 30 | 3: wstring moreText; 31 | 4: CustomList someList; 32 | 5: map someMap; 33 | 6: set someSet; 34 | }; 35 | 36 | struct Baz: Bar 37 | { 38 | 0: wstring someText; 39 | 1: wstring evenMoreText; 40 | 2: wstring someText1; 41 | } 42 | 43 | struct DerivedEmpty: Foo 44 | { 45 | } 46 | -------------------------------------------------------------------------------- /examples/java/core/enumerations/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.Enumerations' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | bondfiles 'src/main/bond/enumerations.bond' 33 | options '--namespace', 'Examples=org.bondlib.examples.enumerations' 34 | } 35 | 36 | jar { 37 | manifest { 38 | attributes 'Main-Class': mainClassName 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /cpp/inc/bond/core/select_protocol_fwd.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "bond_fwd.h" 9 | 10 | #include 11 | 12 | namespace bond 13 | { 14 | 15 | // Use compile-time schema 16 | template 17 | inline std::pair SelectProtocolAndApply(Buffer& input, const Transform& transform); 18 | 19 | 20 | // Use runtime schema 21 | template 22 | inline std::pair SelectProtocolAndApply( 23 | const RuntimeSchema& schema, 24 | Buffer& input, 25 | const Transform& transform); 26 | 27 | } // namespace bond 28 | -------------------------------------------------------------------------------- /cpp/src/bond/core/select_protocol.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #include 5 | 6 | #if BOND_LIB_TYPE == BOND_LIB_TYPE_HEADER 7 | #error This source file should not be compiled for BOND_LIB_TYPE_HEADER 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | 14 | namespace bond 15 | { 16 | namespace detail 17 | { 18 | 19 | BOND_DETAIL_INSTANTIATE(BOND_DETAIL_NextProtocol, BOND_DETAIL_BUILTIN_WRITERS) 20 | 21 | BOND_DETAIL_PREFIX_TEMPLATE(BOND_DETAIL_NextProtocol_Null)() 22 | 23 | BOND_DETAIL_INSTANTIATE(BOND_DETAIL_NextProtocol_Select, BOND_DETAIL_BUILTIN_WRITERS) 24 | 25 | BOND_DETAIL_PREFIX_TEMPLATE(BOND_DETAIL_NextProtocol_Select_Null)() 26 | 27 | } // namespace detail 28 | } // namespace bond 29 | -------------------------------------------------------------------------------- /cs/test/core/JsonSerializationTests.cs: -------------------------------------------------------------------------------- 1 | namespace UnitTest 2 | { 3 | using System; 4 | using System.IO; 5 | using Bond; 6 | using Bond.Protocols; 7 | using NUnit.Framework; 8 | 9 | [TestFixture] 10 | class JsonSerializationTests 11 | { 12 | [Test] 13 | public void JsonSerialization_NullNonNullableString_Throws() 14 | { 15 | var ser = new Serializer(typeof(BasicTypes)); 16 | var stream = new StringWriter(); 17 | var jw = new SimpleJsonWriter(stream); 18 | 19 | var nullString = new BasicTypes {_str = null}; 20 | Assert.Throws(() => ser.Serialize(nullString, jw)); 21 | 22 | var nullWString = new BasicTypes {_wstr = null}; 23 | Assert.Throws(() => ser.Serialize(nullWString, jw)); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/cpp/core/generics/generics.cpp: -------------------------------------------------------------------------------- 1 | #include "generics_reflection.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace examples::generics; 7 | 8 | 9 | int main() 10 | { 11 | Struct > obj, obj2; 12 | 13 | obj.n.x = L"test"; 14 | obj.x = 0.11; 15 | obj.y = "test"; 16 | obj.items.push_back(3.14); 17 | obj.items.push_back(0); 18 | 19 | bond::OutputBuffer output; 20 | bond::CompactBinaryWriter writer(output); 21 | 22 | // Serialize the object 23 | bond::Serialize(obj, writer); 24 | 25 | bond::blob buffer = output.GetBuffer(); 26 | 27 | bond::CompactBinaryReader reader(buffer); 28 | 29 | // De-serialize the object 30 | bond::Deserialize(reader, obj2); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /examples/java/core/inheritance/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.Inheritance' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | bondfiles 'src/main/bond/inheritance.bond' 33 | options '--namespace', 'examples.inheritance=org.bondlib.examples.inheritance' 34 | } 35 | 36 | jar { 37 | manifest { 38 | attributes 'Main-Class': mainClassName 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/java/core/runtime_schema/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.RuntimeSchemaExample' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | bondfiles 'src/main/bond/schema.bond' 33 | options '--namespace', 'Examples=org.bondlib.examples.runtime_schema' 34 | } 35 | 36 | jar { 37 | manifest { 38 | attributes 'Main-Class': mainClassName 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/java/core/schema_view/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.SchemaView' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | bondfiles 'src/main/bond/schema_view.bond' 33 | options '--namespace', 'examples.schema_view=org.bondlib.examples.schemaview' 34 | } 35 | 36 | jar { 37 | manifest { 38 | attributes 'Main-Class': mainClassName 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tools/syntax/VsCode/README.md: -------------------------------------------------------------------------------- 1 | # Bond VS Code Extension 2 | Adds basic Syntax highlighting to [Visual Studio Code][1] 3 | ## Development 4 | See [VS Code's documentation][2]. 5 | ### Todo: 6 | * [Snippets][5] 7 | * [Intellisense][6] 8 | * [Publish][4] 9 | * Bond View / Nested Struct Support 10 | * Validators 11 | 12 | ## Installation 13 | * To start using this extension with Visual Studio Code copy it into [your Extensions Folder][3] folder and restart Code. 14 | 15 | [1]:https://code.visualstudio.com/ 16 | [2]:https://code.visualstudio.com/docs/customization/colorizer 17 | [3]:https://code.visualstudio.com/docs/extensions/install-extension#_your-extensions-folder 18 | [4]:https://code.visualstudio.com/docs/tools/vscecli 19 | [5]:https://code.visualstudio.com/Docs/customization/userdefinedsnippets 20 | [6]:http://stackoverflow.com/questions/29975036/how-to-import-intellisense-files-into-vscode-visual-studio-code 21 | -------------------------------------------------------------------------------- /examples/java/core/generic_tree/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.GenericTree' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | bondfiles 'src/main/bond/generic_tree.bond' 33 | options '--namespace', 'examples.generic_tree=org.bondlib.examples.generictree' 34 | } 35 | 36 | jar { 37 | manifest { 38 | attributes 'Main-Class': mainClassName 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/java/core/untagged_protocols/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.UntaggedProtocols' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | bondfiles 'src/main/bond/schema.bond' 33 | options '--namespace', 'Examples=org.bondlib.examples.untagged_protocols' 34 | } 35 | 36 | jar { 37 | manifest { 38 | attributes 'Main-Class': mainClassName 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/java/core/serialization/build.gradle: -------------------------------------------------------------------------------- 1 | group 'org.bondlib' 2 | version '1.0' 3 | 4 | buildscript { 5 | repositories { 6 | mavenLocal() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath 'org.bondlib:bond-gradle:+' 12 | } 13 | } 14 | 15 | apply plugin: 'application' 16 | apply plugin: 'org.bondlib.gradle' 17 | 18 | sourceCompatibility = 1.8 19 | mainClassName = 'org.bondlib.examples.Serialization' 20 | applicationDefaultJvmArgs = ['-ea'] 21 | 22 | repositories { 23 | mavenLocal() 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.bondlib:bond:+' 29 | } 30 | 31 | compileBond { 32 | bondfiles 'src/main/bond/serialization.bond' 33 | options '--namespace', 'examples.serialization=org.bondlib.examples.serialization' 34 | } 35 | 36 | jar { 37 | manifest { 38 | attributes 'Main-Class': mainClassName 39 | } 40 | } 41 | --------------------------------------------------------------------------------