diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2017-04-20 09:48:31 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2017-04-20 09:48:31 -0400 |
commit | 37073e44e9895ea4ecc18fdd0a9b54f5ebb052fa (patch) | |
tree | e82aac08fa2a06d2011fca367195daa35a5c17ae /src/mongo/idl | |
parent | c192a1b9b1e223f8075ab5ce72dde372467f9650 (diff) | |
download | mongo-37073e44e9895ea4ecc18fdd0a9b54f5ebb052fa.tar.gz |
SERVER-28515 Add import support to IDL
Diffstat (limited to 'src/mongo/idl')
-rw-r--r-- | src/mongo/idl/SConscript | 3 | ||||
-rw-r--r-- | src/mongo/idl/basic_types.idl | 79 | ||||
-rw-r--r-- | src/mongo/idl/unittest.idl | 114 | ||||
-rw-r--r-- | src/mongo/idl/unittest_import.idl | 74 |
4 files changed, 159 insertions, 111 deletions
diff --git a/src/mongo/idl/SConscript b/src/mongo/idl/SConscript index 93a57d332e0..87c5d3c2158 100644 --- a/src/mongo/idl/SConscript +++ b/src/mongo/idl/SConscript @@ -17,7 +17,8 @@ env.CppUnitTest( target='idl_test', source=[ 'idl_test.cpp', - env.Idlc('unittest.idl')[0] + env.Idlc('unittest_import.idl')[0], + env.Idlc('unittest.idl')[0], ], LIBDEPS=[ '$BUILD_DIR/mongo/base', diff --git a/src/mongo/idl/basic_types.idl b/src/mongo/idl/basic_types.idl new file mode 100644 index 00000000000..198d8f20980 --- /dev/null +++ b/src/mongo/idl/basic_types.idl @@ -0,0 +1,79 @@ +# Copyright (C) 2017 MongoDB Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License, version 3, +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# IDL Basic Types +global: + cpp_namespace: "mongo" + +types: + string: + bson_serialization_type: string + description: "A BSON UTF-8 string" + cpp_type: "std::string" + deserializer: "mongo::BSONElement::str" + + int: + bson_serialization_type: int + description: "A BSON 32-bit integer" + cpp_type: "std::int32_t" + deserializer: "mongo::BSONElement::_numberInt" + + long: + bson_serialization_type: long + description: "A BSON 64-bit integer" + cpp_type: "std::int64_t" + deserializer: "mongo::BSONElement::_numberLong" + + double: + bson_serialization_type: double + description: "A BSON 64-bit floating point number" + cpp_type: "double" + deserializer: "mongo::BSONElement::_numberDouble" + + decimal: + bson_serialization_type: double + description: "A BSON 128-bit floating point decimal number" + cpp_type: "mongo::Decimal128" + deserializer: "mongo::BSONElement::_numberDecimal" + + bool: + bson_serialization_type: bool + description: "A BSON bool" + cpp_type: "bool" + deserializer: "mongo::BSONElement::boolean" + + # TODO: support bindata + # bindata: + # bson_serialization_type: bindata + # cpp_type: "std:" + # deserializer: "mongo::BSONElement::str" + + objectid: + bson_serialization_type: objectid + description: "A BSON ObjectID" + cpp_type: "mongo::OID" + deserializer: "mongo::BSONElement::OID" + + date: + bson_serialization_type: date + description: "A BSON UTC DateTime" + cpp_type: "mongo::Date_t" + deserializer: "mongo::BSONElement::date" + + timestamp: + bson_serialization_type: timestamp + description: "A BSON TimeStamp" + cpp_type: "mongo::Timestamp" + deserializer: "mongo::BSONElement::timestamp"
\ No newline at end of file diff --git a/src/mongo/idl/unittest.idl b/src/mongo/idl/unittest.idl index d0705b7d260..252d1ead736 100644 --- a/src/mongo/idl/unittest.idl +++ b/src/mongo/idl/unittest.idl @@ -20,67 +20,11 @@ global: - "mongo/db/namespace_string.h" - "mongo/idl/idl_test_types.h" -types: - string: - bson_serialization_type: string - description: "A BSON UTF-8 string" - cpp_type: "std::string" - deserializer: "mongo::BSONElement::str" - - int: - bson_serialization_type: int - description: "A BSON 32-bit integer" - cpp_type: "std::int32_t" - deserializer: "mongo::BSONElement::_numberInt" - - long: - bson_serialization_type: long - description: "A BSON 64-bit integer" - cpp_type: "std::int64_t" - deserializer: "mongo::BSONElement::_numberLong" - - double: - bson_serialization_type: double - description: "A BSON 64-bit floating point number" - cpp_type: "double" - deserializer: "mongo::BSONElement::_numberDouble" - - decimal: - bson_serialization_type: double - description: "A BSON 128-bit floating point decimal number" - cpp_type: "mongo::Decimal128" - deserializer: "mongo::BSONElement::_numberDecimal" - - bool: - bson_serialization_type: bool - description: "A BSON bool" - cpp_type: "bool" - deserializer: "mongo::BSONElement::boolean" - - # TODO: support bindata - # bindata: - # bson_serialization_type: bindata - # cpp_type: "std:" - # deserializer: "mongo::BSONElement::str" - - objectid: - bson_serialization_type: objectid - description: "A BSON ObjectID" - cpp_type: "mongo::OID" - deserializer: "mongo::BSONElement::OID" - - date: - bson_serialization_type: date - description: "A BSON UTC DateTime" - cpp_type: "mongo::Date_t" - deserializer: "mongo::BSONElement::date" - - timestamp: - bson_serialization_type: timestamp - description: "A BSON TimeStamp" - cpp_type: "mongo::Timestamp" - deserializer: "mongo::BSONElement::timestamp" +imports: + - "mongo/idl/basic_types.idl" + - "mongo/idl/unittest_import.idl" +types: ################################################################################################## # # Test a custom non-BSONElement deserialization and serialization methods for a string type @@ -137,57 +81,7 @@ types: deserializer: "mongo::BSONElement::numberInt" -################################################################################################## -# -# Unit test structs for a single value to ensure type validation works correctly -# -################################################################################################## - structs: - one_string: - description: UnitTest for a single string - fields: - value: string - - one_int: - description: UnitTest for a single int - fields: - value: int - - one_long: - description: UnitTest for a single long - fields: - value: long - - one_double: - description: UnitTest for a single double - fields: - value: double - - one_decimal: - description: UnitTest for a single decimal - fields: - value: decimal - - one_bool: - description: UnitTest for a single bool - fields: - value: bool - - one_objectid: - description: UnitTest for a single objectid - fields: - value: objectid - - one_date: - description: UnitTest for a single date - fields: - value: date - - one_timestamp: - description: UnitTest for a single timestamp - fields: - value: timestamp ################################################################################################## # diff --git a/src/mongo/idl/unittest_import.idl b/src/mongo/idl/unittest_import.idl new file mode 100644 index 00000000000..a2064766133 --- /dev/null +++ b/src/mongo/idl/unittest_import.idl @@ -0,0 +1,74 @@ +# Copyright (C) 2017 MongoDB Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License, version 3, +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# IDL Unit Tests IDL file for testing imported structs +global: + cpp_namespace: "mongo" + +imports: + - "mongo/idl/basic_types.idl" + + +################################################################################################## +# +# Unit test structs for a single value to ensure type validation works correctly +# +################################################################################################## + +structs: + one_string: + description: UnitTest for a single string + fields: + value: string + + one_int: + description: UnitTest for a single int + fields: + value: int + + one_long: + description: UnitTest for a single long + fields: + value: long + + one_double: + description: UnitTest for a single double + fields: + value: double + + one_decimal: + description: UnitTest for a single decimal + fields: + value: decimal + + one_bool: + description: UnitTest for a single bool + fields: + value: bool + + one_objectid: + description: UnitTest for a single objectid + fields: + value: objectid + + one_date: + description: UnitTest for a single date + fields: + value: date + + one_timestamp: + description: UnitTest for a single timestamp + fields: + value: timestamp
\ No newline at end of file |