MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / ParseFunction

Method ParseFunction

native/thirdpart/flatbuffers/idl_parser.cpp:1831–1872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1829#endif
1830
1831CheckedError Parser::ParseFunction(const std::string *name, Value &e) {
1832 ParseDepthGuard depth_guard(this);
1833 ECHECK(depth_guard.Check());
1834
1835 // Copy name, attribute will be changed on NEXT().
1836 const auto functionname = attribute_;
1837 if (!IsFloat(e.type.base_type)) {
1838 return Error(functionname + ": type of argument mismatch, expecting: " +
1839 kTypeNames[BASE_TYPE_DOUBLE] +
1840 ", found: " + kTypeNames[e.type.base_type] +
1841 ", name: " + (name ? *name : "") + ", value: " + e.constant);
1842 }
1843 NEXT();
1844 EXPECT('(');
1845 ECHECK(ParseSingleValue(name, e, false));
1846 EXPECT(')');
1847 // calculate with double precision
1848 double x, y = 0.0;
1849 ECHECK(atot(e.constant.c_str(), *this, &x));
1850 // clang-format off
1851 auto func_match = false;
1852 #define FLATBUFFERS_FN_DOUBLE(name, op) \
1853 if (!func_match && functionname == name) { y = op; func_match = true; }
1854 FLATBUFFERS_FN_DOUBLE("deg", x / kPi * 180);
1855 FLATBUFFERS_FN_DOUBLE("rad", x * kPi / 180);
1856 FLATBUFFERS_FN_DOUBLE("sin", sin(x));
1857 FLATBUFFERS_FN_DOUBLE("cos", cos(x));
1858 FLATBUFFERS_FN_DOUBLE("tan", tan(x));
1859 FLATBUFFERS_FN_DOUBLE("asin", asin(x));
1860 FLATBUFFERS_FN_DOUBLE("acos", acos(x));
1861 FLATBUFFERS_FN_DOUBLE("atan", atan(x));
1862 // TODO(wvo): add more useful conversion functions here.
1863 #undef FLATBUFFERS_FN_DOUBLE
1864 // clang-format on
1865 if (true != func_match) {
1866 return Error(std::string("Unknown conversion function: ") + functionname +
1867 ", field name: " + (name ? *name : "") +
1868 ", value: " + e.constant);
1869 }
1870 e.constant = NumToString(y);
1871 return NoError();
1872}
1873
1874CheckedError Parser::TryTypedValue(const std::string *name, int dtoken,
1875 bool check, Value &e, BaseType req,

Callers

nothing calls this directly

Calls 7

ErrorFunction · 0.85
atotFunction · 0.85
NumToStringFunction · 0.85
NoErrorFunction · 0.85
IsFloatFunction · 0.70
CheckMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected