2015-02-05 01:00:00 +03:00
|
|
|
#!/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
|
|
|
|
|
2015-08-23 09:42:07 +03:00
|
|
|
AUTOGENERATED_WARNING_COMMENT = "/* THIS FILE IS AUTOGENERATED BY gen-usecounters.py - DO NOT EDIT */"
|
2015-02-05 01:00:00 +03:00
|
|
|
|
|
|
|
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')
|
2017-08-08 17:01:27 +03:00
|
|
|
print_optional_macro_declare('USE_COUNTER_CUSTOM')
|
2015-02-05 01:00:00 +03:00
|
|
|
|
|
|
|
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']
|
2015-06-03 22:21:24 +03:00
|
|
|
print('USE_COUNTER_CSS_PROPERTY(%s, %s)' % (prop, prop), file=f)
|
2017-08-08 17:01:27 +03:00
|
|
|
elif counter['type'] == 'custom':
|
|
|
|
desc = counter['desc'].replace('\\', r'\\').replace('"', r'\"')
|
|
|
|
print('USE_COUNTER_CUSTOM(%s, "%s")' % (counter['name'], desc), file=f)
|
2015-02-05 01:00:00 +03:00
|
|
|
|
|
|
|
print_optional_macro_undeclare('USE_COUNTER_DOM_METHOD')
|
|
|
|
print_optional_macro_undeclare('USE_COUNTER_DOM_ATTRIBUTE')
|
|
|
|
print_optional_macro_undeclare('USE_COUNTER_CSS_PROPERTY')
|
2017-08-08 17:01:27 +03:00
|
|
|
print_optional_macro_undeclare('USE_COUNTER_CUSTOM')
|
2015-02-05 01:00:00 +03:00
|
|
|
|
|
|
|
def generate_property_map(f, counters):
|
|
|
|
print(AUTOGENERATED_WARNING_COMMENT, file=f)
|
|
|
|
print('''
|
|
|
|
enum {
|
2015-06-03 22:21:24 +03:00
|
|
|
#define CSS_PROP_PUBLIC_OR_PRIVATE(publicname_, privatename_) privatename_
|
2015-02-05 01:00:00 +03:00
|
|
|
#define CSS_PROP_LIST_INCLUDE_LOGICAL
|
2018-03-27 01:54:20 +03:00
|
|
|
#define CSS_PROP(name_, id_, method_, ...) \\
|
2015-06-03 22:21:24 +03:00
|
|
|
USE_COUNTER_FOR_CSS_PROPERTY_##method_ = eUseCounter_UNKNOWN,
|
2015-02-05 01:00:00 +03:00
|
|
|
#include "nsCSSPropList.h"
|
|
|
|
#undef CSS_PROP
|
|
|
|
#undef CSS_PROP_LIST_INCLUDE_LOGICAL
|
2015-06-03 22:21:24 +03:00
|
|
|
#undef CSS_PROP_PUBLIC_OR_PRIVATE
|
2015-02-05 01:00:00 +03:00
|
|
|
};
|
|
|
|
''', file=f)
|
|
|
|
for counter in counters:
|
|
|
|
if counter['type'] == 'property':
|
2015-06-03 22:21:24 +03:00
|
|
|
prop = counter['property_name']
|
2015-02-05 01:00:00 +03:00
|
|
|
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)
|