OLD | NEW |
1 # Copyright (c) 2013 Google Inc. All rights reserved. | 1 # Copyright (c) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 const char InspectorBackendDispatcher::commandNames[] = { | 224 const char InspectorBackendDispatcher::commandNames[] = { |
225 $methodNameDeclarations | 225 $methodNameDeclarations |
226 }; | 226 }; |
227 | 227 |
228 const size_t InspectorBackendDispatcher::commandNamesIndex[] = { | 228 const size_t InspectorBackendDispatcher::commandNamesIndex[] = { |
229 $methodNameDeclarationsIndex | 229 $methodNameDeclarationsIndex |
230 }; | 230 }; |
231 | 231 |
232 const char* InspectorBackendDispatcher::commandName(MethodNames index) { | 232 const char* InspectorBackendDispatcher::commandName(MethodNames index) { |
233 COMPILE_ASSERT(static_cast<int>(kMethodNamesEnumSize) == WTF_ARRAY_LENGTH(co
mmandNamesIndex), command_name_array_problem); | 233 static_assert(static_cast<int>(kMethodNamesEnumSize) == WTF_ARRAY_LENGTH(com
mandNamesIndex), "MethodNames enum should have the same number of elements as co
mmandNamesIndex"); |
234 return commandNames + commandNamesIndex[index]; | 234 return commandNames + commandNamesIndex[index]; |
235 } | 235 } |
236 | 236 |
237 class InspectorBackendDispatcherImpl : public InspectorBackendDispatcher { | 237 class InspectorBackendDispatcherImpl : public InspectorBackendDispatcher { |
238 public: | 238 public: |
239 InspectorBackendDispatcherImpl(InspectorFrontendChannel* inspectorFrontendCh
annel) | 239 InspectorBackendDispatcherImpl(InspectorFrontendChannel* inspectorFrontendCh
annel) |
240 : m_inspectorFrontendChannel(inspectorFrontendChannel) | 240 : m_inspectorFrontendChannel(inspectorFrontendChannel) |
241 $constructorInit | 241 $constructorInit |
242 { } | 242 { } |
243 | 243 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 struct ArrayItemHelper { | 604 struct ArrayItemHelper { |
605 typedef typename T::ItemTraits Traits; | 605 typedef typename T::ItemTraits Traits; |
606 }; | 606 }; |
607 | 607 |
608 template<typename T> | 608 template<typename T> |
609 class Array : public JSONArrayBase { | 609 class Array : public JSONArrayBase { |
610 private: | 610 private: |
611 Array() { } | 611 Array() { } |
612 | 612 |
613 JSONArray* openAccessors() { | 613 JSONArray* openAccessors() { |
614 COMPILE_ASSERT(sizeof(JSONArray) == sizeof(Array<T>), cannot_cast); | 614 static_assert(sizeof(JSONArray) == sizeof(Array<T>), "JSONArray should b
e the same size as Array<T>"); |
615 return static_cast<JSONArray*>(static_cast<JSONArrayBase*>(this)); | 615 return static_cast<JSONArray*>(static_cast<JSONArrayBase*>(this)); |
616 } | 616 } |
617 | 617 |
618 public: | 618 public: |
619 void addItem(PassRefPtr<T> value) | 619 void addItem(PassRefPtr<T> value) |
620 { | 620 { |
621 ArrayItemHelper<T>::Traits::pushRefPtr(this->openAccessors(), value); | 621 ArrayItemHelper<T>::Traits::pushRefPtr(this->openAccessors(), value); |
622 } | 622 } |
623 | 623 |
624 void addItem(T value) | 624 void addItem(T value) |
625 { | 625 { |
626 ArrayItemHelper<T>::Traits::pushRaw(this->openAccessors(), value); | 626 ArrayItemHelper<T>::Traits::pushRaw(this->openAccessors(), value); |
627 } | 627 } |
628 | 628 |
629 static PassRefPtr<Array<T> > create() | 629 static PassRefPtr<Array<T> > create() |
630 { | 630 { |
631 return adoptRef(new Array<T>()); | 631 return adoptRef(new Array<T>()); |
632 } | 632 } |
633 | 633 |
634 static PassRefPtr<Array<T> > runtimeCast(PassRefPtr<JSONValue> value) | 634 static PassRefPtr<Array<T> > runtimeCast(PassRefPtr<JSONValue> value) |
635 { | 635 { |
636 RefPtr<JSONArray> array; | 636 RefPtr<JSONArray> array; |
637 bool castRes = value->asArray(&array); | 637 bool castRes = value->asArray(&array); |
638 ASSERT_UNUSED(castRes, castRes); | 638 ASSERT_UNUSED(castRes, castRes); |
639 #if $validatorIfdefName | 639 #if $validatorIfdefName |
640 assertCorrectValue(array.get()); | 640 assertCorrectValue(array.get()); |
641 #endif // $validatorIfdefName | 641 #endif // $validatorIfdefName |
642 COMPILE_ASSERT(sizeof(Array<T>) == sizeof(JSONArray), type_cast_problem)
; | 642 static_assert(sizeof(Array<T>) == sizeof(JSONArray), "Array<T> should be
the same size as JSONArray"); |
643 return static_cast<Array<T>*>(static_cast<JSONArrayBase*>(array.get())); | 643 return static_cast<Array<T>*>(static_cast<JSONArrayBase*>(array.get())); |
644 } | 644 } |
645 | 645 |
646 void concat(PassRefPtr<Array<T> > array) | 646 void concat(PassRefPtr<Array<T> > array) |
647 { | 647 { |
648 return ArrayItemHelper<T>::Traits::concat(this->openAccessors(), array->
openAccessors()); | 648 return ArrayItemHelper<T>::Traits::concat(this->openAccessors(), array->
openAccessors()); |
649 } | 649 } |
650 | 650 |
651 #if $validatorIfdefName | 651 #if $validatorIfdefName |
652 static void assertCorrectValue(JSONValue* value) | 652 static void assertCorrectValue(JSONValue* value) |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 private: | 892 private: |
893 RefPtr<JSONObject> m_result; | 893 RefPtr<JSONObject> m_result; |
894 | 894 |
895 template<int STEP> Builder<STATE | STEP>& castState() | 895 template<int STEP> Builder<STATE | STEP>& castState() |
896 { | 896 { |
897 return *reinterpret_cast<Builder<STATE | STEP>*>(this); | 897 return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
898 } | 898 } |
899 | 899 |
900 Builder(PassRefPtr</*%s*/JSONObject> ptr) | 900 Builder(PassRefPtr</*%s*/JSONObject> ptr) |
901 { | 901 { |
902 COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_sta
te); | 902 static_assert(STATE == NoFieldsSet, "builder should not be created i
n non-init state"); |
903 m_result = ptr; | 903 m_result = ptr; |
904 } | 904 } |
905 friend class %s; | 905 friend class %s; |
906 public: | 906 public: |
907 """) | 907 """) |
908 | 908 |
909 class_binding_builder_part_2 = (""" | 909 class_binding_builder_part_2 = (""" |
910 Builder<STATE | %s>& set%s(%s value) | 910 Builder<STATE | %s>& set%s(%s value) |
911 { | 911 { |
912 COMPILE_ASSERT(!(STATE & %s), property_%s_already_set); | 912 static_assert(!(STATE & %s), "property %s should not be set yet"); |
913 m_result->set%s("%s", %s); | 913 m_result->set%s("%s", %s); |
914 return castState<%s>(); | 914 return castState<%s>(); |
915 } | 915 } |
916 """) | 916 """) |
917 | 917 |
918 class_binding_builder_part_3 = (""" | 918 class_binding_builder_part_3 = (""" |
919 operator RefPtr<%s>& () | 919 operator RefPtr<%s>& () |
920 { | 920 { |
921 COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); | 921 static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet")
; |
922 COMPILE_ASSERT(sizeof(%s) == sizeof(JSONObject), cannot_cast); | 922 static_assert(sizeof(%s) == sizeof(JSONObject), "%s should be the sa
me size as JSONObject"); |
923 return *reinterpret_cast<RefPtr<%s>*>(&m_result); | 923 return *reinterpret_cast<RefPtr<%s>*>(&m_result); |
924 } | 924 } |
925 | 925 |
926 PassRefPtr<%s> release() | 926 PassRefPtr<%s> release() |
927 { | 927 { |
928 return RefPtr<%s>(*this).release(); | 928 return RefPtr<%s>(*this).release(); |
929 } | 929 } |
930 }; | 930 }; |
931 | 931 |
932 """) | 932 """) |
933 | 933 |
934 class_binding_builder_part_4 = ( | 934 class_binding_builder_part_4 = ( |
935 """ static Builder<NoFieldsSet> create() | 935 """ static Builder<NoFieldsSet> create() |
936 { | 936 { |
937 return Builder<NoFieldsSet>(JSONObject::create()); | 937 return Builder<NoFieldsSet>(JSONObject::create()); |
938 } | 938 } |
939 """) | 939 """) |
OLD | NEW |