fix(resources): first recursive resource support

However, this also means we need recursive builders, which is tottally
unsupported for now ... .

This means we have to generalize rbuild generation ... could be easy.
Lets see
This commit is contained in:
Sebastian Thiel
2015-03-10 11:04:25 +01:00
parent 3b7e63f286
commit 35bd1c3e9c
3 changed files with 12 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ api_base=${2:?Second argument must be the destination path to which to copy the
(cd ${repo_path} && git pull --ff-only) || exit $?
for json_path in `cd ${repo_path} && find . -type f -name "*-api.json"`; do
for json_path in `cd ${repo_path} && find . -type f -name "*-api.json" -or -name "*-gen.go"`; do
dest=${api_base}/`dirname ${json_path}`
mkdir -p ${dest} || exit $?
cp ${repo_path}/${json_path} ${dest} || exit $?

View File

@@ -111,6 +111,7 @@ impl<'a, C, NC, A> ${hub_type}${ht_params}
${schema.new(s, c)}
% endfor
% if nested_schemas:
// ###################
// NESTED SCHEMAS ###
// #################
@@ -119,6 +120,7 @@ ${schema.new(s, c)}
% for s in nested_schemas:
${schema.new(s, c)}
% endfor
% endif
// ###################
// MethodBuilders ###

View File

@@ -372,8 +372,7 @@ def schema_markers(s, c):
# return (name, method)
def activity_split(fqan):
t = fqan.split('.')
assert len(t) == 3
return t[1:]
return t[1], '.'.join(t[2:])
# Shorthand to get a type from parameters of activities
def activity_rust_type(p, allow_optionals=True):
@@ -535,10 +534,14 @@ def new_context(resources):
# A: { SchemaTypeName -> { fqan -> ['request'|'response', ...]}
# B: { fqan -> activity_method_data }
# fqan = fully qualified activity name
def build_activity_mappings(activities):
res = dict()
fqan = dict()
def build_activity_mappings(activities, res = None, fqan = None):
if res is None:
res = dict()
if fqan is None:
fqan = dict()
for an, a in activities.iteritems():
if 'resources' in a:
build_activity_mappings(a.resources, res, fqan)
if 'methods' not in a:
continue
for mn, m in a.methods.iteritems():
@@ -648,7 +651,7 @@ def scope_url_to_variant(name, url, fully_qualified=True):
FULL = 'Full'
fqvn = lambda n: fully_qualified and 'Scope::%s' % n or n
base = os.path.basename(url)
# special case, which works for now ...
# special case, which works for now ... https://mail.gmail.com
if not base.startswith(name):
return fqvn(FULL)
base = base[len(name):]