bool object::instance_of(value constructor) const { root_object cons(constructor.to_object()); if (cons.is_null()) throw exception("Could not check instance constructor: " "constructor has to be a non-null object"); JSBool result; if (!JS_HasInstance( Impl::current_context(), Impl::get_object(cons), Impl::get_jsval(value(*this)), &result)) throw exception("Could not check instance constructor"); return result; }
static int get_byte(value byte_) { int byte; if (byte_.is_int()) { byte = byte_.get_int(); if (byte < 0 || byte > 255) throw exception("Byte is outside the valid range for bytes"); return byte; } object byte_o = byte_.to_object(); if (byte_o.is_null()) throw exception("Not a valid byte"); binary &byte_bin = flusspferd::get_native<binary>(byte_o); if (byte_bin.get_length() != 1) throw exception("Byte must not be a non single-element Binary"); byte = byte_bin.get_const_data()[0]; return byte; }
std::size_t convert_container_base::from_value::length(value obj_v) { array arr(obj_v.to_object()); return arr.length(); }
value convert_container_base::from_value::element(value obj_v, std::size_t i) { array arr(obj_v.to_object()); return arr.get_element(i); }
void convert_container_base::to_value::add(value obj, value el) { obj.to_object().call("push", el); }