Generates a TypeScript type for a stone alias.
160750
def _generate_alias_type(self, alias_type):
        
        namespace = alias_type.namespace
        self.emit('export type %s = %s;' % (fmt_type_name(alias_type, namespace),
                                     fmt_type_name(alias_type.data_type, namespace)))
        self.emit()
796741
function resolveTypes(types) {

  CORE_TYPES.forEach(function(t) {
    if (!types[t]) {
      types[t] = {type:t, resolved:true};
    }
  });

  // Resolve the type structure by copying all properties and read/write functions from the parent to the child
  // (if they aren't already defined)
  // Can (and will often be) run multiple times on the same object.
  // XXX: This isn't pretty
  function resolveType(type) {

    if (typeof type !== 'object') {
      throw new Error('Type definition must be an object. Illegal value: ' + type);
    }

    var parent = types[type.type];

    while (parent && !type.resolved) {
      resolveType(parent);

      _.defaults(type, JSON.parse(JSON.stringify(parent)));
      type.write = type.write || parent.write;
      type.read = type.read || parent.read;
      type.type = parent.type; // Always switch to the parent's type.
      parent = types[type.type];
    }

  }

  Object.keys(types).forEach(function(name) {

    var type = types[name];
    resolveType(type);

    type.name = name;
  });

  Object.keys(types).forEach(function(name) {

    var type = types[name];
    // Add any missing read/write functions

    if (!type.write) {
      type.write = function(builder, value, attribute) {

        if (attribute.mask) {
          if (typeof value == 'object') {
            var mask = '';
            attribute.mask.slice().reverse().forEach(function(property) {
              mask += value[property]?'1':'0'; // XXX: Is this a problem performance-wise?
            });

            debug('Created mask for ', attribute.name, mask, value);
            value = parseInt(mask, 2);

          }
        }

        if (attribute.enum) {
          switch(typeof value) {
            case 'string':
              value = attribute.enum[value];
              break;
            case 'number':
              value = attribute.enum.get(value);
              break;
          }
          value = value.value;
        }

        builder[attribute.type](value);
      };
    }

    if (!type.read) {
      type.read = function(parser, attribute) {
        parser[attribute.type](attribute.name);

        /*parser.tap(function() {
          debug('Read attribute', attribute.name, this.vars[attribute.name]);
        });*/

        if (attribute.mask) {

          parser.tap(function() {
            var value = {};
            this.vars[attribute.name].toString(2).split('').reverse().forEach(function(bit, pos) {
              value[attribute.mask[pos]] = (bit === '1');
            });
            this.vars[attribute.name] = value;
          });
        }
      };
    }

  });

  //debug('Resolved types', types);

  return types;
}
377795
def by_alias(cls, name: str) -> "TxType":
        """"""
        return {
            "get": TxType.Get,
            "check": TxType.Check,
            "delete": TxType.Delete,
            "save": TxType.Update,
        }[name]
673606
def exchange_typecasting_alias_method_chain attribute, setter=nil
      alias_method :"#{attribute}_without_exchange_typecasting#{setter}", :"#{attribute}#{setter}"
      alias_method :"#{attribute}#{setter}", :"#{attribute}_with_exchange_typecasting#{setter}"
    end
1294227
def register_type(cls, name):
    """"""
    x = TypeDefinition(name, (cls,), ())
    Validator.types_mapping[name] = x
660825
function mongoType(
  typeStr,
  options
) {
  const required = typeStr.match(/^(\S+)!$/);
  const list = typeStr.match(/^\[(\S+)]$/);

  if (required) {
    const innerType = required[1];
    if (_.includes(SCALARS, innerType)) {
      options.required = true;
    }
    return mongoType(innerType);
  } else if (list) {
    return [ mongoType(list[1]) ];
  }
  switch (typeStr) {
    case 'String':
      return String;
    case 'Int':
    case 'Float':
      return Number;
    case 'Boolean':
      return Boolean;
    case 'DateTime':
      return Date;
    case 'ID':
      return mongoose.Schema.Types.ObjectId;
    case 'JSON':
      return mongoose.Schema.Types.Mixed;
    default:
      throw new Error(typeStr);
  }
}
84821
def check_type(type_name)
      alias_name = @rally_alias_types[type_name.downcase.to_s]
      return alias_name unless alias_name.nil?
      return type_name
    end
711124
def typeCompileAst(ast):
    
    children = list(ast.children)
    if ast.astType == 'op':
        retsig = ast.typecode()
        basesig = ''.join(x.typecode() for x in list(ast.children))
        # Find some operation that will work on an acceptable casting of args.
        for sig in sigPerms(basesig):
            value = (ast.value + '_' + retsig + sig).encode('ascii')
            if value in interpreter.opcodes:
                break
        else:
            for sig in sigPerms(basesig):
                funcname = (ast.value + '_' + retsig + sig).encode('ascii')
                if funcname in interpreter.funccodes:
                    value = ('func_%sn' % (retsig + sig)).encode('ascii')
                    children += [ASTNode('raw', 'none',
                                         interpreter.funccodes[funcname])]
                    break
            else:
                raise NotImplementedError(
                    "couldn't find matching opcode for '%s'"
                    % (ast.value + '_' + retsig + basesig))
        # First just cast constants, then cast variables if necessary:
        for i, (have, want) in enumerate(zip(basesig, sig)):
            if have != want:
                kind = typecode_to_kind[want]
                if children[i].astType == 'constant':
                    children[i] = ASTNode('constant', kind, children[i].value)
                else:
                    opname = "cast"
                    children[i] = ASTNode('op', kind, opname, [children[i]])
    else:
        value = ast.value
        children = ast.children
    return ASTNode(ast.astType, ast.astKind, value,
                   [typeCompileAst(c) for c in children])
