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

Method new_enumerate_impl

gi/object.cpp:1973–2049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1971}
1972
1973bool ObjectPrototype::new_enumerate_impl(JSContext* cx, JS::HandleObject,
1974 JS::MutableHandleIdVector properties,
1975 bool only_enumerable
1976 [[maybe_unused]]) {
1977 unsigned n_interfaces;
1978 Gjs::AutoFree<GType> interfaces{g_type_interfaces(gtype(), &n_interfaces)};
1979 GI::Repository repo;
1980
1981 for (unsigned k = 0; k < n_interfaces; k++) {
1982 Maybe<GI::AutoInterfaceInfo> iface_info{
1983 repo.find_by_gtype<GI::InfoTag::INTERFACE>(interfaces[k])};
1984 if (!iface_info)
1985 continue;
1986
1987 GI::InterfaceInfo::MethodsIterator meth_iter = iface_info->methods();
1988 GI::InterfaceInfo::PropertiesIterator props_iter =
1989 iface_info->properties();
1990 if (!properties.reserve(properties.length() + meth_iter.size() +
1991 props_iter.size())) {
1992 JS_ReportOutOfMemory(cx);
1993 return false;
1994 }
1995
1996 // Methods
1997 for (GI::AutoFunctionInfo meth_info : meth_iter) {
1998 if (meth_info.is_method()) {
1999 const char* name = meth_info.name();
2000 jsid id = gjs_intern_string_to_id(cx, name);
2001 if (id.isVoid())
2002 return false;
2003 properties.infallibleAppend(id);
2004 }
2005 }
2006
2007 // Properties
2008 for (GI::AutoPropertyInfo prop_info : props_iter) {
2009 Gjs::AutoChar js_name{gjs_hyphen_to_underscore(prop_info.name())};
2010
2011 jsid id = gjs_intern_string_to_id(cx, js_name);
2012 if (id.isVoid())
2013 return false;
2014 properties.infallibleAppend(id);
2015 }
2016 }
2017
2018 if (info()) {
2019 GI::ObjectInfo::MethodsIterator meth_iter = info()->methods();
2020 GI::ObjectInfo::PropertiesIterator props_iter = info()->properties();
2021 if (!properties.reserve(properties.length() + meth_iter.size() +
2022 props_iter.size())) {
2023 JS_ReportOutOfMemory(cx);
2024 return false;
2025 }
2026
2027 // Methods
2028 for (GI::AutoFunctionInfo meth_info : meth_iter) {
2029 if (meth_info.is_method()) {
2030 const char* name = meth_info.name();

Callers

nothing calls this directly

Calls 9

gjs_intern_string_to_idFunction · 0.85
gjs_hyphen_to_underscoreFunction · 0.85
infoFunction · 0.85
lengthMethod · 0.80
methodsMethod · 0.45
propertiesMethod · 0.45
sizeMethod · 0.45
is_methodMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected