From a546a67934d8fbc0b9851acc96e297c5ee14fd9a Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Aug 2015 07:59:44 +0200 Subject: [PATCH] Implement the 'base' field for the Type class fixes #9921 --- lib/base/type.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/base/type.cpp b/lib/base/type.cpp index b8058bb45..02c07939f 100644 --- a/lib/base/type.cpp +++ b/lib/base/type.cpp @@ -71,7 +71,7 @@ Object::Ptr Type::Instantiate(void) const ObjectFactory factory = GetFactory(); if (!factory) - return Object::Ptr(); + BOOST_THROW_EXCEPTION(std::runtime_error("Type does not have a factory function.")); return factory(); } @@ -115,6 +115,8 @@ Value Type::GetField(int id) const { if (id == 0) return GetPrototype(); + else if (id == 1) + return GetBaseType(); return Object::GetField(id); } @@ -148,6 +150,8 @@ int TypeType::GetFieldId(const String& name) const { if (name == "prototype") return 0; + else if (name == "base") + return 1; return -1; } @@ -156,13 +160,15 @@ Field TypeType::GetFieldInfo(int id) const { if (id == 0) return Field(0, "Object", "prototype", NULL, 0); + else if (id == 1) + return Field(1, "Object", "base", NULL, 0); throw std::runtime_error("Invalid field ID."); } int TypeType::GetFieldCount(void) const { - return 1; + return 2; } ObjectFactory TypeType::GetFactory(void) const -- 2.40.0