Commit Graph

197 Commits

Author SHA1 Message Date
罗泽轩 4525cd9c56
[Lua] manipulate byte array as string (#6624)
* [Lua] manipulate byte array as string

Sometimes it would be more effective than reading byte by byte

* change according to the review

* update
2021-05-07 22:57:13 -07:00
Derek Bailey 14725d6c3b
[Lua] GetRootAs can accept strings. Made Luatest Benchmarks optional (#6593) 2021-04-27 13:02:13 -07:00
Casper 4133a39df8
Rust structz (#6539)
* Rust structz

* struct of structs test

* swift tmp variables

Co-authored-by: Casper Neo <cneo@google.com>
2021-03-29 19:56:45 -04:00
Derek Bailey 8cccdfba53
Revert "[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)" (#6488)
This reverts commit cbbbaa61b3.
2021-02-23 11:30:07 -08:00
Björn Harrtell cbbbaa61b3
[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)
* WIP: Fix returned truncated ArraySegment<byte> if elementSize is not byte

* Fix

* Regenerated test code
2021-02-23 09:34:20 -08:00
mustiikhalil 0c7ae58164
[Go] Working on a go example plus fixing go grpc code (#6448)
Implemented server.go and half implemented client.go

Finishes implementation for greeter go example

Update grpc code for monster.fbs

Adds a couple of cpp methods

Adhere to gofmt standards

Adds a readme for issues with grpc
2021-02-19 12:47:59 +03:00
Richard A Hofer 13d9e35858
Better python generated code naming (#6336)
* Remove a lot of redundancy from the Python generated code.

Update tutorial to reflect new Python generated code.

* Add aliases for newly deprecated Python generated methods.

This should help with backwards compatibility.

* Fix incorrect names in deprecated comments.
2021-01-28 12:35:37 -08:00
Vladimir Glavnyy 83ce29cc22
[C++, JSON] Fix nullptr access when reading a key with a default value. (#6375)
This commit fixes handling of default and NULL `key` fields in `Parser::ParseVector` (#5928).

The JSON generator updated. It outputs `key` fields even if the `--force-defaults` option is inactive.

Additional test cases for `key` added.
2021-01-07 11:24:59 -08:00
Richard A Hofer 4363c1d2cb
Fix generated EndVector. (#6385) 2021-01-05 14:45:23 -08:00
Stefan de Konink 1bf1ec0270
Implements type promotion for Java enum (#6382)
* Implements type promotion for Java enum as suggested in #3890, #5111, #6369

* After generate_code.sh
2021-01-05 11:11:29 -08:00
Richard A Hofer 24dd85fd28
Generate code to encode and decode nested flatbuffers in Python. (#6354)
* Generate code to encode and decode nested flatbuffers in Python.

* Delete accidental trailing whitespace.

* Fully delete trailing whitespace.
2021-01-04 12:18:19 -08:00
Richard A Hofer f8b203c9c4
Add vectorNumElements attribute to Builder for simpler vector creation. (#6328)
* Add vectorNumElements attribute to Builder for simpler vector creation.

This adds a default to EndVector which should simplify its use.

* Update tutorial to reflect new default arg in Python EndVector.

* Remove optional argument to Python EndVector.

* Add generated files.

* Unset Builder.vectorNumElems when not in use.
2020-12-14 12:00:28 -08:00
David P. Sicilia a9e91116d2
[Python] Commit some orphan python genfile diffs. (#6325) 2020-12-10 16:43:40 -08:00
Derek Bailey febb9d87c9
Union As Accessors for C# (#6251)
* Union As Accessors for C#

* Changed loop to be compatible with older compilers

* errant change fix
2020-11-12 09:28:21 -08:00
Casper 46a8c7e958
Added required-nested-flatbuffer to monster_test and fixed rust (#6236)
Co-authored-by: Casper Neo <cneo@google.com>
2020-11-05 13:58:06 -08:00
Charlie Yin c9b29d0885
Support size-prefixed buffers and add tests for size-prefixed messages (#6232) 2020-11-05 11:23:56 -08:00
Derek Bailey 914c646014
Removed C# references from java generator. Move annotations closer to definitions (#6204) 2020-10-25 21:42:29 -07:00
Anass Al 689bfafa7e
[Python/JS/TS] Codegen SizeOf method for structs (#6136)
* [Python] Codegen SizeOf classmethod for structs

This codegens a `SizeOf()` classmethod for all structs since we can't
determine the size of a FlatBuffer generated struct from Python otherwise.

* [JS/TS] Codegen sizeOf static method for structs

This codegens a `sizeOf()` static method for all structs since we can't
determine the size of a FlatBuffer generated struct from JavaScript or
TypeScript otherwise.
2020-09-28 08:54:50 -07:00
mugisoba ac203b2092
[C#] Add file identifier to ObjectAPI Serialization Utility. (#5920)
* use Finish***Buffer instead.

* add file_identifier test.
2020-05-21 09:14:20 -07:00
Anass Al fb96fadc20
[C#] Fix nested structs and arrays in Object API (#5765)
* [C#] Fix nested structs and arrays in Object API

The adds support for nested structs and fixed size arrays in the C#
Object API codegen which previously generated invalid code that wouldn't
compile.

- Nested structs would originally generate syntax errors due to adding an
  additional `.` to separate fields.
- Fixed size arrays of nested structs would originally generate code for
  the first field in the top most struct, and would lead to a compiler
  error due to referencing undefined variables.

* [C#] fix nested structs and arrays of structs.

* fix nested structs + arrays

* add table support

* Cleanup code

Co-authored-by: mugisoba <mugisoba+github@icloud.com>
2020-04-06 09:27:13 -07:00
stefan301 3af7359345
[csharp] flatc should generate a 'Create…' method for tables with struct field… (#5818)
* flatc should generate a 'Create…' method for tables with struct fields when also generating the object based api (C#)
https://stackoverflow.com/questions/60724317/flatc-should-generate-a-create-method-for-tables-with-struct-fields-when-al

* missing namespace fixed: C:\projects\flatbuffers\tests\namespace_test\NamespaceA\TableInFirstNS.cs(30,7): error CS0246: The type or namespace name 'StructInNestedNST' could not be found (are you missing a using directive or an assembly reference?) [C:\projects\flatbuffers\tests\FlatBuffers.Test\FlatBuffers.Test.csproj]

Co-authored-by: stefan301 <Stefan.Felkel@de.Zuken.com>
2020-03-23 09:39:26 -07:00
Wouter van Oortmerssen 6df40a2471 pre-tag version bump for 1.12
Change-Id: I84a9365e9d8a1afe333b1df85058401ffe0a6b7c
2020-03-12 15:33:39 -07:00
Marc Butler 0e3fdd0eea
Escape characters in jsonschema descriptions (#5644)
* Escape JSON Schema comments

* Add quotes to monster comment

Thus exercising the JSON Schema comment escape support.
2020-03-12 12:10:30 -07:00
Wouter van Oortmerssen 7c37abe92d
[C#] add ObjectAPI Serialization Utility (#5785)
* [C#] add ObjectAPI Serialization Utility

* set InitialBufferSize to 64k

* rename SerializeToFlatBuffers to SerializeToBinary
2020-03-05 09:33:22 -08:00
mugisoba 173e10fdf1
[C#] support Json Serialization (#5752)
* support json serialization

* fix invalid json format.
* string must be written with double quotes.
* remove commma after the last object member.

* fix indent

* Revert "fix invalid json format."

This reverts commit d6820ed50c.

* quated string value.

* add cs-gen-json-serializer flag.

* fix preprocessor indent

* ENABLE_JSON_SERIALIZATION -> ENABLE_JSON_SERIALIZATION_TEST

* share TestBuffer method

* remove ENABLE_JSON_SERIALIZATION

* remove duplicated test data

* [windows] add nuget restore and copy test data.

* [docker mono] share msbuild settings with windows. add nuget restore and copy test data.

* add some note for json api.
2020-02-10 17:43:36 -08:00
mugisoba 7418d85872
[C#] support Object API (#5710)
* [C#] support Object API

* fix sign-compare

* fix indent

* add new line before for loop.

* using auto whenever possible

* reduce the amout of blank lines.

* wip: support vectors of union

* done: support unions of vectors

* set C# version to 4.0
* remove null propagation operator
* remove auto property initializer
* remove expression-bodied method
* remove pattern matching

* add Example2 to NetTest.sh

* separate JavaUsage.md and CsharpUsage.md from JavaCsharpUsage.md

* add C# Object based API notes.

* support vs2010.

* remove range based for loop.

* remove System.Linq

* fix indent

* CreateSharedString to CreateString

* check shared attribute

* snake case
2020-01-30 10:18:28 -08:00
Somo bee1df96dc [Go] Replace references to hardcoded ”Monster" etc with idiomatic go wherever possible (#5716)
* go: replace objAPI-generated Pack func with method

See discussion at https://github.com/google/flatbuffers/issues/5668

* go: replace generated union type UnPack func with method

Similar to discussion https://github.com/google/flatbuffers/issues/5668

But signature:
```
func AnyUnPack(t Any, table flatbuffers.Table) *AnyT
```

Becomes,
```
func (rcv Any) UnPack(table flatbuffers.Table) *AnyT
```
2020-01-16 16:19:00 -08:00
dreifachstein 35daaf83d3 [Java] Replace Table.UTF8_CHARSET with StandardCharsets.UTF_8 (#5696)
StandardCharsets.UTF_8 is already used in FlexBuffersBuilder.
2020-01-06 09:28:19 -08:00
lu-wang-g a2c12900aa Optimize Pack method using numpy (#5662)
Add the support to pack using numpy for scalar vectors when numpy is available.
2019-12-26 21:42:11 -05:00
lu-wang-g 65f8703572 Flatbuffers Python Object API (#5616)
* Flatbuffers Python Object API

Implement the logic to generate the Python object API that can
unpack the data from a buf class into an object class, and pack
the data of an object class to a buf class.

* Fix the build issues

Remove unused parameters and replace auto in the for-loop statement
with std::string to make it compatible with VS2010.

* Fix the build issues.

* Add support for Array type

Added logic to handle Array type in Python Object API. Updated the
generated code accordingly.

* Fix the old style casting from int to char

* Fixed another conversion from int to char

* Fixed the import for typing

Importing typing may cause errors when a machine do not have the
moduel typing installed. This PR fixes the issue by guarding
"import typing" with the "try/except" statement.

* Fix issue of iterating the vector of import list

* Update the generated examples using generate_code.sh

* Fix the import order for typing

The import list was stored in unordered_set, so that each generated
codes may have different import order. Therefore, it failed in the
consistency test where two generated copies need to have exactly the
same apperance.

* Optimize unpack using numpy

Use numpy to unpack vector whenever it is possible to improve unpack
performance.

Also, added codegen command for Python specificly in generate_code.sh,
because --no-includes cannot be turn on for Python.

* Fix the import order

* Update generate_code.bat for windows accordingly

* Replace error message with pass

Avoid printing error message for every Python2 users about typing.
Replace it with pass.
2019-12-02 14:11:28 -08:00
Tiago Silva 3c964e10ab [GO] Fix support for enums with underscores and Unions with imported members (#5600)
* Fix Enum Stringer method when Enum has underscores

Fixes #5481

* Fix go package importing itself when Union has imported members.
2019-11-26 12:25:36 -08:00
Malar Kannan 6beb9f49cb Support for python grpc - continuing the work from the pull request #4270 #4705 (#5613)
* Support for python grpc

* add few fixes

* Fixes build

* Fix python generator

* Add tests

* Fix grpc python test

* Fix tests and add incomplete python generator

* Fix python generator

* Add python generator methods

* Fix Appveyor build

* grpc python support v0.1

* Update tests

* update grpctest

* Remove duplicated code and fix a brace

* tests for flatbuffers grpc python

* Updated tests + removed SerializeToString, From String

* remove pickle import

* include missing files in ci - BUILD and generated test result
2019-11-14 16:58:35 -08:00
Derek Bailey 46ae3f80a6 [C++, Java, C#, TypeScript, JavaScript] Skip generation of mutable union types (#5599)
* Skip generation of mutable union types

* Removed C# and Java unit tests that mutated a Union type
2019-11-04 14:54:44 -08:00
Paulo Pinheiro 8526e12d73 [Kotlin] Fix union vector accessor after change in Java API (#5605)
Kolin uses java library as dependency, which changed the way it access union vector recently
(e365c502ff).

This changes updates kotlin code generation to match Java's changes.
2019-11-04 14:25:07 -08:00
Lawrence Chan 964365ba69 [Go] Add UnPackTo functions (#5598) 2019-11-04 12:12:25 -08:00
iceboy 32254b7acd [Go] Object API support (#5339)
* start

* works for current usages!

* unpack: vector of struct

* optimize byte slice

* support nested struct

* support null table

* support struct

* support union

* update generated code

* grumble

* fix compiler warning

* update generated code

* wrap type in namespace

* bug

* wrap in namespace

* enum byte arrays

* generate struct for unions

* basic testing

* remove branching

* fix assert

* pack vector of fixed structs correctly

* omit null vectors

* Refactor Union Pack and UnPack methods

Remove append usage to increase code efficiency when dealing with large vectors

* generate goldens
2019-10-31 11:13:45 -07:00
Derek Bailey 8d5e424c65 Add ByteBuffer copy for vector of bytes in Java (#5587) 2019-10-28 09:30:31 -07:00
Kulikov Alexey e365c502ff Java: Added access object for vector of struct and vector of tables. (#5233)
* Java: Added access object for vector of struct and vector of tables.

* Java: Workarounds removed when accessing the union vector.
2019-09-23 09:22:43 -07:00
Kevin Fort 2706381eef Add element size parameter to __vector_as_arraysegment [c#] (#5512)
* Add element size parameter to __vector_as_arraysegment

Add element size parameter to __vector_as_arraysegment fixing issue where VectorAsBytes returns incorrect size span for multibyte element types.

* Update codegen

Update codegen and Table to return typed span.

* update test files

update test files
2019-09-10 17:07:46 -07:00
Jaemin Park 4b870aca98 [Javascript] Fix syntax error for signed enum (#5503)
* wrap quotes to enum name map to prevent syntax errorn when enum value is negative

* Add a test that covers signed enum case
2019-09-05 10:22:04 -07:00
Nathan Williams d0e3870c0f [C#] Fix retrieving enumeration vectors as arrays (#5457)
* [C#] Fix retrieving enumeration vectors as arrays

* [C#] Don't generate CreateVectorBlock for enums
2019-09-03 14:10:54 -07:00
svenk177 4525c91be3 Fix incorrect padding in arrays of structs (Issue #5484) (#5491) 2019-08-23 10:46:47 -07:00
Joseph Pyott 9fa8245e81 Python: Added support for file_identifiers (#5123)
* Python: Added support for file_identifiers

* Added tests. Fixed file_identifier code.

* Python: Fixed excessive padding of file_identifier. Repaired tests.

* Python: Made code compatible with python2.7

* Python: Typo fix in @endcond

* whitespace normaalization

* Stylistic change from if(not X is None) to if(X is not None). Added comment to type string.

* Python: Added support for automatic code generation of file_identifiers. Added tests for said code generation.

* converted sprintf to snprintf

* Bugfix, added snprint deffinition for MSVC

* changed snprint deffinition for MSVC to sprint_s

* changed scanf to IntToStringHex. Renamed HasFileIdentifier to GenHasFileIdentifier.

* Added updated genereated code to commit

* Python bugix: flatc no longer produces HasFileIdentfier for shcemas with no file identifier

* Added tests to verify `MonsterBufferHasIdentifier` returns false on no Identifier

* Python: added tests for GetBufferIdentifier and BufferHasIdentifier
Python: removed unessasary parenethesis in if statements
Minor format changes.

* Python : correceted instances of keyword arguments being called as positional arguments

* fixed typos and grammer in comments

* Minor style fixes

* Indentation fix

* Equals style changes

* Python: Fixed Alignment Issues. Changed test code to test against atual output

* Ran make(forgot to run make last commit)

* Python: Style changes

* Style changes

* indentation and style

* readded CONTRIBUTING.md

* Formatting tweak

Mostly to make CI run again

* More formatting fixes

* More formatting fixes

* More formatting fixes

* More formatting fixes

* Formatting fix

* More formatting fixes

* Formatting

* ran generate_code.sh
2019-07-26 11:06:25 -07:00
Paulo Pinheiro de9aa0cdee Add basic Kotlin support (#5409)
* [Kotlin] Add kotlin generate code for tests and add
kotlin test to TestAll.sh

* [Kotlin] Add Kotlin generator

This change adds support for generating Kotlin classes.

The approach of this generator is to keep it as close
as possible to the java generator for now, in order
to keep the change simple.

It uses the already implemented java runtime,
so we don't support cross-platform nor js Kotlin yet.

Kotlin tests are just a copy of the java tests.

* Add optional ident support for CodeWriter

Identation is important for some languages and
different projects have different ways of ident
code, e.g. tabs vs spaces, so we are adding optional
support on CodeWriter for identation.

* [Kotlin] Add Documentation for Kotlin

* [Kotlin] Modify generated code to use experimental Unsigned types.
2019-07-22 16:05:15 -07:00
Wouter van Oortmerssen 123c7a4890 Updated missing generated code for PR #5313 (fixed arrays)
Change-Id: I249140119e6241beb5aec5670d0e5ccddc8f5251
2019-06-20 10:21:10 -07:00
svenk177 e635141d5b Add support for fixed-size arrays (#5313) 2019-06-18 00:15:13 +02:00
Vladimir Glavnyy 0d2cebccfe Add FLATBUFFERS_COMPATIBILITY string (#5381)
* Add FLATBUFFERS_COMPATIBILITY string

- Add a new __reset method NET/JAVA which hides internal state

* Resolve PR notes

* Use operator new() to __init of Struct and Table

* Restrict visibility of C# Table/Struct to internal level
2019-06-17 19:16:21 +02:00
John Luxford a80db8538c [C#, Java, C++] Fixes issue #5399 by always including namespaces (#5404)
* [C#] Fixes issue #5399 by always including namespaces

* Updated tests for code generator changes

* Fixed 'As' method names
2019-06-14 17:47:07 +02:00
Vladimir Glavnyy 95004218f7 Fix multi-line comments for cpp enums (#5345) (#5346)
- fix CSharp comments generation
- fix Python comments generation
- fix Lua comments generation
- fix PHP comments generation
- fix Dart comments generation
- add brief description of Color enum
- add multi-line comments to the Monster:Color
2019-06-02 12:36:49 -07:00
Wouter van Oortmerssen b652fcc3a7 Break internal Java/C# APIs
This is done on purpose, to avoid API version mismatches that
can cause bad decoding results, see:
https://github.com/google/flatbuffers/issues/5368

Change-Id: I2c857438377e080caad0e2d8bcc758c9b19bd6ec
2019-05-31 13:00:55 -07:00