static struct config_value *_value(struct parser *p) { /* '[' TYPE* ']' | TYPE */ struct config_value *h = NULL, *l, *ll = NULL; if (p->t == TOK_ARRAY_B) { match(TOK_ARRAY_B); while (p->t != TOK_ARRAY_E) { if (!(l = _type(p))) return_0; if (!h) h = l; else ll->next = l; ll = l; if (p->t == TOK_COMMA) match(TOK_COMMA); } match(TOK_ARRAY_E); /* * Special case for an empty array. */ if (!h) { if (!(h = _create_value(p->mem))) return NULL; h->type = CFG_EMPTY_ARRAY; } } else h = _type(p); return h; }
svg_path_generator<OutputIterator,Path>::svg_path_generator() : svg_path_generator::base_type(svg) { boost::spirit::karma::uint_type uint_; boost::spirit::karma::_val_type _val; boost::spirit::karma::_1_type _1; boost::spirit::karma::lit_type lit; svg = point | linestring | polygon ; point = &uint_(mapnik::geometry::geometry_types::Point)[_1 = _type(_val)] << svg_point [_1 = _first(_val)] ; svg_point = &uint_ << lit("cx=\"") << coordinate << lit("\" cy=\"") << coordinate << lit('\"') ; linestring = &uint_(mapnik::geometry::geometry_types::LineString)[_1 = _type(_val)] << lit("d=\"") << svg_path << lit("\"") ; polygon = &uint_(mapnik::geometry::geometry_types::Polygon)[_1 = _type(_val)] << lit("d=\"") << svg_path << lit("\"") ; svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit('M') | &uint_(mapnik::SEG_LINETO) << lit('L')) << coordinate << lit(' ') << coordinate) % lit(' ') ; }
wkt_generator<OutputIterator, Geometry>::wkt_generator(bool single) : wkt_generator::base_type(wkt) { boost::spirit::karma::uint_type uint_; boost::spirit::karma::_val_type _val; boost::spirit::karma::_1_type _1; boost::spirit::karma::lit_type lit; boost::spirit::karma::_a_type _a; boost::spirit::karma::_b_type _b; boost::spirit::karma::_c_type _c; boost::spirit::karma::_r1_type _r1; boost::spirit::karma::eps_type eps; boost::spirit::karma::string_type kstring; wkt = point | linestring | polygon ; point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << kstring[ phoenix::if_ (single) [_1 = "Point("] .else_[_1 = "("]] << point_coord [_1 = _first(_val)] << lit(')') ; linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << kstring[ phoenix::if_ (single) [_1 = "LineString("] .else_[_1 = "("]] << coords << lit(')') ; polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << kstring[ phoenix::if_ (single) [_1 = "Polygon("] .else_[_1 = "("]] << coords2 << lit("))") ; point_coord = &uint_ << coordinate << lit(' ') << coordinate ; polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1][_a = _x(_val)][ _b = _y(_val)] << kstring[ if_ (_r1 > 1) [_1 = "),("] .else_[_1 = "("]] | &uint_(mapnik::SEG_LINETO) << lit(',') << eps[_a = _x(_val)][_b = _y(_val)] ) << coordinate[_1 = _a] << lit(' ') << coordinate[_1 = _b] ; coords2 %= *polygon_coord(_a,_b,_c) ; coords = point_coord % lit(',') ; }
void ClientLoop::rep_reg_type( qint64 m, int n_callback ) { if ( quint64_callbacks.contains( n_callback ) ) { Callback &lc = quint64_callbacks[ n_callback ]; connect( this, SIGNAL(_type(quint64)), lc.receiver, lc.member ); emit _type( m ); disconnect( this, SIGNAL(_type(quint64)), lc.receiver, lc.member ); } }
geometry_generator_grammar() : geometry_generator_grammar::base_type(coordinates) { boost::spirit::karma::uint_type uint_; boost::spirit::bool_type bool_; boost::spirit::karma::_val_type _val; boost::spirit::karma::_1_type _1; boost::spirit::karma::lit_type lit; boost::spirit::karma::_a_type _a; boost::spirit::karma::_r1_type _r1; boost::spirit::karma::eps_type eps; boost::spirit::karma::string_type kstring; coordinates = point | linestring | polygon ; point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << point_coord [_1 = _first(_val)] ; linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << lit('[') << coords << lit(']') ; polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << lit('[') << coords2 << lit("]]") ; point_coord = &uint_ << lit('[') << coord_type << lit(',') << coord_type << lit(']') ; polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1] << kstring[ if_ (_r1 > 1) [_1 = "],["] .else_[_1 = '[' ]] | &uint_(mapnik::SEG_LINETO) << lit(',')) << lit('[') << coord_type << lit(',') << coord_type << lit(']') ; coords2 %= *polygon_coord(_a) ; coords = point_coord % lit(',') ; }
wkt_multi_generator<OutputIterator, GeometryContainer>::wkt_multi_generator() : wkt_multi_generator::base_type(wkt) { boost::spirit::karma::lit_type lit; boost::spirit::karma::eps_type eps; boost::spirit::karma::_val_type _val; boost::spirit::karma::_1_type _1; boost::spirit::karma::_a_type _a; geometry_types.add (mapnik::geometry_type::types::Point,"Point") (mapnik::geometry_type::types::LineString,"LineString") (mapnik::geometry_type::types::Polygon,"Polygon") ; wkt = eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)] << lit("GeometryCollection(") << geometry << lit(")") | eps(is_multi(_val)) << lit("Multi") << geometry_types[_1 = phoenix::at_c<0>(_a)] << "(" << multi_geometry << ")" | geometry ; geometry = -(single_geometry % lit(',')) ; single_geometry = geometry_types[_1 = _type(_val)] << path ; multi_geometry = -(path % lit(',')) ; }
void cw__test_helpers_check_token_type(DjinniWrapperUserToken * t, DjinniString * type) { djinni::Handle<DjinniWrapperUserToken> _t(t, user_token___wrapper_dec_ref); std::unique_ptr<DjinniString> _type(type); try { ::testsuite::TestHelpers::check_token_type(DjinniWrapperUserToken::get(std::move(_t)), DjinniString::toCpp(std::move(_type))); } CW_TRANSLATE_EXCEPTIONS_RETURN(); }
int _trace(int err, char *type, char *fmt, ...) { va_list args; time_t curr_time; char c_time_str[50]; curr_time = time(NULL); ctime_r(&curr_time, c_time_str); c_time_str[strlen(c_time_str) - 1] = 0; fprintf((!strcmp(type, ERR) ? stderr : (!strcmp(type, WARN) ? stderr : stdout)), "[%s] ", c_time_str); fflush((!strcmp(type, ERR) ? stderr : (!strcmp(type, WARN) ? stderr : stdout))); _type((!strcmp(type, ERR) ? 2 : (!strcmp(type, WARN) ? 2 : 1)), type); va_start(args, fmt); vfprintf((!strcmp(type, ERR) ? stderr : (!strcmp(type, WARN) ? stderr : stdout)), fmt, args); va_end(args); if (errno != 0) { fprintf((!strcmp(type, ERR) ? stderr : (!strcmp(type, WARN) ? stderr : stdout)), " : "); fflush((!strcmp(type, ERR) ? stderr : (!strcmp(type, WARN) ? stderr : stdout))); fprintf((!strcmp(type, ERR) ? stderr : (!strcmp(type, WARN) ? stderr : stdout)), MAKE_RED); perror(""); fprintf((!strcmp(type, ERR) ? stderr : (!strcmp(type, WARN) ? stderr : stdout)), RESET_COLOR); } else { fprintf((!strcmp(type, ERR) ? stderr : (!strcmp(type, WARN) ? stderr : stdout)), "\n"); } return (err); }
Token Tokenizer::next() { if ( _pos >= _raw.size() ) return Token( Token::INVALID, "", 0, false ); unsigned start = _pos++; Token::Type type = _type( _raw[start] ); if ( type == Token::WHITESPACE ) abort(); if ( type == Token::TEXT ) while ( _pos < _raw.size() && _type( _raw[_pos] ) == type ) _pos++; StringData ret = _raw.substr( start, _pos - start ); bool old = _previousWhiteSpace; _previousWhiteSpace = _skipWhitespace(); return Token( type, ret, start, old ); }
Token Tokenizer::next() { if (_pos >= _raw.size()) return Token(Token::INVALID, "", 0); unsigned start = _pos++; Token::Type type = _type(_raw[start]); if (type == Token::WHITESPACE) MONGO_UNREACHABLE; if (type == Token::TEXT) while (_pos < _raw.size() && _type(_raw[_pos]) == type) _pos++; StringData ret = _raw.substr(start, _pos - start); _skipWhitespace(); return Token(type, ret, start); }
cv::TermCriteria MxArray::toTermCriteria(mwIndex index) const { MxArray _type(at("type", index)); return cv::TermCriteria( (_type.isChar()) ? TermCritType[_type.toString()] : _type.toInt(), at("maxCount", index).toInt(), at("epsilon", index).toDouble() ); }
bool BundleCompiler::compile(const char* type, const char* name, const char* platform) { StringId64 _type(type); StringId64 _name(name); TempAllocator512 alloc; DynamicString path(alloc); TempAllocator512 alloc2; DynamicString src_path(alloc2); src_path += name; src_path += "."; src_path += type; char res_name[1 + 2*StringId64::STRING_LENGTH]; _type.to_string(res_name); res_name[16] = '-'; _name.to_string(res_name + 17); path::join(CROWN_DATA_DIRECTORY, res_name, path); CE_LOGI("%s <= %s.%s", res_name, name, type); bool success = true; jmp_buf buf; Buffer output(default_allocator()); array::reserve(output, 4*1024*1024); if (!setjmp(buf)) { CompileOptions opts(_source_fs, output, platform, &buf); compile(_type, src_path.c_str(), opts); File* outf = _bundle_fs.open(path.c_str(), FileOpenMode::WRITE); u32 size = array::size(output); u32 written = outf->write(array::begin(output), size); _bundle_fs.close(*outf); success = size == written; } else { success = false; } return success; }
yconstfn _type make_from_tuple_impl(_tTuple&& t, index_sequence<_vSeq...>) { return _type(std::get<_vSeq>(yforward(t))...); }
bool Tokenizer::_skipWhitespace() { unsigned start = _pos; while ( _pos < _raw.size() && _type( _raw[_pos] ) == Token::WHITESPACE ) _pos++; return _pos > start; }
bool SizeAnalyzer::analyze(AnalysisVisitor & visitor, const unsigned int lhs, ast::CallExp & e) { if (lhs > 2) { return false; } const ast::exps_t args = e.getArgs(); enum Kind { ROWS, COLS, ROWSTIMESCOLS, ROWSCOLS, ONE, BOTH, DUNNO } kind = DUNNO; const std::size_t size = args.size(); if (size == 0 || size >= 3) { return false; } ast::Exp * first = *args.begin(); if (!first) { return false; } first->accept(visitor); Result & res = visitor.getResult(); if (!res.getType().ismatrix()) { visitor.getDM().releaseTmp(res.getTempId(), first); return false; } switch (size) { case 1: if (lhs == 1) { kind = BOTH; } else if (lhs == 2) { kind = ROWSCOLS; } break; case 2: { ast::Exp * second = *std::next(args.begin()); if (second && lhs == 1) { if (second->isStringExp()) { const std::wstring & arg2 = static_cast<ast::StringExp *>(second)->getValue(); if (arg2 == L"r") { kind = ROWS; } else if (arg2 == L"c") { kind = COLS; } else if (arg2 == L"*") { kind = ROWSTIMESCOLS; } else { visitor.getDM().releaseTmp(res.getTempId(), first); return false; } } else if (second->isDoubleExp()) { const double arg2 = static_cast<ast::DoubleExp *>(second)->getValue(); if (arg2 == 1) { kind = ROWS; } else if (arg2 == 2) { kind = COLS; } else if (arg2 >= 3) { // TODO: we should handle hypermatrix kind = ONE; } else { visitor.getDM().releaseTmp(res.getTempId(), first); return false; } } } else { visitor.getDM().releaseTmp(res.getTempId(), first); return false; } break; } default: visitor.getDM().releaseTmp(res.getTempId(), first); return false; } TIType type(visitor.getGVN(), TIType::DOUBLE); switch (kind) { case ROWS: { SymbolicDimension & rows = res.getType().rows; Result & _res = e.getDecorator().setResult(type); _res.getConstant() = rows.getValue(); e.getDecorator().setCall(new SizeCall(SizeCall::R)); visitor.setResult(_res); break; } case COLS: { SymbolicDimension & cols = res.getType().cols; Result & _res = e.getDecorator().setResult(type); _res.getConstant() = cols.getValue(); e.getDecorator().setCall(new SizeCall(SizeCall::C)); visitor.setResult(_res); break; } case ROWSTIMESCOLS: { SymbolicDimension & rows = res.getType().rows; SymbolicDimension & cols = res.getType().cols; SymbolicDimension prod = rows * cols; Result & _res = e.getDecorator().setResult(type); _res.getConstant() = prod.getValue(); e.getDecorator().setCall(new SizeCall(SizeCall::RC)); visitor.setResult(_res); break; } case ROWSCOLS: { SymbolicDimension & rows = res.getType().rows; SymbolicDimension & cols = res.getType().cols; std::vector<Result> & mlhs = visitor.getLHSContainer(); mlhs.clear(); mlhs.reserve(2); mlhs.emplace_back(type); mlhs.back().getConstant() = rows.getValue(); mlhs.emplace_back(type); mlhs.back().getConstant() = cols.getValue(); e.getDecorator().setCall(new SizeCall(SizeCall::R_C)); break; } case ONE: { Result & _res = e.getDecorator().setResult(type); _res.getConstant() = new types::Double(1); e.getDecorator().setCall(new SizeCall(SizeCall::ONE)); visitor.setResult(_res); break; } case BOTH: { TIType _type(visitor.getGVN(), TIType::DOUBLE, 1, 2); Result & _res = e.getDecorator().setResult(_type); e.getDecorator().setCall(new SizeCall(SizeCall::BOTH)); visitor.setResult(_res); break; } default: return false; } return true; }