1101631
def _format_type(cls):
    """"""
    if cls.__module__ == _BUILTIN_MODULE:
        return cls.__name__
    else:
        return '%s.%s' % (cls.__module__, cls.__name__)
1301340
private static void createLanguageAliases(TypeSpec.Builder type, Map<String, String> languageAliases) {
    MethodSpec.Builder method = MethodSpec.methodBuilder("registerLanguageAliases")
        .addModifiers(PRIVATE, STATIC);
    
    for (Map.Entry<String, String> entry : languageAliases.entrySet()) {
      method.addStatement("addLanguageAlias($S, $S)", 
          entry.getKey(), entry.getValue());
    }
    
    type.addMethod(method.build());
  }
205620
def make_stone_friendly(self, data_type, val, validate):
        
        if isinstance(data_type, bv.Timestamp):
            try:
                ret = datetime.datetime.strptime(val, data_type.format)
            except (TypeError, ValueError) as e:
                raise bv.ValidationError(e.args[0])
        elif isinstance(data_type, bv.Bytes):
            if self.for_msgpack:
                if isinstance(val, six.text_type):
                    ret = val.encode('utf-8')
                else:
                    ret = val
            else:
                try:
                    ret = base64.b64decode(val)
                except TypeError:
                    raise bv.ValidationError('invalid base64-encoded bytes')
        elif isinstance(data_type, bv.Void):
            if self.strict and val is not None:
                raise bv.ValidationError("expected null, got value")
            return None
        else:
            if validate:
                if self.caller_permissions.permissions:
                    data_type.validate_with_permissions(val, self.caller_permissions)
                else:
                    data_type.validate(val)
            ret = val
        if self.alias_validators is not None and data_type in self.alias_validators:
            self.alias_validators[data_type](ret)
        return ret
577970
def update_aliases(aliases,aonly,x):
    ""
    if isinstance(x,basestring): aliases[x]=x
    elif isinstance(x,sqparse2.AliasX):
      if not isinstance(x.alias,basestring): raise TypeError('alias not string',type(x.alias))
      if isinstance(x.name,sqparse2.NameX): aliases.update({x.alias:x.name.name,x.name.name:x.name.name})
      elif isinstance(x.name,sqparse2.SelectX):
        aliases.update({x.alias:x.alias})
        aonly[x.alias]=x.name
      else: raise TypeError('aliasx_unk_thing',type(x.name)) # pragma: no cover
    else: raise TypeError(type(x)) # pragma: no cover
591135
function typeChecker(type) {
  var typeString = "[object " + type + "]";
  return function(value) {
    return Object.prototype.toString.call(value) === typeString;
  };
}
281717
def _validate_stone_cfg(self):
        
        def mk_route_schema():
            s = Struct('Route', ApiNamespace('stone_cfg'), None)
            s.set_attributes(None, [], None)
            return s

        try:
            stone_cfg = self.api.namespaces.pop('stone_cfg')
        except KeyError:
            return mk_route_schema()

        if stone_cfg.routes:
            route = stone_cfg.routes[0]
            raise InvalidSpec(
                'No routes can be defined in the stone_cfg namespace.',
                route._ast_node.lineno,
                route._ast_node.path,
            )

        if not stone_cfg.data_types:
            return mk_route_schema()

        for data_type in stone_cfg.data_types:
            if data_type.name != 'Route':
                raise InvalidSpec(
                    "Only a struct named 'Route' can be defined in the "
                    "stone_cfg namespace.",
                    data_type._ast_node.lineno,
                    data_type._ast_node.path,
                )

        # TODO: are we always guaranteed at least one data type?
        # pylint: disable=undefined-loop-variable
        return data_type
790397
function typescriptSource() {
    return gulp.src([
        "./src/helper/*.ts",
        "./src/BasicCollection.ts",
        "./src/OrderedCollection.ts",
        "./src/CollectionStatic.ts",
        "./src/internal/Collection.ts",
        "./src/internal/MinHeap.ts",
        "./src/internal/OrderedCollection.ts",
        "./src/module.ts"
    ])

        // remove import statements
        .pipe(replace(/import\s[^;]+;/ig, ""))

        // remove exports for hidden internal stuff starting with two "_",
        // exports with just one "_" remain as they are required for testing
        .pipe(replace(/export\s(\w+\s__)/ig, "$1"))
        .pipe(concat("linq.ts"))
        .pipe(gulp.dest("./build"));
}
1141885
def generate(
        cls: Type[T], data: Generic, name: str = None, *, recursive: bool = True
    ) -> T:
        """"""
        if name is None:
            name = cls.__name__
        kls = make_class(name, {k: ib(default=None) for k in data}, bases=(cls,))
        data = {
            k: (
                cls.generate(v, k.title())
                if recursive and isinstance(v, Mapping)
                else v
            )
            for k, v in data.items()
        }
        return kls(**data)
1297157
def target_types_from_build_file_aliases(aliases):
  """"""
  target_types = dict(aliases.target_types)
  for alias, factory in aliases.target_macro_factories.items():
    target_type, = factory.target_types
    target_types[alias] = target_type
  return target_types