MCPcopy Create free account
hub / github.com/GNOME/gjs / to_string_impl

Method to_string_impl

gi/function.cpp:1235–1262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1233}
1234
1235bool Function::to_string_impl(JSContext* cx, JS::MutableHandleValue rval) {
1236 int n_args = m_info.n_args();
1237 std::string arg_names;
1238 for (int i = 0, n_jsargs = 0; i < n_args; i++) {
1239 Argument* gjs_arg = m_arguments.argument(i);
1240 if (!gjs_arg || gjs_arg->skip_in())
1241 continue;
1242
1243 if (n_jsargs > 0)
1244 arg_names += ", ";
1245
1246 n_jsargs++;
1247 arg_names += gjs_arg->arg_name();
1248 }
1249
1250 AutoChar descr;
1251 if (auto func_info = m_info.as<GI::InfoTag::FUNCTION>()) {
1252 descr = g_strdup_printf(
1253 "%s(%s) {\n\t/* wrapper for native symbol %s() */\n}",
1254 format_name().c_str(), arg_names.c_str(), func_info->symbol());
1255 } else {
1256 descr =
1257 g_strdup_printf("%s(%s) {\n\t/* wrapper for native symbol */\n}",
1258 format_name().c_str(), arg_names.c_str());
1259 }
1260
1261 return gjs_string_from_utf8(cx, descr, rval);
1262}
1263
1264const JSClassOps Function::class_ops = {
1265 nullptr, // addProperty

Callers 1

to_stringMethod · 0.80

Calls 6

gjs_string_from_utf8Function · 0.85
n_argsMethod · 0.80
argumentMethod · 0.80
skip_inMethod · 0.80
arg_nameMethod · 0.80
symbolMethod · 0.80

Tested by

no test coverage detected