mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-22 06:41:17 +00:00
Python 3 version
This commit is contained in:
parent
f55dd2ad86
commit
6dd9f576f6
@ -6,10 +6,10 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
print '''
|
print('''
|
||||||
Java binding generator for BTstack
|
Java binding generator for BTstack
|
||||||
Copyright 2015, BlueKitchen GmbH
|
Copyright 2015, BlueKitchen GmbH
|
||||||
'''
|
''')
|
||||||
|
|
||||||
# com.bluekitchen.btstack.BTstack.java templates
|
# com.bluekitchen.btstack.BTstack.java templates
|
||||||
java_btstack_header = \
|
java_btstack_header = \
|
||||||
@ -165,7 +165,7 @@ def camel_case_var(name):
|
|||||||
|
|
||||||
def read_defines(infile):
|
def read_defines(infile):
|
||||||
global defines
|
global defines
|
||||||
with open (infile, 'rb') as fin:
|
with open (infile, 'rt') as fin:
|
||||||
|
|
||||||
for line in fin:
|
for line in fin:
|
||||||
parts = re.match('#define\s+(\w+)\s+(\w*)',line)
|
parts = re.match('#define\s+(\w+)\s+(\w*)',line)
|
||||||
@ -277,11 +277,11 @@ def parse_commands(infile):
|
|||||||
|
|
||||||
outfile = '%s/BTstack.java' % gen_path
|
outfile = '%s/BTstack.java' % gen_path
|
||||||
|
|
||||||
with open(outfile, 'w') as fout:
|
with open(outfile, 'wt') as fout:
|
||||||
|
|
||||||
fout.write(java_btstack_header % package)
|
fout.write(java_btstack_header % package)
|
||||||
|
|
||||||
with open (infile, 'rb') as fin:
|
with open (infile, 'rt') as fin:
|
||||||
|
|
||||||
params = []
|
params = []
|
||||||
for line in fin:
|
for line in fin:
|
||||||
@ -349,7 +349,7 @@ def create_event(event_name, format, args):
|
|||||||
|
|
||||||
gen_event_path = '%s/event' % gen_path
|
gen_event_path = '%s/event' % gen_path
|
||||||
outfile = '%s/%s.java' % (gen_event_path, event_name)
|
outfile = '%s/%s.java' % (gen_event_path, event_name)
|
||||||
with open(outfile, 'w') as fout:
|
with open(outfile, 'wt') as fout:
|
||||||
offset = 2
|
offset = 2
|
||||||
getters = ''
|
getters = ''
|
||||||
length_name = ''
|
length_name = ''
|
||||||
@ -402,7 +402,7 @@ def create_event_factory(events, le_events, defines):
|
|||||||
event_name = camel_case(event_name)
|
event_name = camel_case(event_name)
|
||||||
subcases += java_event_factory_subevent.format(event_type, event_name)
|
subcases += java_event_factory_subevent.format(event_type, event_name)
|
||||||
|
|
||||||
with open(outfile, 'w') as fout:
|
with open(outfile, 'wt') as fout:
|
||||||
defines_text = java_defines_string(defines)
|
defines_text = java_defines_string(defines)
|
||||||
fout.write(java_event_factory_template.format(package, defines_text, cases, subcases))
|
fout.write(java_event_factory_template.format(package, defines_text, cases, subcases))
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ def parse_events(path):
|
|||||||
params = []
|
params = []
|
||||||
event_types = set()
|
event_types = set()
|
||||||
format = None
|
format = None
|
||||||
with open (path, 'rb') as fin:
|
with open (path, 'rt') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
parts = re.match('.*@format\s*(\w*)\s*', line)
|
parts = re.match('.*@format\s*(\w*)\s*', line)
|
||||||
if parts and len(parts.groups()) == 1:
|
if parts and len(parts.groups()) == 1:
|
||||||
@ -460,4 +460,4 @@ create_events(le_events)
|
|||||||
create_event_factory(events, le_events, event_types)
|
create_event_factory(events, le_events, event_types)
|
||||||
|
|
||||||
# done
|
# done
|
||||||
print 'Done!'
|
print('Done!')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user