anuragraghavan / franca

Automatically exported from code.google.com/p/franca
0 stars 0 forks source link

Franca map key types should be restricted #67

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Franca allows any type as a map key, including very curious options like maps 
and unions. It is undefined how complex data types should be hashed to ensure 
this is done the same way on different systems/languages.

In the example below ComplexMap is not feasible for D-Bus nor IPC 
CommonAPI-C++.  

typeCollection x {

    struct Complextype {
        Int32 a
        String b
        MyUnion u
        MyOtherMap m
    }

    union MyUnion {
        UInt32 v1
        Float v2
    }

    map ComplexMap {
        Complextype to Complextype
    }

    map SimpleMap {
        String to Complextype
    }
}

It is also not expected that e.g. maps are useful as map keys. For complex data 
types like structures or unions a specification would be required to define how 
to compute hashes to use them as map keys.

Propose to restrict map keys to Strings.

Original issue reported on code.google.com by manfred....@bmw.de on 31 Oct 2013 at 3:36

GoogleCodeExporter commented 9 years ago
Reducing allowed key types to strings is certainly too restricted. There are 
lot of applications where integers are or enumerators used a key types. It 
should also be possible to use structs, e.g. using a "struct { Int16 x, Int16 y 
}" as a key for putting data items into a 2D space.

On the other hand, using maps as key types really seems far-fetched. But 
without further rationale it seems quite arbitrary to disallow maps as key 
types and allow everything else.

In any case, we can add a validation (allow only basic types as map key type) 
into the external validator which checks D-Bus implementability (issue 71).

Further comments?

Original comment by klaus.birken@gmail.com on 19 Feb 2014 at 11:31

GoogleCodeExporter commented 9 years ago
The D-Bus external validator for Franca now issues the following warning if 
non-primitive types are used as map-keys:
    D-Bus compatibility: D-Bus dictionaries support only primitive key types.

This has been implemented with commit 42adfb3 on develop and will be part of 
0.9.1. We will not implement further restrictions on the map key type in 
standard Franca (see comment #1).

Original comment by klaus.birken@gmail.com on 10 Nov 2014 at 12:42

GoogleCodeExporter commented 9 years ago

Original comment by klaus.birken@gmail.com on 19 Dec 2014 at 2:32

GoogleCodeExporter commented 9 years ago

Original comment by klaus.birken@gmail.com on 25 Jan 2015 at 11:16