bond 0.5.0.0 → 0.6.0.0
raw patch · 5 files changed
+37/−21 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- bond.cabal +1/−1
- src/Language/Bond/Codegen/Cpp/Types_cpp.hs +5/−7
- src/Language/Bond/Codegen/Cpp/Types_h.hs +14/−0
- src/Language/Bond/Codegen/Cs/Comm_cs.hs +4/−2
- src/Language/Bond/Syntax/SchemaDef.hs +13/−11
bond.cabal view
@@ -2,7 +2,7 @@ -- Licensed under the MIT license. See LICENSE file in the project root for full license information. name: bond -version: 0.5.0.0 +version: 0.6.0.0 cabal-version: >= 1.8 tested-with: GHC>=7.4.1 synopsis: Bond schema compiler and code generator
src/Language/Bond/Codegen/Cpp/Types_cpp.hs view
@@ -31,6 +31,10 @@ if null declParams then CPP.schemaMetadata cpp s else mempty -- global variables for enum name/value conversions + -- + -- ToString is intentionally not implemented in terms of FromEnum, as + -- ToString returns a reference to the name stored in the map. FromEnum + -- copies this name into the output paramater. statics Enum {..} = [lt| namespace _bond_enumerators { @@ -58,15 +62,9 @@ void FromString(const std::string& name, enum #{declName}& value) { - std::map<std::string, enum #{declName}>::const_iterator it = - _name_to_value_#{declName}.find(name); - - if (_name_to_value_#{declName}.end() == it) + if (!ToEnum(value, name)) bond::InvalidEnumValueException(name.c_str(), "#{declName}"); - - value = it->second; } - } // namespace #{declName} } // namespace _bond_enumerators|] where
src/Language/Bond/Codegen/Cpp/Types_h.hs view
@@ -373,6 +373,20 @@ return true; } + + inline + bool FromEnum(std::string& name, enum #{declName} value) + { + std::map<enum #{declName}, std::string>::const_iterator it = + _value_to_name_#{declName}.find(value); + + if (_value_to_name_#{declName}.end() == it) + return false; + + name = it->second; + + return true; + } } // namespace #{declName} } // namespace _bond_enumerators
src/Language/Bond/Codegen/Cs/Comm_cs.hs view
@@ -112,7 +112,8 @@ public global::System.Threading.Tasks.Task<global::Bond.Comm.IMessage<#{getMessageResultTypeName}>> #{methodName}Async(global::Bond.Comm.IMessage<#{getMessageInputTypeName}> param, global::System.Threading.CancellationToken ct) { return m_connection.RequestResponseAsync<#{getMessageInputTypeName}, #{getMessageResultTypeName}>( - "#{getDeclTypeName idl s}.#{methodName}", + "#{getDeclTypeName idl s}", + "#{methodName}", param, ct); }|] @@ -129,7 +130,8 @@ public void #{methodName}Async(global::Bond.Comm.IMessage<#{getMessageInputTypeName}> param) { m_connection.FireEventAsync<#{getMessageInputTypeName}>( - "#{getDeclTypeName idl s}.#{methodName}", + "#{getDeclTypeName idl s}", + "#{methodName}", param); }|] where
src/Language/Bond/Syntax/SchemaDef.hs view
@@ -70,8 +70,10 @@ , element :: Maybe [TypeDef] , key :: Maybe [TypeDef] , bonded_type :: Maybe Bool - -- Domain of Int is ListSubType - , list_sub_type :: Maybe Int + -- Domain of Int is ListSubType. + -- Currently not present in TypeDef, as its addition is breaking + -- some users that have already serialized SchemaDef structs. + --, list_sub_type :: Maybe Int } data Metadata = @@ -174,19 +176,19 @@ -- TypeDef for specified type typeDef typ | isScalar typ || isString typ || isMetaName typ - = TypeDef (Just $ typeId typ) Nothing Nothing Nothing Nothing Nothing + = TypeDef (Just $ typeId typ) Nothing Nothing Nothing Nothing | otherwise = case typ of - BT_Blob -> listDef BT_Int8 (Just 2) - (BT_List t) -> listDef t Nothing - (BT_Vector t) -> listDef t Nothing - (BT_Nullable t) -> listDef t (Just 1) - (BT_Set t) -> TypeDef (Just 12) Nothing (Just [typeDef t]) Nothing Nothing Nothing - (BT_Map k t) -> TypeDef (Just 13) Nothing (Just [typeDef t]) (Just [typeDef k]) Nothing Nothing + BT_Blob -> listDef BT_Int8 + (BT_List t) -> listDef t + (BT_Vector t) -> listDef t + (BT_Nullable t) -> listDef t + (BT_Set t) -> TypeDef (Just 12) Nothing (Just [typeDef t]) Nothing Nothing + (BT_Map k t) -> TypeDef (Just 13) Nothing (Just [typeDef t]) (Just [typeDef k]) Nothing (BT_Bonded t) -> (typeDef t) {bonded_type = Just True} (BT_Maybe t) -> typeDef t - t -> TypeDef Nothing (Just (structIdx t)) Nothing Nothing Nothing Nothing + t -> TypeDef Nothing (Just (structIdx t)) Nothing Nothing Nothing where - listDef t list_sub_type = TypeDef (Just 11) Nothing (Just [typeDef t]) Nothing Nothing list_sub_type + listDef t = TypeDef (Just 11) Nothing (Just [typeDef t]) Nothing Nothing variant = Variant Nothing Nothing Nothing Nothing Nothing Nothing attr [] = Nothing attr xs = Just $ concatMap (\a -> [qualifiedName $ attrName a, attrValue a]) xs