summaryrefslogtreecommitdiffstats
path: root/dom/base/gen-usecounters.py
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/base/gen-usecounters.py
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/gen-usecounters.py')
-rwxr-xr-xdom/base/gen-usecounters.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/dom/base/gen-usecounters.py b/dom/base/gen-usecounters.py
new file mode 100755
index 000000000..5b17c22e4
--- /dev/null
+++ b/dom/base/gen-usecounters.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import print_function
+
+import json
+import os
+import sys
+sys.path.append(os.path.dirname(__file__))
+
+import usecounters
+
+AUTOGENERATED_WARNING_COMMENT = "/* THIS FILE IS AUTOGENERATED BY gen-usecounters.py - DO NOT EDIT */"
+
+def generate_list(f, counters):
+ def print_optional_macro_declare(name):
+ print('''
+#ifndef %(name)s
+#define %(name)s(interface_, name_) // nothing
+#define DEFINED_%(name)s
+#endif
+''' % { 'name': name }, file=f)
+
+ def print_optional_macro_undeclare(name):
+ print('''
+#ifdef DEFINED_%(name)s
+#undef DEFINED_%(name)s
+#undef %(name)s
+#endif
+''' % { 'name': name }, file=f)
+
+ print(AUTOGENERATED_WARNING_COMMENT, file=f)
+
+ print_optional_macro_declare('USE_COUNTER_DOM_METHOD')
+ print_optional_macro_declare('USE_COUNTER_DOM_ATTRIBUTE')
+ print_optional_macro_declare('USE_COUNTER_CSS_PROPERTY')
+
+ for counter in counters:
+ if counter['type'] == 'method':
+ print('USE_COUNTER_DOM_METHOD(%s, %s)' % (counter['interface_name'], counter['method_name']), file=f)
+ elif counter['type'] == 'attribute':
+ print('USE_COUNTER_DOM_ATTRIBUTE(%s, %s)' % (counter['interface_name'], counter['attribute_name']), file=f)
+ elif counter['type'] == 'property':
+ prop = counter['property_name']
+ print('USE_COUNTER_CSS_PROPERTY(%s, %s)' % (prop, prop), file=f)
+
+ print_optional_macro_undeclare('USE_COUNTER_DOM_METHOD')
+ print_optional_macro_undeclare('USE_COUNTER_DOM_ATTRIBUTE')
+ print_optional_macro_undeclare('USE_COUNTER_CSS_PROPERTY')
+
+def generate_property_map(f, counters):
+ print(AUTOGENERATED_WARNING_COMMENT, file=f)
+ print('''
+enum {
+ #define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) privatename_
+ #define CSS_PROP_LIST_INCLUDE_LOGICAL
+ #define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \\
+ kwtable_, stylestruct_, stylestructoffset_, animtype_) \\
+ USE_COUNTER_FOR_CSS_PROPERTY_##method_ = eUseCounter_UNKNOWN,
+ #include "nsCSSPropList.h"
+ #undef CSS_PROP
+ #undef CSS_PROP_LIST_INCLUDE_LOGICAL
+ #undef CSS_PROP_PUBLIC_OR_PRIVATE
+};
+''', file=f)
+ for counter in counters:
+ if counter['type'] == 'property':
+ prop = counter['property_name']
+ print('#define USE_COUNTER_FOR_CSS_PROPERTY_%s eUseCounter_property_%s' % (prop, prop), file=f)
+
+def use_counter_list(output_header, conf_filename):
+ counters = usecounters.read_conf(conf_filename)
+ generate_list(output_header, counters)
+
+def property_map(output_map, conf_filename):
+ counters = usecounters.read_conf(conf_filename)
+ generate_property_map(output_map, counters)