summaryrefslogtreecommitdiff
path: root/buildscripts/idl/idl/binder.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts/idl/idl/binder.py')
-rw-r--r--buildscripts/idl/idl/binder.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/buildscripts/idl/idl/binder.py b/buildscripts/idl/idl/binder.py
index bec32eead89..c6f7ee5032c 100644
--- a/buildscripts/idl/idl/binder.py
+++ b/buildscripts/idl/idl/binder.py
@@ -21,6 +21,7 @@ from typing import Union
from . import ast
from . import bson
+from . import cpp_types
from . import errors
from . import syntax
@@ -121,6 +122,14 @@ def _validate_cpp_type(ctxt, idl_type, syntax_type):
if idl_type.cpp_type in ["std::int32_t", "std::int64_t", "std::uint32_t", "std::uint64_t"]:
return
+ # Only allow 16-byte arrays since they are for MD5 and UUID
+ if idl_type.cpp_type.replace(" ", "") == "std::array<std::uint8_t,16>":
+ return
+
+ # Support vector for variable length BinData.
+ if idl_type.cpp_type == "std::vector<std::uint8_t>":
+ return
+
# Check for std fixed integer types which are not allowed. These are not allowed even if they
# have the "std::" prefix.
for std_numeric_type in [
@@ -142,8 +151,9 @@ def _validate_type_properties(ctxt, idl_type, syntax_type):
if len(idl_type.bson_serialization_type) == 1:
bson_type = idl_type.bson_serialization_type[0]
+
if bson_type == "any":
- # For any, a deserialer is required but the user can try to get away with the default
+ # For any, a deserializer is required but the user can try to get away with the default
# serialization for their C++ type.
if idl_type.deserializer is None:
ctxt.add_missing_ast_required_field_error(idl_type, syntax_type, idl_type.name,
@@ -154,7 +164,7 @@ def _validate_type_properties(ctxt, idl_type, syntax_type):
ctxt.add_missing_ast_required_field_error(idl_type, syntax_type, idl_type.name,
"deserializer")
- elif not bson_type in ["object"]:
+ elif not bson_type in ["object", "bindata"]:
if idl_type.deserializer is None:
ctxt.add_missing_ast_required_field_error(idl_type, syntax_type, idl_type.name,
"deserializer")
@@ -166,6 +176,10 @@ def _validate_type_properties(ctxt, idl_type, syntax_type):
if idl_type.serializer is not None:
ctxt.add_not_custom_scalar_serialization_not_supported_error(
idl_type, syntax_type, idl_type.name, bson_type)
+
+ if bson_type == "bindata" and idl_type.default:
+ ctxt.add_bindata_no_default(idl_type, syntax_type, idl_type.name)
+
else:
# Now, this is a list of scalar types
if idl_type.deserializer is None: