fix: correct js_type/vtype mismatches and optimize fetch response methods
The codebase had a critical bug where js_type() (returns JS_* public
constants) was compared against T_* internal type constants in several
places. Since these enums have different values (e.g., JS_OBJ=9 vs T_OBJ=0),
comparisons would fail silently.
This caused:
- console.inspect() to show raw "<function rawtype=0 data=...>" instead of properly inspecting objects
- Function.prototype.bind() to not apply bound this for native functions (vtype compared against JS_UNDEF=0 instead of T_UNDEF=3)
The bind() bug led to workarounds like commit 52dd51e which replaced
js_getthis() with js_getcurrentfunc() + SLOT_DATA pattern throughout
the codebase to avoid relying on broken this binding.
Now that bind() works correctly, response.text() and response.json()
are updated to use js_getthis() + SLOT_DATA on the response object,
which is ~30% faster than the previous pattern (avoids function lookup
and slot traversal on the function object).
Changes:
- Fix vtype() vs js_type() mismatches across all modules
- Fix bound_this check in cfunc call path (T_UNDEF not JS_UNDEF)
- Optimize fetch response methods to use this binding
- Add T_CFUNC handling in console.inspect()