Commit Graph

28 Commits

Author SHA1 Message Date
Paweł Dziepak
4df4994b71 idl: fix generated writers when member functions are used
When using member name in an idetifer of generated class or method
idl compiler should strip the trailing '()'.
2017-02-27 17:05:58 +00:00
Paweł Dziepak
38ee69dee0 idl: allow writers to use any output stream
Original IDL generated code was hardcoded to always use bytes_ostream.
This patch makes the output stream a template parameter so that any
valid output stream can be used.
Unfortunately, making IDL writers generic requires updates in the code
that uses them, this is fixed in C++17 which would be able to deduce the
parameter in most cases.
2016-12-22 13:35:04 +01:00
Gleb Natapov
2e8b255741 Merge seastar upstream
* seastar 0303e0c...e534401 (6):
  > Merge "enable rpc to work on non contiguous memory for receive" from Gleb
  > install-dependencies.sh: install python3 for Ubuntu/Debian, which requires for configure.py
  > fix tcp stuck when output_stream write more than 212992 bytes once.
  > scripts/posix_net_conf.sh: supress 'ls: cannot access /sys/class/net/<NIC>/device/msi_irqs/' error message
  > scripts/posix_net_conf.sh: fix 'command not found' error when specifies --cpu-mask
  > native_network_stack: Fix use after free/missing wait in dhcp

Includes: "Remove utils::fragmented_input_stream and utils::input_stream in favor of seastar version" from Gleb.
2016-09-15 12:12:16 +03:00
Paweł Dziepak
89f7b46f61 idl: switch to utils::input_stream
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-08-22 09:31:33 +01:00
Paweł Dziepak
dcf794b04d idl: make bytes compatible with bytes_ostream
This patch makes idl type "bytes" compatible with both bytes and
bytes_ostream.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-08-22 09:31:33 +01:00
Tomasz Grabiec
c3707ff754 idl: Avoid full deserialization in skip()
Fixes #1330.
2016-07-25 17:35:34 +02:00
Tomasz Grabiec
207c8d94f1 idl: Rename variable to a more meaningful name
Message-Id: <1465909911-10534-2-git-send-email-tgrabiec@scylladb.com>
2016-06-14 17:02:59 +03:00
Paul McGuire
8326fe7760 Clean up idl-compiler pyparsing usage
This patch makes a few minor improvements in the parser:

  - merge first and rest into 2-argument form of Word to define
    identifier – should give some performance boost, simpler code

  - replace Literal(keyword_string) with Keyword(keyword_string)
    throughout - stricter parsing, avoids misinterpreting identifiers
    with keywords

  - replace expr.setResultsName("name") with expr("name") throughout –
    this is a style change (no actual change in underlying parser
    behavior), but I find this form easier to follow

  - add calls to setName to make exceptions more readable

Message-Id: <005901d1bbd2$711f7bb0$535e7310$@austin.rr.com>
2016-06-08 08:13:05 +03:00
Duarte Nunes
9bd7d08fc7 idl-compiler: Default expr can refer to previous fields
This patch changes the idl-compiler so that the default value of a
field can be set to the value of a previous field in the class:

class P {
    uint32_t x;
    uint32_t y = x;
};

Signed-off-by: Duarte Nunes <duarte@scylladb.com>
2016-06-02 16:21:36 +02:00
Amnon Heiman
e26002d581 idl-compiler: default constructor of complex types
This patch solve a problem where a complex type is define as version
depended (with the version attribute) but doesn't have a default value.

In those cases the default constructor is used, but in the case of
complex types (template) param_type should be use to get the C++ type.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
Message-Id: <1463916723-15322-1-git-send-email-amnon@scylladb.com>
2016-05-22 15:32:29 +03:00
Tomasz Grabiec
d0ae2e3607 idl-compiler: Make sub-streams stored in views be properly bounded
Currently when reading a view to an object the stream stored has the
same bound as the containing stream, not the bounds of the object
itself. The serializer of the view assumes that the stream has the
bounds of the object itself.

Fixes dtest failure in
paging_test.py:TestPagingSize.test_undefined_page_size_default

Fixes #963.

Message-Id: <1456854556-32088-1-git-send-email-tgrabiec@scylladb.com>
2016-03-01 19:50:42 +02:00
Amnon Heiman
1c7bc28d35 idl-compiler: change optional vector implementation
This patch change the way optional vector are implemented.

Now a vector of optional would be handle like any other non primitive
types, with a single method add() that would return a writer to the
optional.

The writer to the optional would have a skip and write method like
simple optional field.

For basic types the write method would get the value as a parameter, for
composite type, it would return a writer to the type.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
Message-Id: <1456796143-3366-2-git-send-email-amnon@scylladb.com>
2016-03-01 09:41:30 +02:00
Tomasz Grabiec
ee8509cf36 idl-compiler: Introduce add(*_view) on vector 2016-02-26 12:26:13 +01:00
Tomasz Grabiec
4ab0ca07f1 idl-compiler: Catch un-closed frame errors sooner
By initilizing them to 0 we can catch unclosed frames at
deserialization time. It's better than leaving frame size undefined,
which may cause errors much later in deserialization process and thus
would make it harder to identifiy the real cause.
2016-02-26 12:26:13 +01:00
Amnon Heiman
9ea3ffe527 idl-compiler: Add optional support
This patch adds optional writer support an optional field can be either
skip or set.

