Commit Graph

216 Commits

Author SHA1 Message Date
Wouter van Oortmerssen 4d7890c2c9 Fixed whole-number float default values missing a .0 suffix.
A previous commit that added "f" for C++/Java/C# would break
on gcc of constants like 3f, which are now output as 3.0f

Tested: on Linux

Change-Id: If9cabbe3c6d6948a5050b8b123bda9c06e181f52
2016-04-18 11:50:46 -07:00
Wouter van Oortmerssen 29d957ed5e Fixed missing "f" on float default values in C++/Java/C#
Bug: 28145201
Change-Id: I5a1818c40c2f4fbd00cfec3362040407976f7a39
Tested: on Linux.
2016-04-13 17:29:03 -07:00
Wouter van Oortmerssen 72fc45aa6a Made user-defined attributes available in the reflection data.
Tested: on Linux.

Bug: 27923233
Change-Id: Ic16675650e4a8e138c163f1e2131a3aad7008ada
2016-04-11 17:36:56 -07:00
Wouter van Oortmerssen e597ad8f0f Fixed pre-declarations of included types in generated code.
This was harmless, but unnecessary.

Change-Id: I1365a725e254d4ebbda081110a50277cb5118323
Tested: on Linux.
2016-04-11 11:05:42 -07:00
Wouter van Oortmerssen 5e3f9d5175 Merge branch 'master' of https://github.com/google/flatbuffers 2016-04-04 16:55:25 -07:00
Armen Baghumian 28a3c939e7 Implement __vector_as_bytes and methods to get [ubyte] efficiently
Currently in order to get a value type of [ubyte] in PHP, iteration is
necessary which is not efficient. Helper __vector_as_bytes has been
implemented in order to return the byte arrays in PHP efficiently.

Appropriate methods also been added to use aforementioned method to return
the byte array. (e.g. get*Bytes()).

The reason the methods are named get*Bytes() and not for instance
get*ByteArray() is the fact that PHP doesn't support byte arrays and the
binary safe string implementation in PHP is used to simulate byte arrays
and since there is chance for PHP users to confuse this with PHP arrays
the name get*Bytes() has been chosen.

In the future __vector_as_bytebuffer() method can also be implemented to
return PHP implementation of ByteBuffer.
2016-03-29 14:56:09 +11:00
Wouter van Oortmerssen e6b79f0002 Added stream & idempotent annotations for RPCs.
Change-Id: Ia8651c1051808fdda0dc0ba52ec991777f868e88
Tested: on Linux.
2016-03-09 15:03:05 -08:00
Wouter van Oortmerssen 1a63eb46bb Added RPC declarations to the schema parser.
This is the first step in RPC support. Actual code generation
to follow.

Change-Id: I96c40fec3db671d100dd9eb509a71c5cbe55bfb2
Tested: on Linux.
Bug: 20122696
2016-03-09 13:47:40 -08:00
Wouter van Oortmerssen fbc8af40e3 Allow JSON numeric fields to be specified by a numeric data in a string.
Change-Id: I6a3fae1e71434a7384edc39b8602bd84a0432edb
Tested: on Linux.
Bug: 24140897
2016-03-07 17:22:51 -08:00
Wouter van Oortmerssen 709e720839 Merge branch 'master' of https://github.com/google/flatbuffers 2016-03-07 15:04:18 -08:00
Wouter van Oortmerssen 958fc6ec49 Added support for easy string pooling.
Change-Id: I790cf681c1bffff800d77afb0e2f908d1c827679
Tested: on Linux.
Bug: 26186542
2016-03-07 12:58:36 -08:00
Wouter van Oortmerssen 617fedf349 Merge pull request #3765 from Mischanix/js-typed-arrays
Javascript helper to get typed array views
2016-02-26 09:51:50 -08:00
Evan Wallace 31b30335f6 Fix #3773: Generated JS now avoids the flatbuffers object 2016-02-25 01:06:16 -08:00
Nalinichandra Penke cbab26673b Fix #3775: Skip unknown field names if they're quoted 2016-02-22 14:34:20 -06:00
Wouter van Oortmerssen 20c0082ee5 Fixed namespace code generation for C++
The code generator was assuming all declarations for the current
file sit in the same namepace. Now uses the "on demand" namespace
switching we had for the forward declarations.

Also fixed a bug related to namespace lookup.

