Skip to content

Commit

Permalink
fix(traits): finally, we pick up all types
Browse files Browse the repository at this point in the history
HashMap types were missing previously, but now it seems to be picked
up quite nicely.
Would this mean we do the type-setup correctly, everywhere ?
  • Loading branch information
Byron committed Mar 11, 2015
1 parent 00de2b1 commit 7e24393
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
20 changes: 19 additions & 1 deletion gen/youtube3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5035,7 +5035,7 @@ impl ResponseResult for PageInfo {}
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[derive(Default, Clone)]
#[derive(Default, Clone, RustcEncodable, RustcDecodable)]
pub struct ChannelContentDetailsRelatedPlaylists {
/// The ID of the playlist that contains the channel"s uploaded videos. Use the videos.insert method to upload new videos and the videos.delete method to delete previously uploaded videos.
pub uploads: Option<String>,
Expand All @@ -5051,7 +5051,25 @@ pub struct ChannelContentDetailsRelatedPlaylists {

impl NestedType for ChannelContentDetailsRelatedPlaylists {}
impl Part for ChannelContentDetailsRelatedPlaylists {}
impl RequestValue for ChannelContentDetailsRelatedPlaylists {}
impl ResponseResult for ChannelContentDetailsRelatedPlaylists {}
impl cmn::Resource for ChannelContentDetailsRelatedPlaylists {}

impl ChannelContentDetailsRelatedPlaylists {
/// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`.
/// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or
/// the parts you want to see in the server response.
fn to_parts(&self) -> String {
let mut r = String::new();
if self.uploads.is_some() { r = r + "uploads,"; }
if self.watch_history.is_some() { r = r + "watchHistory,"; }
if self.likes.is_some() { r = r + "likes,"; }
if self.favorites.is_some() { r = r + "favorites,"; }
if self.watch_later.is_some() { r = r + "watchLater,"; }
r.pop();
r
}
}


// ###################
Expand Down
20 changes: 15 additions & 5 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def schema_markers(s, c):
used_by.extend(oid.used_by)
used_by.extend(oid.parents)
# end gather usages

for sid in ids:
activities = c.sta_map.get(sid, dict())
if len(activities) == 0:
Expand Down Expand Up @@ -616,12 +616,23 @@ def link_used(s, rs):
if rs.id not in l:
l.append(rs.id)

def append_unique(l, s):
if s not in l:
l.append(s)
return l

all_schemas = deepcopy(schemas)
def recurse_properties(prefix, rs, s, parent_ids):
assure_list(s, USED_BY)
assure_list(s, PARENT).extend(parent_ids)
link_used(s, rs)

if is_nested_type_property(s) and 'id' not in s:
s.id = prefix
all_schemas[s.id] = s
rs = s
# end this is already a perfectly valid type

properties = s.get('properties', {rs.id: s})
for pn, p in properties.iteritems():
link_used(p, rs)
Expand All @@ -634,13 +645,12 @@ def recurse_properties(prefix, rs, s, parent_ids):
if 'items' in p:
ns.update((k, deepcopy(v)) for k, v in p.items.iteritems())

recurse_properties(prefix + canonical_type_name(pn), ns, ns, parent_ids + [rs.id])
recurse_properties(nested_type_name(prefix, pn), ns, ns, append_unique(parent_ids, rs.id))
elif _is_map_prop(p):
# TODO: does this code run ? Why is there a plain prefix
recurse_properties(prefix + canonical_type_name(pn), rs, p.additionalProperties, parent_ids + [])
recurse_properties(nested_type_name(prefix, pn), rs, p.additionalProperties, append_unique(parent_ids, rs.id))
elif 'items' in p:
# it's an array
recurse_properties(prefix + canonical_type_name(pn), rs, p.items, parent_ids + [])
recurse_properties(nested_type_name(prefix, pn), rs, p.items, append_unique(parent_ids, rs.id))
# end handle prop itself
# end for each property
# end utility
Expand Down

0 comments on commit 7e24393

Please sign in to comment.