mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-02 17:42:16 +01:00
fix(build): fixes to help more projects to build
Involving * complete list of reserved words (keywords in Rust) * use namespace for otherwise clashing types in cmn::, io::
This commit is contained in:
@@ -41,8 +41,7 @@ use std::io;
|
||||
use std::fs;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub use cmn::{Hub, ReadSeek, ResourceMethodsBuilder, MethodBuilder, Resource, Part, ResponseResult, RequestValue,
|
||||
NestedType, Delegate, DefaultDelegate, Result};
|
||||
pub use cmn::{Hub, ReadSeek, Part, ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate};
|
||||
|
||||
|
||||
// ##############
|
||||
|
||||
@@ -103,7 +103,7 @@ pub struct ${ThisType}
|
||||
% endif
|
||||
}
|
||||
|
||||
impl${mb_tparams} MethodBuilder for ${ThisType} {}
|
||||
impl${mb_tparams} cmn::MethodBuilder for ${ThisType} {}
|
||||
|
||||
impl${mb_tparams} ${ThisType} where ${', '.join(mb_type_bounds())} {
|
||||
|
||||
@@ -322,11 +322,11 @@ ${'.' + action_name | indent_by(13)}(${action_args});
|
||||
where = ''
|
||||
qualifier = 'pub '
|
||||
add_args = ''
|
||||
rtype = 'Result<()>'
|
||||
rtype = 'cmn::Result<()>'
|
||||
response_schema = method_response(schemas, c, m)
|
||||
|
||||
if response_schema:
|
||||
rtype = 'Result<%s>' % (response_schema.id)
|
||||
rtype = 'cmn::Result<%s>' % (response_schema.id)
|
||||
|
||||
if media_params:
|
||||
stripped = lambda s: s.strip().strip(',')
|
||||
@@ -377,7 +377,7 @@ ${'.' + action_name | indent_by(13)}(${action_args});
|
||||
## Additional params - may not overlap with optional params
|
||||
for &field in [${', '.join(enclose_in('"', (p.name for p in field_params)))}].iter() {
|
||||
if ${paddfields}.contains_key(field) {
|
||||
return Result::FieldClash(field);
|
||||
return cmn::Result::FieldClash(field);
|
||||
}
|
||||
}
|
||||
for (name, value) in ${paddfields}.iter() {
|
||||
@@ -432,7 +432,7 @@ else {
|
||||
## return RequestResult::Error(err);
|
||||
## }
|
||||
|
||||
Result::Success(response)
|
||||
cmn::Result::Success(response)
|
||||
}
|
||||
|
||||
% for p in media_params:
|
||||
|
||||
@@ -45,7 +45,7 @@ pub struct ${ThisType}
|
||||
hub: &'a ${hub_type_name}${hub_type_params_s()},
|
||||
}
|
||||
|
||||
impl${rb_params} ResourceMethodsBuilder for ${ThisType} {}
|
||||
impl${rb_params} cmn::ResourceMethodsBuilder for ${ThisType} {}
|
||||
|
||||
## Builder Creators Methods ####################
|
||||
impl${rb_params} ${ThisType} {
|
||||
|
||||
@@ -24,6 +24,13 @@ TYPE_MAP = {'boolean' : 'bool',
|
||||
'string' : 'String',
|
||||
'object' : 'HashMap'}
|
||||
|
||||
RESERVED_WORDS = set(('abstract', 'alignof', 'as', 'become', 'box', 'break', 'const', 'continue', 'crate', 'do',
|
||||
'else', 'enum', 'extern', 'false', 'final', 'fn', 'for', 'if', 'impl', 'in', 'let', 'loop',
|
||||
'macro', 'match', 'mod', 'move', 'mut', 'offsetof', 'override', 'priv', 'pub', 'pure', 'ref',
|
||||
'return', 'sizeof', 'static', 'self', 'struct', 'super', 'true', 'trait', 'type', 'typeof',
|
||||
'unsafe', 'unsized', 'use', 'virtual', 'where', 'while', 'yield'))
|
||||
|
||||
|
||||
_words = [w.strip(',') for w in "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.".split(' ')]
|
||||
RUST_TYPE_RND_MAP = {'bool': lambda: str(bool(randint(0, 1))).lower(),
|
||||
'u32' : lambda: randint(0, 100),
|
||||
@@ -246,8 +253,8 @@ def nested_type_name(sn, pn):
|
||||
|
||||
# Make properties which are reserved keywords usable
|
||||
def mangle_ident(n):
|
||||
n = '_'.join(singular(w) for w in camel_to_under(n).split('.'))
|
||||
if n in ('type', 'where', 'override', 'move'):
|
||||
n = camel_to_under(n).replace('-', '.').replace('.', '')
|
||||
if n in RESERVED_WORDS:
|
||||
return n + '_'
|
||||
return n
|
||||
|
||||
@@ -352,7 +359,7 @@ def schema_markers(s, c):
|
||||
# it should have at least one activity that matches it's type to qualify for the Resource trait
|
||||
for fqan, iot in activities.iteritems():
|
||||
if activity_name_to_type_name(activity_split(fqan)[1]).lower() == s.id.lower():
|
||||
res.add('Resource')
|
||||
res.add('cmn::Resource')
|
||||
if IO_RESPONSE in iot:
|
||||
res.add('ResponseResult')
|
||||
if IO_REQUEST in iot:
|
||||
|
||||
Reference in New Issue
Block a user