Change-Id: Ib54a3efbc752cbb9590302fa0707c0c73448db3d
Tested: on Linux.
2016-02-17 11:26:38 -08:00
Robert Nix 9d92aeb182 Add helper for javascript typed arrays
For scalar vector fields, emit an Array helper that
returns a typed array view of the underlying bytes buffer.
2016-02-12 12:41:28 -06:00
Robert Nix 2f5d7ae645 Fix javascript unicode test
The generated buffer should be tested for semantic equivalence
to the correct buffer, instead of being tested for bytewise
equality.
2016-02-12 12:31:25 -06:00
Oli Wilkinson dbf6702371 Added support for C# partial class generation when the `csharp_partial` attribute is used on a table/struct. 2016-01-21 15:42:30 +00:00
Wouter van Oortmerssen db0727e943 Merge pull request #3734 from evolutional/cs-forcedefaults
Implemented ForceDefaults option on C# FlatBufferBuilder.
2016-01-20 13:46:49 -08:00
Wouter van Oortmerssen 0afac8f75a Merge branch 'master' of https://github.com/google/flatbuffers 2016-01-20 13:30:09 -08:00
Wouter van Oortmerssen 519dcdd0b2 Fixed Python unit test breakage.
Test was testing for a field to be None, even though it is populated
in one particular instance.

Change-Id: Id19848d01498d4c0a684efdb2bf49ff12c5b6758
Tested: on Linux.
2016-01-20 13:04:03 -08:00
Oli Wilkinson fff4590faf Implemented ForceDefaults option on C# FlatBufferBuilder.
Tested on: Windows, Unit Tests
2016-01-20 17:25:58 +00:00
Robert b7d97ff3de Merge pull request #3491 from faizanrashid/master
[BUG FIX] [MINOR] Fix encoding with unicode characters.
2016-01-19 17:56:26 -08:00
Mark Klara 69a31b807a Revamping the FlatBuffers docs.
Adding an API reference for the supported languages.

General docs cleanup, including a new `tutorial` section that
supports all of the supported languages.

Added samples for each supported language to mirror the new
tutorial page.

Cleaned up all the links by making them `@ref` style links,
instead of referencing the names of the generated `.html` files.

Removed all generated files that were unnecessarily committed.

Also fixed the C# tests (two were failing due to a missing file).

Bug: b/25801305

Tested: Tested all samples on Ubuntu, Mac, and Android. Docs were
generated using doxygen and viewed on Chrome.

Change-Id: I2acaba6e332a15ae2deff5f26a4a25da7bd2c954
2016-01-19 14:31:17 -08:00
Wouter van Oortmerssen d75d29e2fe Merge branch 'master' of https://github.com/google/flatbuffers 2016-01-19 14:10:49 -08:00
Wouter van Oortmerssen 049f3f7907 Added support for parsing JSON null value.
These cause the field in question to be skipped.

Bug: 16550393
Change-Id: Id05104e89818ee773b8a91fdcc86e18061b9a82f
Tested: on Linux.
2016-01-19 14:05:27 -08:00
Wouter van Oortmerssen e848137ded Added min/max values for enums/unions.
Bug: 21642898
Change-Id: Ifaf0b3c4274fe30ef29507ba1c1216d700efe85b
Tested: on Linux.
2016-01-19 14:05:27 -08:00
Wouter van Oortmerssen 8472b5f224 Merge pull request #3513 from evolutional/fix-3500
Java/C#: generation of typed helpers when using nested_flatbuffers
2016-01-19 10:40:02 -08:00
Oli Wilkinson eaa2b414b2 Added generation of typed helpers when using nested_flatbuffers in Java/C#. Fixes #3500 2016-01-18 15:23:14 +00:00
Chandra Penke b63ebad49d Fix #3497: Add support for compiling in g++ 4.4 and 4.5
- Removed uses of lambda expressions

- Added custom defines for constexpr and nullptr

- Removed trailing comma of last value from generated enums
2016-01-09 06:30:50 -06:00
Faizan Rashid af23683311 [BUG FIX] [MINOR] Fix encoding with unicode characters.
When passing a unicode string to builder.CreateString, the
default encoding assumed all characters can be encoded
using ascii. Added a fix so a user can specify the
encoding and how to handle errors when creating strings.
2015-12-31 09:45:09 +05:00
Wouter van Oortmerssen 8f13c828f5 Merge pull request #2776 from ncpenke/skip-unknown-json-fields
Fix #2775: Add parser option to skip unknown JSON fields
2015-12-29 10:29:11 -08:00
Wouter van Oortmerssen e6240f4039 Merge pull request #2790 from chobie/php-table-fix
(PHP) fixes getting indirect table, also fixes getInt method on 32bit machine
2015-12-29 10:25:21 -08:00
Shuhei Tanuma 4691558ee3 (PHP) remove duplicate test 2015-12-24 15:50:03 +09:00
Shuhei Tanuma 7fbd9b8de4 (PHP) improve indirect buffer test 2015-12-24 15:35:28 +09:00
Nalinichandra Penke 13d0594b4c Fix #2775: Add parser option to skip unknown JSON fields 2015-12-22 00:02:19 -08:00
Wouter van Oortmerssen 1891537236 Fixed reflection setting string not changing size field.
Change-Id: I3c3e88a79667d1733b6c47e43b55d8b2604ca8e2
Tested: on Linux.
2015-12-21 16:20:03 -08:00
Wouter van Oortmerssen 995ee86a6e Added an IsFieldPresent helper function.
This is implemented as a template function, since Table::CheckField
is not reachable by subclasses of Table (private base class).

