Commit dcf0456c authored by Aleksey Kozyatinskiy's avatar Aleksey Kozyatinskiy Committed by Commit Bot

Revert "Roll third_party/inspector_protocol to 59ca26e"

This reverts commit bd7f5cf0.

Reason for revert: does not work well.

Original change's description:
> 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}

TBR=pfeldman@chromium.org,yangguo@chromium.org,kozyatinskiy@chromium.org

Change-Id: I64cfa2740c03a2c15db1eb483212adec8f5f6a76
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: none
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Reviewed-on: https://chromium-review.googlesource.com/1024350Reviewed-by: 's avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52740}
parent 519efef5
...@@ -75,7 +75,7 @@ if (v8_enable_backtrace == "") { ...@@ -75,7 +75,7 @@ if (v8_enable_backtrace == "") {
# subdirectories. # subdirectories.
v8_path_prefix = get_path_info("../", "abspath") v8_path_prefix = get_path_info("../", "abspath")
v8_inspector_js_protocol = v8_path_prefix + "/src/inspector/js_protocol.pdl" v8_inspector_js_protocol = v8_path_prefix + "/src/inspector/js_protocol.json"
############################################################################### ###############################################################################
# Templates # Templates
......
...@@ -30,9 +30,9 @@ _protocol_generated = [ ...@@ -30,9 +30,9 @@ _protocol_generated = [
action("protocol_compatibility") { action("protocol_compatibility") {
visibility = [ ":*" ] # Only targets in this file can depend on this. visibility = [ ":*" ] # Only targets in this file can depend on this.
script = "$_inspector_protocol/check_protocol_compatibility.py" script = "$_inspector_protocol/CheckProtocolCompatibility.py"
inputs = [ inputs = [
"js_protocol.pdl", "js_protocol.json",
] ]
_stamp = "$target_gen_dir/js_protocol.stamp" _stamp = "$target_gen_dir/js_protocol.stamp"
outputs = [ outputs = [
...@@ -41,7 +41,7 @@ action("protocol_compatibility") { ...@@ -41,7 +41,7 @@ action("protocol_compatibility") {
args = [ args = [
"--stamp", "--stamp",
rebase_path(_stamp, root_build_dir), rebase_path(_stamp, root_build_dir),
rebase_path("js_protocol.pdl", root_build_dir), rebase_path("js_protocol.json", root_build_dir),
] ]
} }
...@@ -55,7 +55,7 @@ inspector_protocol_generate("protocol_generated_sources") { ...@@ -55,7 +55,7 @@ inspector_protocol_generate("protocol_generated_sources") {
out_dir = target_gen_dir out_dir = target_gen_dir
config_file = "inspector_protocol_config.json" config_file = "inspector_protocol_config.json"
inputs = [ inputs = [
"js_protocol.pdl", "js_protocol.json",
"inspector_protocol_config.json", "inspector_protocol_config.json",
] ]
outputs = _protocol_generated outputs = _protocol_generated
......
...@@ -9,6 +9,9 @@ yangguo@chromium.org ...@@ -9,6 +9,9 @@ yangguo@chromium.org
# Changes to remote debugging protocol require devtools review to # Changes to remote debugging protocol require devtools review to
# ensure backwards compatibility and commitment to maintain. # 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=set noparent
per-file js_protocol.pdl=dgozman@chromium.org per-file js_protocol.pdl=dgozman@chromium.org
per-file js_protocol.pdl=pfeldman@chromium.org per-file js_protocol.pdl=pfeldman@chromium.org
......
...@@ -17,8 +17,8 @@ def _CompileScripts(input_api, output_api): ...@@ -17,8 +17,8 @@ def _CompileScripts(input_api, output_api):
local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] local_paths = [f.LocalPath() for f in input_api.AffectedFiles()]
compilation_related_files = [ compilation_related_files = [
"js_protocol.pdl" "js_protocol.json"
"compile-scripts.py", "compile-scripts.js",
"injected-script-source.js", "injected-script-source.js",
"injected_script_externs.js", "injected_script_externs.js",
"check_injected_script_source.js" "check_injected_script_source.js"
......
...@@ -27,7 +27,7 @@ injected_script_externs_file = path.join(v8_inspector_path, ...@@ -27,7 +27,7 @@ injected_script_externs_file = path.join(v8_inspector_path,
'injected_script_externs.js') 'injected_script_externs.js')
generate_protocol_externs.generate_protocol_externs(protocol_externs_file, generate_protocol_externs.generate_protocol_externs(protocol_externs_file,
path.join(v8_inspector_path, 'js_protocol.pdl')) path.join(v8_inspector_path, 'js_protocol.json'))
error_warning_regex = re.compile(r'WARNING|ERROR') error_warning_regex = re.compile(r'WARNING|ERROR')
......
...@@ -28,17 +28,8 @@ ...@@ -28,17 +28,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os import os
import os.path as path
import re import re
import json 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 = { type_traits = {
"any": "*", "any": "*",
...@@ -105,7 +96,8 @@ def param_type(domain_name, param): ...@@ -105,7 +96,8 @@ def param_type(domain_name, param):
def load_schema(file, domains): def load_schema(file, domains):
input_file = open(file, "r") input_file = open(file, "r")
parsed_json = pdl.loads(input_file.read(), file) json_string = input_file.read()
parsed_json = json.loads(json_string)
domains.extend(parsed_json["domains"]) domains.extend(parsed_json["domains"])
......
{ {
"protocol": { "protocol": {
"path": "js_protocol.pdl", "path": "js_protocol.json",
"package": "src/inspector/protocol", "package": "src/inspector/protocol",
"output": "protocol", "output": "protocol",
"namespace": ["v8_inspector", "protocol"], "namespace": ["v8_inspector", "protocol"],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -50,8 +50,6 @@ import os.path ...@@ -50,8 +50,6 @@ import os.path
import optparse import optparse
import sys import sys
import pdl
try: try:
import json import json
except ImportError: except ImportError:
...@@ -230,8 +228,8 @@ def load_schema(file_name, domains): ...@@ -230,8 +228,8 @@ def load_schema(file_name, domains):
if not os.path.isfile(file_name): if not os.path.isfile(file_name):
return return
input_file = open(file_name, "r") input_file = open(file_name, "r")
parsed_json = pdl.loads(input_file.read(), file_name) json_string = input_file.read()
input_file.close() parsed_json = json.loads(json_string)
domains += parsed_json["domains"] domains += parsed_json["domains"]
return parsed_json["version"] return parsed_json["version"]
...@@ -424,7 +422,6 @@ def load_domains_and_baselines(file_name, domains, baseline_domains): ...@@ -424,7 +422,6 @@ def load_domains_and_baselines(file_name, domains, baseline_domains):
version = load_schema(os.path.normpath(file_name), domains) version = load_schema(os.path.normpath(file_name), domains)
suffix = "-%s.%s.json" % (version["major"], version["minor"]) suffix = "-%s.%s.json" % (version["major"], version["minor"])
baseline_file = file_name.replace(".json", suffix) baseline_file = file_name.replace(".json", suffix)
baseline_file = file_name.replace(".pdl", suffix)
load_schema(os.path.normpath(baseline_file), baseline_domains) load_schema(os.path.normpath(baseline_file), baseline_domains)
return version return version
......
...@@ -14,8 +14,6 @@ try: ...@@ -14,8 +14,6 @@ try:
except ImportError: except ImportError:
import simplejson as json import simplejson as json
import pdl
# Path handling for libraries and templates # Path handling for libraries and templates
# Paths have to be normalized because Jinja uses the exact template path to # 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 # determine the hash used in the cache filename, and we need a pre-caching step
...@@ -97,7 +95,6 @@ def read_config(): ...@@ -97,7 +95,6 @@ def read_config():
".protocol.export_macro": "", ".protocol.export_macro": "",
".protocol.export_header": False, ".protocol.export_header": False,
".protocol.options": False, ".protocol.options": False,
".protocol.file_name_prefix": "",
".exported": False, ".exported": False,
".exported.export_macro": "", ".exported.export_macro": "",
".exported.export_header": False, ".exported.export_header": False,
...@@ -159,10 +156,6 @@ def format_include(config, header, file_name=None): ...@@ -159,10 +156,6 @@ def format_include(config, header, file_name=None):
return header 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): def to_file_name(config, file_name):
if config.use_snake_file_names: if config.use_snake_file_names:
return to_snake_case(file_name).replace(".cpp", ".cc") return to_snake_case(file_name).replace(".cpp", ".cc")
...@@ -337,8 +330,9 @@ class Protocol(object): ...@@ -337,8 +330,9 @@ class Protocol(object):
def read_protocol_file(self, file_name): def read_protocol_file(self, file_name):
input_file = open(file_name, "r") input_file = open(file_name, "r")
parsed_json = pdl.loads(input_file.read(), file_name) json_string = input_file.read()
input_file.close() input_file.close()
parsed_json = json.loads(json_string)
version = parsed_json["version"]["major"] + "." + parsed_json["version"]["minor"] version = parsed_json["version"]["major"] + "." + parsed_json["version"]["minor"]
domains = [] domains = []
for domain in parsed_json["domains"]: for domain in parsed_json["domains"]:
...@@ -577,23 +571,21 @@ def main(): ...@@ -577,23 +571,21 @@ def main():
for domain in protocol.json_api["domains"]: for domain in protocol.json_api["domains"]:
class_name = domain["domain"] class_name = domain["domain"]
file_name = config.protocol.file_name_prefix + class_name
template_context = { template_context = {
"protocol": protocol, "protocol": protocol,
"config": config, "config": config,
"domain": domain, "domain": domain,
"join_arrays": join_arrays, "join_arrays": join_arrays,
"format_include": functools.partial(format_include, config), "format_include": functools.partial(format_include, config),
"format_domain_include": functools.partial(format_domain_include, config),
} }
if domain["domain"] in protocol.generate_domains: if domain["domain"] in protocol.generate_domains:
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, class_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) outputs[os.path.join(config.protocol.output, to_file_name(config, class_name + ".cpp"))] = cpp_template.render(template_context)
if domain["domain"] in protocol.exported_domains: if domain["domain"] in protocol.exported_domains:
outputs[os.path.join(config.exported.output, to_file_name(config, file_name + ".h"))] = exported_template.render(template_context) outputs[os.path.join(config.exported.output, to_file_name(config, class_name + ".h"))] = exported_template.render(template_context)
if domain["domain"] in protocol.imported_domains: if domain["domain"] in protocol.imported_domains:
outputs[os.path.join(config.protocol.output, to_file_name(config, file_name + ".h"))] = imported_template.render(template_context) outputs[os.path.join(config.protocol.output, to_file_name(config, class_name + ".h"))] = imported_template.render(template_context)
if config.lib: if config.lib:
template_context = { template_context = {
......
...@@ -11,7 +11,6 @@ try: ...@@ -11,7 +11,6 @@ try:
except ImportError: except ImportError:
import simplejson as json import simplejson as json
import pdl
def main(argv): def main(argv):
if len(argv) < 1: if len(argv) < 1:
...@@ -26,7 +25,8 @@ def main(argv): ...@@ -26,7 +25,8 @@ def main(argv):
sys.stderr.write("Cannot find %s\n" % file_name) sys.stderr.write("Cannot find %s\n" % file_name)
return 1 return 1
input_file = open(file_name, "r") input_file = open(file_name, "r")
parsed_json = pdl.loads(input_file.read(), file_name) json_string = input_file.read()
parsed_json = json.loads(json_string)
domains += parsed_json["domains"] domains += parsed_json["domains"]
version = parsed_json["version"] version = parsed_json["version"]
......
# Copyright 2018 The Chromium Authors. All rights reserved. # Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import convert_to_protocol_json import collections
import json
import os.path
import re
import sys
file_name = None
description = ''
def main(): primitiveTypes = ['integer', 'number', 'boolean', 'string', 'object', 'any', 'array']
convert_protocol_to_json.main()
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:]))
...@@ -2,7 +2,7 @@ Name: inspector protocol ...@@ -2,7 +2,7 @@ Name: inspector protocol
Short Name: inspector_protocol Short Name: inspector_protocol
URL: https://chromium.googlesource.com/deps/inspector_protocol/ URL: https://chromium.googlesource.com/deps/inspector_protocol/
Version: 0 Version: 0
Revision: dd90116bd5b9b49678b70954ccf615b21af472a8 Revision: 752d4abd13119010cf30e454e8ef9b5fb7ef43a3
License: BSD License: BSD
License File: LICENSE License File: LICENSE
Security Critical: no Security Critical: no
......
# 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:]))
# 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") { ...@@ -27,7 +27,7 @@ template("inspector_protocol_generate") {
inspector_protocol_dir = invoker.inspector_protocol_dir inspector_protocol_dir = invoker.inspector_protocol_dir
action(target_name) { action(target_name) {
script = "$inspector_protocol_dir/code_generator.py" script = "$inspector_protocol_dir/CodeGenerator.py"
inputs = [ inputs = [
invoker.config_file, invoker.config_file,
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
'templates/Imported_h.template', 'templates/Imported_h.template',
'templates/TypeBuilder_cpp.template', 'templates/TypeBuilder_cpp.template',
'templates/TypeBuilder_h.template', 'templates/TypeBuilder_h.template',
'code_generator.py', 'CodeGenerator.py',
] ]
} }
} }
# 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 @@ ...@@ -4,7 +4,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include {{format_domain_include(config.protocol.package, domain.domain)}} #include {{format_include(config.protocol.package, domain.domain)}}
#include {{format_include(config.protocol.package, "Protocol")}} #include {{format_include(config.protocol.package, "Protocol")}}
...@@ -24,7 +24,7 @@ const char Metainfo::version[] = "{{domain.version}}"; ...@@ -24,7 +24,7 @@ const char Metainfo::version[] = "{{domain.version}}";
namespace {{type.id}}Enum { namespace {{type.id}}Enum {
{% for literal in type.enum %} {% for literal in type.enum %}
const char {{ literal | dash_to_camelcase}}[] = "{{literal}}"; const char* {{ literal | dash_to_camelcase}} = "{{literal}}";
{% endfor %} {% endfor %}
} // namespace {{type.id}}Enum } // namespace {{type.id}}Enum
{% if protocol.is_exported(domain.domain, type.id) %} {% if protocol.is_exported(domain.domain, type.id) %}
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
// and include Domain::API version from there. // and include Domain::API version from there.
{% for name in domain.dependencies %} {% for name in domain.dependencies %}
{% if protocol.is_imported_dependency(name) %} {% if protocol.is_imported_dependency(name) %}
#include {{format_domain_include(config.protocol.package, name)}} #include {{format_include(config.protocol.package, name)}}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if protocol.is_exported_domain(domain.domain) %} {% if protocol.is_exported_domain(domain.domain) %}
...@@ -46,7 +46,7 @@ using {{type.id}} = {{protocol.resolve_type(type).type}}; ...@@ -46,7 +46,7 @@ using {{type.id}} = {{protocol.resolve_type(type).type}};
namespace {{type.id}}Enum { namespace {{type.id}}Enum {
{% for literal in type.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 %} {% endfor %}
} // namespace {{type.id}}Enum } // namespace {{type.id}}Enum
{% endif %} {% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment