summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/inspector/CodeGeneratorInspector.py
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/inspector/CodeGeneratorInspector.py')
-rwxr-xr-xSource/WebCore/inspector/CodeGeneratorInspector.py54
1 files changed, 48 insertions, 6 deletions
diff --git a/Source/WebCore/inspector/CodeGeneratorInspector.py b/Source/WebCore/inspector/CodeGeneratorInspector.py
index ddae7a290..e9d373b01 100755
--- a/Source/WebCore/inspector/CodeGeneratorInspector.py
+++ b/Source/WebCore/inspector/CodeGeneratorInspector.py
@@ -67,6 +67,8 @@ TYPES_WITH_OPEN_FIELD_LIST_SET = frozenset(["Timeline.TimelineEvent",
# InspectorResourceAgent needs to update mime-type.
"Network.Response"])
+EXACTLY_INT_SUPPORTED = False
+
cmdline_parser = optparse.OptionParser()
cmdline_parser.add_option("--output_h_dir")
cmdline_parser.add_option("--output_cpp_dir")
@@ -622,7 +624,7 @@ class CommandReturnPassModel:
class TypeModel:
- class RefPtrBased:
+ class RefPtrBased(object):
def __init__(self, class_name):
self.class_name = class_name
self.optional = False
@@ -646,7 +648,7 @@ class TypeModel:
def get_event_setter_expression_pattern():
return "%s"
- class Enum:
+ class Enum(object):
def __init__(self, base_type_name):
self.type_name = base_type_name + "::Enum"
@@ -679,7 +681,7 @@ class TypeModel:
def get_event_setter_expression_pattern():
return "%s"
- class ValueType:
+ class ValueType(object):
def __init__(self, type_name, is_heavy):
self.type_name = type_name
self.is_heavy = is_heavy
@@ -696,6 +698,9 @@ class TypeModel:
else:
return self.type_name
+ def get_opt_output_type_(self):
+ return self.type_name
+
@staticmethod
def get_event_setter_expression_pattern():
return "%s"
@@ -708,7 +713,7 @@ class TypeModel:
return self
def get_command_return_pass_model(self):
- return CommandReturnPassModel.OptOutput(self.base.type_name)
+ return CommandReturnPassModel.OptOutput(self.base.get_opt_output_type_())
def get_input_param_type_text(self):
return "const %s* const" % self.base.type_name
@@ -717,12 +722,25 @@ class TypeModel:
def get_event_setter_expression_pattern():
return "*%s"
+ class ExactlyInt(ValueType):
+ def __init__(self):
+ TypeModel.ValueType.__init__(self, "int", False)
+
+ def get_input_param_type_text(self):
+ return "TypeBuilder::ExactlyInt"
+
+ def get_opt_output_type_(self):
+ return "TypeBuilder::ExactlyInt"
+
@classmethod
def init_class(cls):
cls.Bool = cls.ValueType("bool", False)
- cls.Int = cls.ValueType("int", False)
+ if EXACTLY_INT_SUPPORTED:
+ cls.Int = cls.ExactlyInt()
+ else:
+ cls.Int = cls.ValueType("int", False)
cls.Number = cls.ValueType("double", False)
- cls.String = cls.ValueType("String", True)
+ cls.String = cls.ValueType("String", True,)
cls.Object = cls.RefPtrBased("InspectorObject")
cls.Array = cls.RefPtrBased("InspectorArray")
cls.Any = cls.RefPtrBased("InspectorValue")
@@ -2224,6 +2242,30 @@ private:
};
+// A small transient wrapper around int type, that can be used as a funciton parameter type
+// cleverly disallowing C++ implicit casts from float or double.
+class ExactlyInt {
+public:
+ template<typename T>
+ ExactlyInt(T t) : m_value(cast_to_int<T>(t)) {}
+
+ ExactlyInt() {}
+
+ operator int() { return m_value; }
+private:
+ int m_value;
+
+ template<typename T>
+ static int cast_to_int(T) { return T::default_case_cast_is_not_supported(); }
+};
+
+template<>
+inline int ExactlyInt::cast_to_int<int>(int i) { return i; }
+
+template<>
+inline int ExactlyInt::cast_to_int<unsigned int>(unsigned int i) { return i; }
+
+
// This class provides "Traits" type for the input type T. It is programmed using C++ template specialization
// technique. By default it simply takes "ItemTraits" type from T, but it doesn't work with the base types.
template<typename T>