Change-Id: I1ed4d47ce7cb672460ccab61cf7442eb9136b0f1
Tested: on Linux.
Bug: 26273432
2015-12-21 12:17:59 -08:00
Shuhei Tanuma c9198dbbb8 (PHP) fixes getting indirect table, also fixes getInt method on 32bit machine. 2015-12-17 11:35:31 +09:00
Wouter van Oortmerssen a9909a0c18 Made sure all namespace test files get generated.
Also included them in the C++ test.

Change-Id: Ib0c8470f0aacdf16616c27494abdda57a010195d
Tested: on Linux.
2015-12-14 16:15:43 -08:00
Wouter van Oortmerssen c44bc6a719 Merge branch 'master' of https://github.com/google/flatbuffers 2015-12-09 12:57:12 -08:00
Wouter van Oortmerssen 6fba6b6e71 Fixed compiler warnings for cast to bool in generated code.
Change-Id: I7727aeb478feb23d8ef66fd1ba9499b142b3ea7d
Tested: on Linux.
2015-12-09 12:56:24 -08:00
Wouter van Oortmerssen 96cd275603 Merge pull request #288 from mfcollins3/csharp-byte-buffer
Add Get Bytes Method Generator for C#
2015-12-07 17:35:57 -08:00
Wouter van Oortmerssen 8e6758d205 Merge pull request #608 from evolutional/master
Fix to #360 - Fully qualified names outside of current NS
2015-12-07 10:33:38 -08:00
Armen Baghumian f622e5996c Optimize get* operation
It's slightly faster to convert the value to signed value in PHP as
opposed to use pack and unpack.

For 1M get operation the difference is:

    getShort in 3.3272678852081 seconds
    getInt in 3.8338589668274 seconds
    getLong in 5.6381590366364 seconds
    getLong (neg) in 5.6149101257324 seconds

vs

    getShort in 2.7564418315887 seconds
    getInt in 3.1612701416016 seconds
    getLong in 3.1369340419769 seconds
    getLong (neg) in 3.1478710174561 seconds

And since pack("P") and unpack("q") has been removed now ByteBuffer
works for PHP >= 5.4
2015-12-05 23:32:35 +00:00
Armen Baghumian 77fbdd28e2 Correct the max/min signed/unsigned 32-bit int
The test was trying to pack an unsigned int which couldn't fit as a
signed int and putInt() wasn't doing the validation in the correct range
2015-12-05 23:32:35 +00:00
Oli Wilkinson c9ad6d5496 Fix to #360 - Updated the general generator (Java/C#) to emit fully qualified names where the referenced object isn't directly in this namespace. Added test fbs files to verify compilation. 2015-12-05 13:42:09 -05:00
Michael Collins e083e466b8 Add Get Bytes Method Generator for C#
I updated idl_gen_general.cpp to add support for generating a Get Bytes
method for a vector to the generated C# source code. Given a byte vector
field named Foo, a method named GetFooBytes() will be generated in the
C# source code that will return an ArraySegment<byte> value referencing
the vector data in the underlying ByteBuffer.

I added a method to Table.cs named __vector_as_arraysegment that is used
by the code generated by the change to the C# generator.
__vector_as_arraysegment will take the offset of the vector and will
return the ArraySegment<byte> value corresponding to the bytes that
store the vector data.

I updated FlatBuffersExampleTests.cs to add tests to validate my
implementation of Table.__vector_as_arraysegment. I added tests to
demonstrate that the bytes for the monster's name can be extracted from
the underlying byte array. I also added tests to show that
Table.__vector_as_arraysegment returns a null value if the vector is not
present in the FlatBuffer.

I used the updated flatc.exe program to regenerate the C# source files
for the MyGame example. The new Monster class includes the GetXXXBytes
methods to return the byte arrays containing data for vectors.
2015-12-04 11:44:43 -07:00
Wouter van Oortmerssen 45bda6e08d Added --gen-all to generate code for a schema and all its includes.
Also refactored the way options are stored.

Change-Id: I709ac908cd2aba396c9c282725cf1d42ccce0882
Tested: on Linux.
2015-12-04 09:44:31 -08:00
Wouter van Oortmerssen 7b06041a7c C++ generated code now has constants for vtable offsets.
Besides making the generated code looking a lot more readable,
it also allows you to use these offsets in calls to
Table::CheckField, to see if a field is present in a table.

Change-Id: I1b4cc350c4f27c4e474c31add40c701ef4ae63b2
Tested: On Linux.
2015-12-02 11:12:39 -08:00