For vector of optional, a write_empty method will
add 1 to the vector count and mark the optional as false.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
2016-02-26 12:25:08 +01:00
Tomasz Grabiec
97558b2cfe idl-compiler: Put serializers inside template class specializations
The problem is that a generic functions (eg. skip()) which call
deserialize() overloads based on their template parameter only see
deserilize() overloads which were declared at the time skip() was
declared and not those which are available at the time of
instantiation. This forces all serializers to be declared before
serialization_visitors.hh is first included. Serializers included
later will fail to compile. This becomes problematic to ensure when
serializers are included from headers.

Template class specialization lookup doesn't suffer from this
limitation. We can use that to solve the problem. The IDL compiler
will now generate template class specializations with read/write
static methods. In addition to that, default serializer() and
deserialize() implementations are delegating to serializer<>
specialization so that API and existing code doesn't have to change.

Message-Id: <1456423066-6979-1-git-send-email-tgrabiec@scylladb.com>
2016-02-25 20:00:49 +02:00
Amnon Heiman
f461ebc411 idl-compiler: Add pos and rollback to serialize vector
This adds the ability to store a position of a serialized vector and to
rollback to that stored position afterwards.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
Message-Id: <1456041750-1505-3-git-send-email-amnon@scylladb.com>
2016-02-23 17:49:51 +01:00
Paweł Dziepak
28fa2a6493 idl-compiler: add serialization callback interface
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-02-19 21:50:29 +00:00
Paweł Dziepak
7586e47004 idl-compiler: avoid copy of basic types
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-02-19 21:47:42 +00:00
Paweł Dziepak
2ea735f5ed idl-compiler: accept both bytes and bytes_view
bytes can always be trivially converted to bytes_view. Conversion in the
other direction requires a copy.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-02-19 21:47:42 +00:00
Paweł Dziepak
18b1c66287 idl-compiler: allow auto-generated serializers in writers
This patch allows using both auto-generated serializers or writer-based
serialization for non-stub [[writable]] types.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-02-19 21:47:21 +00:00
Paweł Dziepak
af2241686f idl-compiler: add reindent() function
This helps having C++ code properly indented both in the compiler source
code and in the auto-generated files.

Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-02-19 21:20:09 +00:00
Paweł Dziepak
7d1a66d3a0 idl-compiler: move writers and view to *.impl.hh
Signed-off-by: Paweł Dziepak <pdziepak@scylladb.com>
2016-02-19 21:17:00 +00:00
Amnon Heiman
fbc6770837 idl-compiler: Verify member type
This patch adds static assert to the generated code that verify that a
declare type in the idl matches the parameter type.

Accepted type ignores reference and const when comparison.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
2016-02-17 21:44:53 +02:00
Amnon Heiman
714d4927d6 idl-compiler: add writers and view to classes.
This patch adds a writer object to classes in the idl.

It adds attribute support to classes. Writer will be created for classes
that are marked as writable.

For the writers, the code generator creates two kind of struct.
states, that holds the write state (manly the place holders for all
current objects, and vectors) and nodes that represent the current
position in the writing state machine.

To write an object create a writer:
For example creating a writer for mutation, if out is a bytes_ostream

writer_of_mutation w(out);

Views are used to read from buffer without deserialize an entire
object.
This patch adds view creation to the idl-compiler. For each view a
read_size function is created that will be used when skipping through
buffers.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
2016-02-17 18:42:09 +02:00
Gleb Natapov
6a581bb8b6 messaging_service: replace rpc::type with boost::type
RPC moved to boost::type to make serializers less rpc centric. Scylla
should follow.

Message-Id: <20160126164450.GA11706@scylladb.com>
2016-01-27 11:57:45 +02:00
Amnon Heiman
039e627b32 idl-compiler: Fix an issue with default values
This patch fix an issue when a parameter with a version attribute had a
default value.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
Message-Id: <1453723251-9797-1-git-send-email-amnon@scylladb.com>
2016-01-25 14:32:00 +02:00
Amnon Heiman
4a34ed82a3 Add code generation for serializer and deserializer
The code generation takes a schema file and create two files from it,
one with a dist.hh extension containing the forward declarations and a second
with dist.impl.hh with the actual implementation.

Because the rpc uses templating for the input and output streams. The
generated functions are templates.

For each class, struct or enum, two functions are created:
serialize - that gets the output buffer as template parameter and
serialize the object to it. There must be a public way to get to each of
the parameters in the class (either a getter or the parameter should be
public)

deserialize - that gets an input buffer, and return the deserialize
object (and by reference the number of char it read).
To create the return object, the class must have a public constructor
with all of its parameters.

The solution description can be found here:
https://github.com/scylladb/scylla/wiki/Serializer-Deserializer-Code-generation

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
2016-01-24 12:12:51 +02:00