Skip to content

Commit

Permalink
fix(resources): first recursive resource support
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Byron committed Mar 10, 2015
1 parent 3b7e63f commit 35bd1c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion etc/bin/update-json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $?
Expand Down
2 changes: 2 additions & 0 deletions src/mako/lib.rs.mako
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl<'a, C, NC, A> ${hub_type}${ht_params}
${schema.new(s, c)}
% endfor

% if nested_schemas:
// ###################
// NESTED SCHEMAS ###
// #################
Expand All @@ -119,6 +120,7 @@ ${schema.new(s, c)}
% for s in nested_schemas:
${schema.new(s, c)}
% endfor
% endif

// ###################
// MethodBuilders ###
Expand Down
15 changes: 9 additions & 6 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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):]
Expand Down

0 comments on commit 35bd1c3

Please sign in to comment.