ruby: implement a method to convert a type model into a simple ruby value

The goal is that this simple ruby value can be then marshalled in e.g.
JSON.
ruby: define #to_simple_value on Type instances

It converts to a representation that uses only Hash, Array and plain
strings and numbers. This allows to convert values into

In order to save some performance, it is possible to marshal containers
and arrays of numbers into a packed string using the pack_simple_arrays
option. See the method documentation for more details

Note that /std/string is converted to a String already
ruby: fix definition of #to_simple_value on /std/string

It must accept one argument

This fixes rock-core/tools-orocosrb#6
test: fix spurious infinite recursions when running all the tests together
ruby: create #to_json_value to handle JSON idiosyncracies

JSON cannot represent NaN, Infinity and -Infinity while XML and YAML
can, so add a special #to_json_value which is mostly #to_simple_value except for
these special cases
ruby: use symbols instead of strings for keys in #to_simple_value and #to_h

Using strings as keys is really awkward. Note that it does not affect
code that is beyond a marshaller such as JSON as symbols are converted
to strings in the process.
ruby: make the special handling of NaN and Infinity an option of #to_simple_value

The current effort of splitting between #to_simple_value and
to_json_value was obviously broken (since #to_json_value was
not going to be called recursively), and fixing it with the same
philosophy would require some serious over-engineering. Simply
make this special handling an option and set the option accordingly
when calling #to_json_value
Merge pull request #4 from orocos-toolchain/to_simple_value

Define ways to marshal typelib objects (models and values) as simple ruby values
typemodel: make "Type::ValidCategories" be a proper enum-value

and rename it to "NumberOfValidCategories"

"Typelib::Type::ValidCategories" was wrongly set to "Compound+1", a
remnant from 2005 -- impressive by itself ;-) the "Opaque" and
"Container" enums where then added in 2008 without adapting the value of
"ValidCategories". Seems like nobody is using this, so...

setting the start-value of the enum in "Typelib::Numeric" to
"Typelib::Type::ValidCategories" will cause the
"NumberOfValidCategories" in the "Typelib::Numeric" to include the
overall number of valid categories

Signed-off-by: Martin Zenzes <martin.zenzes@dfki.de>
typelib: fix -Wswitch warnings by throwing in "default" case

(or return "Qnil" for ruby)

after adding a new entry into the type-enum, there popped up some
-Wswitch errors because some "default"s were missing. added some throws.
also removed an assert which nobody can catch at runtime.

removed the "shut up gcc" dummy-return-statement -- does gcc still
complain in 2014?

Signed-off-by: Martin Zenzes <martin.zenzes@dfki.de>
typelib/exporter: remove deprecated function

the comment from 2008 says is deprecated. However, now that I get a
clear look at the signature and the body this function it looks actually
helpful in some cases... it will catch exceptions and return a boolean.
but its not consistent with the rest of the api.

anyways, is not used anywhere, hence removed... bäm.

Signed-off-by: Martin Zenzes <martin.zenzes@dfki.de>
typemodel: return a const-ref instead of a copy

do not make a copy if not needed to. if you wanna change the available
containers use the accessors.

Signed-off-by: Martin Zenzes <martin.zenzes@dfki.de>
Merge pull request #16 from jmachowinski/fix-typemodel-enums

typemodel: Fix minors things
ruby: fix the most obvious warnings reported while running the tests
ruby: make ConversionToMismatchedType#pretty_print report the field offsets

The most common occurence of mismatching types is differing layout, so...
ruby: allow setting or adding multiple metadata values in one call
metadata: allow empty value sets

So far, one could not make the difference betweeen a metadata key
set to empty and an unset one. This is problematic in e.g. orogen
where we have cases where the include list is empty (but is known
to be empty), as e.g. for /double.

This commit allows to make the difference, as well as to set a
metadata key to empty. It does not change the behaviour of existing
code as the new behaviour is dependent on
ruby: fix documentation
ruby: base64-encode the packed arrays returned by to_simple_value
add the size to the packed arrays returned by ArrayType#to_simple_value

This is for consistency reasons with the containers. From the point
of view of the receiving end, there is most likely not a difference
between fixed-size and variable-size arrays, so allow to handle them
the same way.