Roll third_party/inspector_protocol to 59ca26e
This roll includes: - [inspector_protocol] first class citizien .pdl support - [inspector_protocol] node uses script names inside own repository + removed .json file R=pfeldman@chromium.org,yangguo@chromium.org Bug: none Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel Change-Id: Idd87e80a3ce42198858ade4bcf6e6fec4b2f0731 Reviewed-on: https://chromium-review.googlesource.com/804635 Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> Reviewed-by: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> Reviewed-by: Pavel Feldman <pfeldman@chromium.org> Cr-Commit-Position: refs/heads/master@{#52734}
This commit is contained in:
parent
5728b3fbc5
commit
bd7f5cf0ab
@ -75,7 +75,7 @@ if (v8_enable_backtrace == "") {
|
||||
# subdirectories.
|
||||
v8_path_prefix = get_path_info("../", "abspath")
|
||||
|
||||
v8_inspector_js_protocol = v8_path_prefix + "/src/inspector/js_protocol.json"
|
||||
v8_inspector_js_protocol = v8_path_prefix + "/src/inspector/js_protocol.pdl"
|
||||
|
||||
###############################################################################
|
||||
# Templates
|
||||
|
@ -30,9 +30,9 @@ _protocol_generated = [
|
||||
|
||||
action("protocol_compatibility") {
|
||||
visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
script = "$_inspector_protocol/CheckProtocolCompatibility.py"
|
||||
script = "$_inspector_protocol/check_protocol_compatibility.py"
|
||||
inputs = [
|
||||
"js_protocol.json",
|
||||
"js_protocol.pdl",
|
||||
]
|
||||
_stamp = "$target_gen_dir/js_protocol.stamp"
|
||||
outputs = [
|
||||
@ -41,7 +41,7 @@ action("protocol_compatibility") {
|
||||
args = [
|
||||
"--stamp",
|
||||
rebase_path(_stamp, root_build_dir),
|
||||
rebase_path("js_protocol.json", root_build_dir),
|
||||
rebase_path("js_protocol.pdl", root_build_dir),
|
||||
]
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ inspector_protocol_generate("protocol_generated_sources") {
|
||||
out_dir = target_gen_dir
|
||||
config_file = "inspector_protocol_config.json"
|
||||
inputs = [
|
||||
"js_protocol.json",
|
||||
"js_protocol.pdl",
|
||||
"inspector_protocol_config.json",
|
||||
]
|
||||
outputs = _protocol_generated
|
||||
|
@ -9,9 +9,6 @@ yangguo@chromium.org
|
||||
|
||||
# Changes to remote debugging protocol require devtools review to
|
||||
# ensure backwards compatibility and commitment to maintain.
|
||||
per-file js_protocol.json=set noparent
|
||||
per-file js_protocol.json=dgozman@chromium.org
|
||||
per-file js_protocol.json=pfeldman@chromium.org
|
||||
per-file js_protocol.pdl=set noparent
|
||||
per-file js_protocol.pdl=dgozman@chromium.org
|
||||
per-file js_protocol.pdl=pfeldman@chromium.org
|
||||
|
@ -17,8 +17,8 @@ def _CompileScripts(input_api, output_api):
|
||||
local_paths = [f.LocalPath() for f in input_api.AffectedFiles()]
|
||||
|
||||
compilation_related_files = [
|
||||
"js_protocol.json"
|
||||
"compile-scripts.js",
|
||||
"js_protocol.pdl"
|
||||
"compile-scripts.py",
|
||||
"injected-script-source.js",
|
||||
"injected_script_externs.js",
|
||||
"check_injected_script_source.js"
|
||||
|
@ -27,7 +27,7 @@ injected_script_externs_file = path.join(v8_inspector_path,
|
||||
'injected_script_externs.js')
|
||||
|
||||
generate_protocol_externs.generate_protocol_externs(protocol_externs_file,
|
||||
path.join(v8_inspector_path, 'js_protocol.json'))
|
||||
path.join(v8_inspector_path, 'js_protocol.pdl'))
|
||||
|
||||
error_warning_regex = re.compile(r'WARNING|ERROR')
|
||||
|
||||
|
@ -28,8 +28,17 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import os
|
||||
import os.path as path
|
||||
import re
|
||||
import json
|
||||
import sys
|
||||
|
||||
sys.path.append(
|
||||
path.normpath(
|
||||
path.join(
|
||||
path.dirname(path.abspath(__file__)),
|
||||
os.pardir, os.pardir, os.pardir, 'third_party', 'inspector_protocol')))
|
||||
import pdl # pylint: disable=F0401
|
||||
|
||||
type_traits = {
|
||||
"any": "*",
|
||||
@ -96,8 +105,7 @@ def param_type(domain_name, param):
|
||||
|
||||
def load_schema(file, domains):
|
||||
input_file = open(file, "r")
|
||||
json_string = input_file.read()
|
||||
parsed_json = json.loads(json_string)
|
||||
parsed_json = pdl.loads(input_file.read(), file)
|
||||
domains.extend(parsed_json["domains"])
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"protocol": {
|
||||
"path": "js_protocol.json",
|
||||
"path": "js_protocol.pdl",
|
||||
"package": "src/inspector/protocol",
|
||||
"output": "protocol",
|
||||
"namespace": ["v8_inspector", "protocol"],
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,183 +1,9 @@
|
||||
# Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
# Copyright 2018 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import collections
|
||||
import json
|
||||
import os.path
|
||||
import re
|
||||
import sys
|
||||
|
||||
file_name = None
|
||||
description = ''
|
||||
|
||||
primitiveTypes = ['integer', 'number', 'boolean', 'string', 'object', 'any', 'array']
|
||||
import convert_to_protocol_json
|
||||
|
||||
|
||||
def assignType(item, type, isArray=False):
|
||||
if isArray:
|
||||
item['type'] = 'array'
|
||||
item['items'] = collections.OrderedDict()
|
||||
assignType(item['items'], type)
|
||||
return
|
||||
|
||||
if type == 'enum':
|
||||
type = 'string'
|
||||
if type in primitiveTypes:
|
||||
item['type'] = type
|
||||
else:
|
||||
item['$ref'] = type
|
||||
|
||||
|
||||
def createItem(d, experimental, deprecated, name=None):
|
||||
result = collections.OrderedDict(d)
|
||||
if name:
|
||||
result['name'] = name
|
||||
global description
|
||||
if description:
|
||||
result['description'] = description.strip()
|
||||
if experimental:
|
||||
result['experimental'] = True
|
||||
if deprecated:
|
||||
result['deprecated'] = True
|
||||
return result
|
||||
|
||||
|
||||
def parse(data):
|
||||
protocol = collections.OrderedDict()
|
||||
protocol['version'] = collections.OrderedDict()
|
||||
protocol['domains'] = []
|
||||
domain = None
|
||||
item = None
|
||||
subitems = None
|
||||
nukeDescription = False
|
||||
global description
|
||||
lines = data.split('\n')
|
||||
for i in range(0, len(lines)):
|
||||
if nukeDescription:
|
||||
description = ''
|
||||
nukeDescription = False
|
||||
line = lines[i]
|
||||
trimLine = line.strip()
|
||||
|
||||
if trimLine.startswith('#'):
|
||||
if len(description):
|
||||
description += '\n'
|
||||
description += trimLine[2:]
|
||||
continue
|
||||
else:
|
||||
nukeDescription = True
|
||||
|
||||
if len(trimLine) == 0:
|
||||
continue
|
||||
|
||||
match = re.compile('^(experimental )?(deprecated )?domain (.*)').match(line)
|
||||
if match:
|
||||
domain = createItem({'domain' : match.group(3)}, match.group(1), match.group(2))
|
||||
protocol['domains'].append(domain)
|
||||
continue
|
||||
|
||||
match = re.compile('^ depends on ([^\s]+)').match(line)
|
||||
if match:
|
||||
if 'dependencies' not in domain:
|
||||
domain['dependencies'] = []
|
||||
domain['dependencies'].append(match.group(1))
|
||||
continue
|
||||
|
||||
match = re.compile('^ (experimental )?(deprecated )?type (.*) extends (array of )?([^\s]+)').match(line)
|
||||
if match:
|
||||
if 'types' not in domain:
|
||||
domain['types'] = []
|
||||
item = createItem({'id': match.group(3)}, match.group(1), match.group(2))
|
||||
assignType(item, match.group(5), match.group(4))
|
||||
domain['types'].append(item)
|
||||
continue
|
||||
|
||||
match = re.compile('^ (experimental )?(deprecated )?(command|event) (.*)').match(line)
|
||||
if match:
|
||||
list = []
|
||||
if match.group(3) == 'command':
|
||||
if 'commands' in domain:
|
||||
list = domain['commands']
|
||||
else:
|
||||
list = domain['commands'] = []
|
||||
else:
|
||||
if 'events' in domain:
|
||||
list = domain['events']
|
||||
else:
|
||||
list = domain['events'] = []
|
||||
|
||||
item = createItem({}, match.group(1), match.group(2), match.group(4))
|
||||
list.append(item)
|
||||
continue
|
||||
|
||||
match = re.compile('^ (experimental )?(deprecated )?(optional )?(array of )?([^\s]+) ([^\s]+)').match(line)
|
||||
if match:
|
||||
param = createItem({}, match.group(1), match.group(2), match.group(6))
|
||||
if match.group(3):
|
||||
param['optional'] = True
|
||||
assignType(param, match.group(5), match.group(4))
|
||||
if match.group(5) == 'enum':
|
||||
enumliterals = param['enum'] = []
|
||||
subitems.append(param)
|
||||
continue
|
||||
|
||||
match = re.compile('^ (parameters|returns|properties)').match(line)
|
||||
if match:
|
||||
subitems = item[match.group(1)] = []
|
||||
continue
|
||||
|
||||
match = re.compile('^ enum').match(line)
|
||||
if match:
|
||||
enumliterals = item['enum'] = []
|
||||
continue
|
||||
|
||||
match = re.compile('^version').match(line)
|
||||
if match:
|
||||
continue
|
||||
|
||||
match = re.compile('^ major (\d+)').match(line)
|
||||
if match:
|
||||
protocol['version']['major'] = match.group(1)
|
||||
continue
|
||||
|
||||
match = re.compile('^ minor (\d+)').match(line)
|
||||
if match:
|
||||
protocol['version']['minor'] = match.group(1)
|
||||
continue
|
||||
|
||||
match = re.compile('^ redirect ([^\s]+)').match(line)
|
||||
if match:
|
||||
item['redirect'] = match.group(1)
|
||||
continue
|
||||
|
||||
match = re.compile('^ ( )?[^\s]+$').match(line)
|
||||
if match:
|
||||
# enum literal
|
||||
enumliterals.append(trimLine)
|
||||
continue
|
||||
|
||||
print 'Error in %s:%s, illegal token: \t%s' % (file_name, i, line)
|
||||
sys.exit(1)
|
||||
return protocol
|
||||
|
||||
def main(argv):
|
||||
if len(argv) < 2:
|
||||
sys.stderr.write("Usage: %s <protocol.pdl> <protocol.json>\n" % sys.argv[0])
|
||||
return 1
|
||||
global file_name
|
||||
file_name = os.path.normpath(argv[0])
|
||||
input_file = open(file_name, "r")
|
||||
pdl_string = input_file.read()
|
||||
protocol = parse(pdl_string)
|
||||
output_file = open(argv[0].replace('.pdl', '.json'), 'wb')
|
||||
json.dump(protocol, output_file, indent=4, separators=(',', ': '))
|
||||
output_file.close()
|
||||
|
||||
output_file = open(os.path.normpath(argv[1]), 'wb')
|
||||
json.dump(protocol, output_file, indent=4, separators=(',', ': '))
|
||||
output_file.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
def main():
|
||||
convert_protocol_to_json.main()
|
||||
|
2
third_party/inspector_protocol/README.v8
vendored
2
third_party/inspector_protocol/README.v8
vendored
@ -2,7 +2,7 @@ Name: inspector protocol
|
||||
Short Name: inspector_protocol
|
||||
URL: https://chromium.googlesource.com/deps/inspector_protocol/
|
||||
Version: 0
|
||||
Revision: 752d4abd13119010cf30e454e8ef9b5fb7ef43a3
|
||||
Revision: dd90116bd5b9b49678b70954ccf615b21af472a8
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
Security Critical: no
|
||||
|
@ -50,6 +50,8 @@ import os.path
|
||||
import optparse
|
||||
import sys
|
||||
|
||||
import pdl
|
||||
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
@ -228,8 +230,8 @@ def load_schema(file_name, domains):
|
||||
if not os.path.isfile(file_name):
|
||||
return
|
||||
input_file = open(file_name, "r")
|
||||
json_string = input_file.read()
|
||||
parsed_json = json.loads(json_string)
|
||||
parsed_json = pdl.loads(input_file.read(), file_name)
|
||||
input_file.close()
|
||||
domains += parsed_json["domains"]
|
||||
return parsed_json["version"]
|
||||
|
||||
@ -422,6 +424,7 @@ def load_domains_and_baselines(file_name, domains, baseline_domains):
|
||||
version = load_schema(os.path.normpath(file_name), domains)
|
||||
suffix = "-%s.%s.json" % (version["major"], version["minor"])
|
||||
baseline_file = file_name.replace(".json", suffix)
|
||||
baseline_file = file_name.replace(".pdl", suffix)
|
||||
load_schema(os.path.normpath(baseline_file), baseline_domains)
|
||||
return version
|
||||
|
@ -14,6 +14,8 @@ try:
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
import pdl
|
||||
|
||||
# Path handling for libraries and templates
|
||||
# Paths have to be normalized because Jinja uses the exact template path to
|
||||
# determine the hash used in the cache filename, and we need a pre-caching step
|
||||
@ -95,6 +97,7 @@ def read_config():
|
||||
".protocol.export_macro": "",
|
||||
".protocol.export_header": False,
|
||||
".protocol.options": False,
|
||||
".protocol.file_name_prefix": "",
|
||||
".exported": False,
|
||||
".exported.export_macro": "",
|
||||
".exported.export_header": False,
|
||||
@ -156,6 +159,10 @@ def format_include(config, header, file_name=None):
|
||||
return header
|
||||
|
||||
|
||||
def format_domain_include(config, header, file_name):
|
||||
return format_include(config, header, config.protocol.file_name_prefix + file_name)
|
||||
|
||||
|
||||
def to_file_name(config, file_name):
|
||||
if config.use_snake_file_names:
|
||||
return to_snake_case(file_name).replace(".cpp", ".cc")
|
||||
@ -330,9 +337,8 @@ class Protocol(object):
|
||||
|
||||
def read_protocol_file(self, file_name):
|
||||
input_file = open(file_name, "r")
|
||||
json_string = input_file.read()
|
||||
parsed_json = pdl.loads(input_file.read(), file_name)
|
||||
input_file.close()
|
||||
parsed_json = json.loads(json_string)
|
||||
version = parsed_json["version"]["major"] + "." + parsed_json["version"]["minor"]
|
||||
domains = []
|
||||
for domain in parsed_json["domains"]:
|
||||
@ -571,21 +577,23 @@ def main():
|
||||
|
||||
for domain in protocol.json_api["domains"]:
|
||||
class_name = domain["domain"]
|
||||
file_name = config.protocol.file_name_prefix + class_name
|
||||
template_context = {
|
||||
"protocol": protocol,
|
||||
"config": config,
|
||||
"domain": domain,
|
||||
"join_arrays": join_arrays,
|
||||
"format_include": functools.partial(format_include, config),
|
||||
"format_domain_include": functools.partial(format_domain_include, config),
|
||||
}
|
||||
|
||||
if domain["domain"] in protocol.generate_domains:
|
||||
outputs[os.path.join(config.protocol.output, to_file_name(config, class_name + ".h"))] = h_template.render(template_context)
|
||||
outputs[os.path.join(config.protocol.output, to_file_name(config, class_name + ".cpp"))] = cpp_template.render(template_context)
|
||||
outputs[os.path.join(config.protocol.output, to_file_name(config, file_name + ".h"))] = h_template.render(template_context)
|
||||
outputs[os.path.join(config.protocol.output, to_file_name(config, file_name + ".cpp"))] = cpp_template.render(template_context)
|
||||
if domain["domain"] in protocol.exported_domains:
|
||||
outputs[os.path.join(config.exported.output, to_file_name(config, class_name + ".h"))] = exported_template.render(template_context)
|
||||
outputs[os.path.join(config.exported.output, to_file_name(config, file_name + ".h"))] = exported_template.render(template_context)
|
||||
if domain["domain"] in protocol.imported_domains:
|
||||
outputs[os.path.join(config.protocol.output, to_file_name(config, class_name + ".h"))] = imported_template.render(template_context)
|
||||
outputs[os.path.join(config.protocol.output, to_file_name(config, file_name + ".h"))] = imported_template.render(template_context)
|
||||
|
||||
if config.lib:
|
||||
template_context = {
|
@ -11,6 +11,7 @@ try:
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
import pdl
|
||||
|
||||
def main(argv):
|
||||
if len(argv) < 1:
|
||||
@ -25,8 +26,7 @@ def main(argv):
|
||||
sys.stderr.write("Cannot find %s\n" % file_name)
|
||||
return 1
|
||||
input_file = open(file_name, "r")
|
||||
json_string = input_file.read()
|
||||
parsed_json = json.loads(json_string)
|
||||
parsed_json = pdl.loads(input_file.read(), file_name)
|
||||
domains += parsed_json["domains"]
|
||||
version = parsed_json["version"]
|
||||
|
32
third_party/inspector_protocol/convert_protocol_to_json.py
vendored
Executable file
32
third_party/inspector_protocol/convert_protocol_to_json.py
vendored
Executable file
@ -0,0 +1,32 @@
|
||||
# Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import collections
|
||||
import json
|
||||
import os.path
|
||||
import re
|
||||
import sys
|
||||
|
||||
import pdl
|
||||
|
||||
def main(argv):
|
||||
if len(argv) < 2:
|
||||
sys.stderr.write("Usage: %s <protocol.pdl> <protocol.json>\n" % sys.argv[0])
|
||||
return 1
|
||||
file_name = os.path.normpath(argv[0])
|
||||
input_file = open(file_name, "r")
|
||||
pdl_string = input_file.read()
|
||||
protocol = pdl.loads(pdl_string, file_name)
|
||||
input_file.close()
|
||||
output_file = open(argv[0].replace('.pdl', '.json'), 'wb')
|
||||
json.dump(protocol, output_file, indent=4, separators=(',', ': '))
|
||||
output_file.close()
|
||||
|
||||
output_file = open(os.path.normpath(argv[1]), 'wb')
|
||||
json.dump(protocol, output_file, indent=4, separators=(',', ': '))
|
||||
output_file.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
29
third_party/inspector_protocol/convert_to_protocol_json.py
vendored
Executable file
29
third_party/inspector_protocol/convert_to_protocol_json.py
vendored
Executable file
@ -0,0 +1,29 @@
|
||||
# Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import collections
|
||||
import json
|
||||
import os.path
|
||||
import re
|
||||
import sys
|
||||
|
||||
import pdl
|
||||
# TODO(kozyatinskiy): remove with ConvertProtocolToJSON.py as soon as Node.js ready.
|
||||
def main(argv):
|
||||
if len(argv) < 2:
|
||||
sys.stderr.write("Usage: %s <protocol.pdl> <protocol.json>\n" % sys.argv[0])
|
||||
return 1
|
||||
file_name = os.path.normpath(argv[0])
|
||||
input_file = open(file_name, "r")
|
||||
pdl_string = input_file.read()
|
||||
protocol = pdl.loads(pdl_string, file_name)
|
||||
input_file.close()
|
||||
|
||||
output_file = open(os.path.normpath(argv[1]), 'wb')
|
||||
json.dump(protocol, output_file, indent=4, separators=(',', ': '))
|
||||
output_file.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv[1:]))
|
@ -27,7 +27,7 @@ template("inspector_protocol_generate") {
|
||||
inspector_protocol_dir = invoker.inspector_protocol_dir
|
||||
|
||||
action(target_name) {
|
||||
script = "$inspector_protocol_dir/CodeGenerator.py"
|
||||
script = "$inspector_protocol_dir/code_generator.py"
|
||||
|
||||
inputs = [
|
||||
invoker.config_file,
|
||||
|
@ -27,7 +27,7 @@
|
||||
'templates/Imported_h.template',
|
||||
'templates/TypeBuilder_cpp.template',
|
||||
'templates/TypeBuilder_h.template',
|
||||
'CodeGenerator.py',
|
||||
'code_generator.py',
|
||||
]
|
||||
}
|
||||
}
|
||||
|
167
third_party/inspector_protocol/pdl.py
vendored
Normal file
167
third_party/inspector_protocol/pdl.py
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
# Copyright 2018 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import collections
|
||||
import json
|
||||
import os.path
|
||||
import re
|
||||
import sys
|
||||
|
||||
description = ''
|
||||
|
||||
primitiveTypes = ['integer', 'number', 'boolean', 'string', 'object', 'any', 'array']
|
||||
|
||||
|
||||
def assignType(item, type, isArray=False):
|
||||
if isArray:
|
||||
item['type'] = 'array'
|
||||
item['items'] = collections.OrderedDict()
|
||||
assignType(item['items'], type)
|
||||
return
|
||||
|
||||
if type == 'enum':
|
||||
type = 'string'
|
||||
if type in primitiveTypes:
|
||||
item['type'] = type
|
||||
else:
|
||||
item['$ref'] = type
|
||||
|
||||
|
||||
def createItem(d, experimental, deprecated, name=None):
|
||||
result = collections.OrderedDict(d)
|
||||
if name:
|
||||
result['name'] = name
|
||||
global description
|
||||
if description:
|
||||
result['description'] = description.strip()
|
||||
if experimental:
|
||||
result['experimental'] = True
|
||||
if deprecated:
|
||||
result['deprecated'] = True
|
||||
return result
|
||||
|
||||
|
||||
def parse(data, file_name):
|
||||
protocol = collections.OrderedDict()
|
||||
protocol['version'] = collections.OrderedDict()
|
||||
protocol['domains'] = []
|
||||
domain = None
|
||||
item = None
|
||||
subitems = None
|
||||
nukeDescription = False
|
||||
global description
|
||||
lines = data.split('\n')
|
||||
for i in range(0, len(lines)):
|
||||
if nukeDescription:
|
||||
description = ''
|
||||
nukeDescription = False
|
||||
line = lines[i]
|
||||
trimLine = line.strip()
|
||||
|
||||
if trimLine.startswith('#'):
|
||||
if len(description):
|
||||
description += '\n'
|
||||
description += trimLine[2:]
|
||||
continue
|
||||
else:
|
||||
nukeDescription = True
|
||||
|
||||
if len(trimLine) == 0:
|
||||
continue
|
||||
|
||||
match = re.compile('^(experimental )?(deprecated )?domain (.*)').match(line)
|
||||
if match:
|
||||
domain = createItem({'domain' : match.group(3)}, match.group(1), match.group(2))
|
||||
protocol['domains'].append(domain)
|
||||
continue
|
||||
|
||||
match = re.compile('^ depends on ([^\s]+)').match(line)
|
||||
if match:
|
||||
if 'dependencies' not in domain:
|
||||
domain['dependencies'] = []
|
||||
domain['dependencies'].append(match.group(1))
|
||||
continue
|
||||
|
||||
match = re.compile('^ (experimental )?(deprecated )?type (.*) extends (array of )?([^\s]+)').match(line)
|
||||
if match:
|
||||
if 'types' not in domain:
|
||||
domain['types'] = []
|
||||
item = createItem({'id': match.group(3)}, match.group(1), match.group(2))
|
||||
assignType(item, match.group(5), match.group(4))
|
||||
domain['types'].append(item)
|
||||
continue
|
||||
|
||||
match = re.compile('^ (experimental )?(deprecated )?(command|event) (.*)').match(line)
|
||||
if match:
|
||||
list = []
|
||||
if match.group(3) == 'command':
|
||||
if 'commands' in domain:
|
||||
list = domain['commands']
|
||||
else:
|
||||
list = domain['commands'] = []
|
||||
else:
|
||||
if 'events' in domain:
|
||||
list = domain['events']
|
||||
else:
|
||||
list = domain['events'] = []
|
||||
|
||||
item = createItem({}, match.group(1), match.group(2), match.group(4))
|
||||
list.append(item)
|
||||
continue
|
||||
|
||||
match = re.compile('^ (experimental )?(deprecated )?(optional )?(array of )?([^\s]+) ([^\s]+)').match(line)
|
||||
if match:
|
||||
param = createItem({}, match.group(1), match.group(2), match.group(6))
|
||||
if match.group(3):
|
||||
param['optional'] = True
|
||||
assignType(param, match.group(5), match.group(4))
|
||||
if match.group(5) == 'enum':
|
||||
enumliterals = param['enum'] = []
|
||||
subitems.append(param)
|
||||
continue
|
||||
|
||||
match = re.compile('^ (parameters|returns|properties)').match(line)
|
||||
if match:
|
||||
subitems = item[match.group(1)] = []
|
||||
continue
|
||||
|
||||
match = re.compile('^ enum').match(line)
|
||||
if match:
|
||||
enumliterals = item['enum'] = []
|
||||
continue
|
||||
|
||||
match = re.compile('^version').match(line)
|
||||
if match:
|
||||
continue
|
||||
|
||||
match = re.compile('^ major (\d+)').match(line)
|
||||
if match:
|
||||
protocol['version']['major'] = match.group(1)
|
||||
continue
|
||||
|
||||
match = re.compile('^ minor (\d+)').match(line)
|
||||
if match:
|
||||
protocol['version']['minor'] = match.group(1)
|
||||
continue
|
||||
|
||||
match = re.compile('^ redirect ([^\s]+)').match(line)
|
||||
if match:
|
||||
item['redirect'] = match.group(1)
|
||||
continue
|
||||
|
||||
match = re.compile('^ ( )?[^\s]+$').match(line)
|
||||
if match:
|
||||
# enum literal
|
||||
enumliterals.append(trimLine)
|
||||
continue
|
||||
|
||||
print 'Error in %s:%s, illegal token: \t%s' % (file_name, i, line)
|
||||
sys.exit(1)
|
||||
return protocol
|
||||
|
||||
|
||||
def loads(data, file_name):
|
||||
if file_name.endswith(".pdl"):
|
||||
return parse(data, file_name)
|
||||
return json.loads(data)
|
@ -4,7 +4,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include {{format_include(config.protocol.package, domain.domain)}}
|
||||
#include {{format_domain_include(config.protocol.package, domain.domain)}}
|
||||
|
||||
#include {{format_include(config.protocol.package, "Protocol")}}
|
||||
|
||||
@ -24,7 +24,7 @@ const char Metainfo::version[] = "{{domain.version}}";
|
||||
|
||||
namespace {{type.id}}Enum {
|
||||
{% for literal in type.enum %}
|
||||
const char* {{ literal | dash_to_camelcase}} = "{{literal}}";
|
||||
const char {{ literal | dash_to_camelcase}}[] = "{{literal}}";
|
||||
{% endfor %}
|
||||
} // namespace {{type.id}}Enum
|
||||
{% if protocol.is_exported(domain.domain, type.id) %}
|
||||
|
@ -15,7 +15,7 @@
|
||||
// and include Domain::API version from there.
|
||||
{% for name in domain.dependencies %}
|
||||
{% if protocol.is_imported_dependency(name) %}
|
||||
#include {{format_include(config.protocol.package, name)}}
|
||||
#include {{format_domain_include(config.protocol.package, name)}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if protocol.is_exported_domain(domain.domain) %}
|
||||
@ -46,7 +46,7 @@ using {{type.id}} = {{protocol.resolve_type(type).type}};
|
||||
|
||||
namespace {{type.id}}Enum {
|
||||
{% for literal in type.enum %}
|
||||
{{config.protocol.export_macro}} extern const char* {{ literal | dash_to_camelcase}};
|
||||
{{config.protocol.export_macro}} extern const char {{ literal | dash_to_camelcase}}[];
|
||||
{% endfor %}
|
||||
} // namespace {{type.id}}Enum
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user