mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-12 07:14:23 +00:00
Rename remained camelCase to snake_case
And fix some minor build warnings along the way.
This commit is contained in:
parent
60a3cd4399
commit
10f08747e7
@ -33,7 +33,7 @@ namespace realm {
|
||||
namespace js {
|
||||
|
||||
template<typename T>
|
||||
struct List {
|
||||
class List {
|
||||
using TContext = typename T::Context;
|
||||
using TObject = typename T::Object;
|
||||
using TValue = typename T::Value;
|
||||
@ -41,20 +41,23 @@ struct List {
|
||||
using Value = Value<T>;
|
||||
using ReturnValue = ReturnValue<T>;
|
||||
|
||||
public:
|
||||
static TObject create_instance(TContext, realm::List &);
|
||||
|
||||
static void GetLength(TContext, TObject, ReturnValue &);
|
||||
static void GetIndex(TContext, TObject, uint32_t, ReturnValue &);
|
||||
static bool SetIndex(TContext, TObject, uint32_t, TValue);
|
||||
// properties
|
||||
static void get_length(TContext, TObject, ReturnValue &);
|
||||
static void get_index(TContext, TObject, uint32_t, ReturnValue &);
|
||||
static bool set_index(TContext, TObject, uint32_t, TValue);
|
||||
|
||||
static void Push(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Pop(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Unshift(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Shift(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Splice(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void StaticResults(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Filtered(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Sorted(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
// methods
|
||||
static void push(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void pop(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void unshift(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void shift(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void splice(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void snapshot(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void filtered(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void sorted(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -64,21 +67,21 @@ struct ListClass : ClassDefinition<T, realm::List, CollectionClass<T>> {
|
||||
std::string const name = "List";
|
||||
|
||||
MethodMap<T> const methods = {
|
||||
{"push", wrap<List::Push>},
|
||||
{"pop", wrap<List::Pop>},
|
||||
{"unshift", wrap<List::Unshift>},
|
||||
{"shift", wrap<List::Shift>},
|
||||
{"splice", wrap<List::Splice>},
|
||||
{"snapshot", wrap<List::StaticResults>},
|
||||
{"filtered", wrap<List::Filtered>},
|
||||
{"sorted", wrap<List::Sorted>},
|
||||
{"push", wrap<List::push>},
|
||||
{"pop", wrap<List::pop>},
|
||||
{"unshift", wrap<List::unshift>},
|
||||
{"shift", wrap<List::shift>},
|
||||
{"splice", wrap<List::splice>},
|
||||
{"snapshot", wrap<List::snapshot>},
|
||||
{"filtered", wrap<List::filtered>},
|
||||
{"sorted", wrap<List::sorted>},
|
||||
};
|
||||
|
||||
PropertyMap<T> const properties = {
|
||||
{"length", {wrap<List::GetLength>}},
|
||||
{"length", {wrap<List::get_length>, nullptr}},
|
||||
};
|
||||
|
||||
IndexPropertyType<T> const index_accessor = {wrap<List::GetIndex>, wrap<List::SetIndex>};
|
||||
IndexPropertyType<T> const index_accessor = {wrap<List::get_index>, wrap<List::set_index>};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -87,13 +90,13 @@ typename T::Object List<T>::create_instance(TContext ctx, realm::List &list) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void List<T>::GetLength(TContext ctx, TObject object, ReturnValue &return_value) {
|
||||
void List<T>::get_length(TContext ctx, TObject object, ReturnValue &return_value) {
|
||||
auto list = get_internal<T, ListClass<T>>(object);
|
||||
return_value.set((uint32_t)list->size());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void List<T>::GetIndex(TContext ctx, TObject object, uint32_t index, ReturnValue &return_value) {
|
||||
void List<T>::get_index(TContext ctx, TObject object, uint32_t index, ReturnValue &return_value) {
|
||||
auto list = get_internal<T, ListClass<T>>(object);
|
||||
auto realm_object = realm::Object(list->get_realm(), list->get_object_schema(), list->get(index));
|
||||
|
||||
@ -101,14 +104,14 @@ void List<T>::GetIndex(TContext ctx, TObject object, uint32_t index, ReturnValue
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool List<T>::SetIndex(TContext ctx, TObject object, uint32_t index, TValue value) {
|
||||
bool List<T>::set_index(TContext ctx, TObject object, uint32_t index, TValue value) {
|
||||
auto list = get_internal<T, ListClass<T>>(object);
|
||||
list->set(ctx, value, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void List<T>::Push(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void List<T>::push(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count_at_least(argc, 1);
|
||||
|
||||
auto list = get_internal<T, ListClass<T>>(this_object);
|
||||
@ -120,7 +123,7 @@ void List<T>::Push(TContext ctx, TObject this_object, size_t argc, const TValue
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void List<T>::Pop(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void List<T>::pop(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 0);
|
||||
|
||||
auto list = get_internal<T, ListClass<T>>(this_object);
|
||||
@ -139,7 +142,7 @@ void List<T>::Pop(TContext ctx, TObject this_object, size_t argc, const TValue a
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void List<T>::Unshift(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void List<T>::unshift(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count_at_least(argc, 1);
|
||||
|
||||
auto list = get_internal<T, ListClass<T>>(this_object);
|
||||
@ -151,7 +154,7 @@ void List<T>::Unshift(TContext ctx, TObject this_object, size_t argc, const TVal
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void List<T>::Shift(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void List<T>::shift(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 0);
|
||||
|
||||
auto list = get_internal<T, ListClass<T>>(this_object);
|
||||
@ -168,7 +171,7 @@ void List<T>::Shift(TContext ctx, TObject this_object, size_t argc, const TValue
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void List<T>::Splice(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void List<T>::splice(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count_at_least(argc, 1);
|
||||
|
||||
auto list = get_internal<T, ListClass<T>>(this_object);
|
||||
@ -178,7 +181,7 @@ void List<T>::Splice(TContext ctx, TObject this_object, size_t argc, const TValu
|
||||
index = std::max<long>(size + index, 0);
|
||||
}
|
||||
|
||||
long remove;
|
||||
size_t remove;
|
||||
if (argc < 2) {
|
||||
remove = size - index;
|
||||
}
|
||||
@ -204,7 +207,7 @@ void List<T>::Splice(TContext ctx, TObject this_object, size_t argc, const TValu
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void List<T>::StaticResults(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void List<T>::snapshot(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 0);
|
||||
|
||||
auto list = get_internal<T, ListClass<T>>(this_object);
|
||||
@ -212,7 +215,7 @@ void List<T>::StaticResults(TContext ctx, TObject this_object, size_t argc, cons
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void List<T>::Filtered(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void List<T>::filtered(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count_at_least(argc, 1);
|
||||
|
||||
auto list = get_internal<T, ListClass<T>>(this_object);
|
||||
@ -220,7 +223,7 @@ void List<T>::Filtered(TContext ctx, TObject this_object, size_t argc, const TVa
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void List<T>::Sorted(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void List<T>::sorted(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 1, 2);
|
||||
|
||||
auto list = get_internal<T, ListClass<T>>(this_object);
|
||||
|
@ -29,7 +29,7 @@ namespace realm {
|
||||
namespace js {
|
||||
|
||||
template<typename T>
|
||||
struct RealmObject {
|
||||
class RealmObject {
|
||||
using TContext = typename T::Context;
|
||||
using TFunction = typename T::Function;
|
||||
using TObject = typename T::Object;
|
||||
@ -40,11 +40,12 @@ struct RealmObject {
|
||||
using Function = Function<T>;
|
||||
using ReturnValue = ReturnValue<T>;
|
||||
|
||||
public:
|
||||
static TObject create_instance(TContext, realm::Object &);
|
||||
|
||||
static void GetProperty(TContext, TObject, const String &, ReturnValue &);
|
||||
static bool SetProperty(TContext, TObject, const String &, TValue);
|
||||
static std::vector<String> GetPropertyNames(TContext, TObject);
|
||||
static void get_property(TContext, TObject, const String &, ReturnValue &);
|
||||
static bool set_property(TContext, TObject, const String &, TValue);
|
||||
static std::vector<String> get_property_names(TContext, TObject);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -54,15 +55,15 @@ struct RealmObjectClass : ClassDefinition<T, realm::Object> {
|
||||
const std::string name = "RealmObject";
|
||||
|
||||
const StringPropertyType<T> string_accessor = {
|
||||
wrap<RealmObject::GetProperty>,
|
||||
wrap<RealmObject::SetProperty>,
|
||||
wrap<RealmObject::GetPropertyNames>,
|
||||
wrap<RealmObject::get_property>,
|
||||
wrap<RealmObject::set_property>,
|
||||
wrap<RealmObject::get_property_names>,
|
||||
};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
typename T::Object RealmObject<T>::create_instance(TContext ctx, realm::Object &realm_object) {
|
||||
static String s_prototype = "prototype";
|
||||
static String prototype_string = "prototype";
|
||||
|
||||
auto delegate = get_delegate<T>(realm_object.realm().get());
|
||||
auto name = realm_object.get_object_schema().name;
|
||||
@ -73,7 +74,7 @@ typename T::Object RealmObject<T>::create_instance(TContext ctx, realm::Object &
|
||||
}
|
||||
|
||||
TFunction constructor = delegate->m_constructors.at(name);
|
||||
TObject prototype = Object::validated_get_object(ctx, constructor, s_prototype);
|
||||
TObject prototype = Object::validated_get_object(ctx, constructor, prototype_string);
|
||||
Object::set_prototype(ctx, object, prototype);
|
||||
|
||||
TValue result = Function::call(ctx, constructor, object, 0, NULL);
|
||||
@ -85,7 +86,7 @@ typename T::Object RealmObject<T>::create_instance(TContext ctx, realm::Object &
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void RealmObject<T>::GetProperty(TContext ctx, TObject object, const String &property, ReturnValue &return_value) {
|
||||
void RealmObject<T>::get_property(TContext ctx, TObject object, const String &property, ReturnValue &return_value) {
|
||||
try {
|
||||
auto realm_object = get_internal<T, RealmObjectClass<T>>(object);
|
||||
auto result = realm_object->template get_property_value<TValue>(ctx, property);
|
||||
@ -96,14 +97,14 @@ void RealmObject<T>::GetProperty(TContext ctx, TObject object, const String &pro
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool RealmObject<T>::SetProperty(TContext ctx, TObject object, const String &property, TValue value) {
|
||||
bool RealmObject<T>::set_property(TContext ctx, TObject object, const String &property, TValue value) {
|
||||
auto realm_object = get_internal<T, RealmObjectClass<T>>(object);
|
||||
realm_object->set_property_value(ctx, property, value, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<String<T>> RealmObject<T>::GetPropertyNames(TContext ctx, TObject object) {
|
||||
std::vector<String<T>> RealmObject<T>::get_property_names(TContext ctx, TObject object) {
|
||||
auto realm_object = get_internal<T, RealmObjectClass<T>>(object);
|
||||
auto &properties = realm_object->get_object_schema().properties;
|
||||
|
||||
|
@ -35,7 +35,7 @@ void set_default_path(std::string path) {
|
||||
s_default_path = path;
|
||||
}
|
||||
|
||||
void clear_test_state() {
|
||||
void delete_all_realms() {
|
||||
realm::_impl::RealmCoordinator::clear_all_caches();
|
||||
realm::remove_realm_files_from_directory(realm::default_realm_file_directory());
|
||||
}
|
||||
|
134
src/js_realm.hpp
134
src/js_realm.hpp
@ -113,7 +113,7 @@ class RealmDelegate : public BindingContext {
|
||||
|
||||
std::string default_path();
|
||||
void set_default_path(std::string path);
|
||||
void clear_test_state();
|
||||
void delete_all_realms();
|
||||
|
||||
template<typename T>
|
||||
class Realm {
|
||||
@ -128,44 +128,33 @@ class Realm {
|
||||
using NativeAccessor = realm::NativeAccessor<TValue, TContext>;
|
||||
|
||||
public:
|
||||
// member methods
|
||||
static void Objects(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Create(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Delete(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void DeleteAll(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Write(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void AddListener(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void RemoveListener(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void RemoveAllListeners(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Close(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static TFunction create_constructor(TContext);
|
||||
|
||||
// methods
|
||||
static void objects(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void create(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void delete_one(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void delete_all(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void write(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void add_listener(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void remove_listener(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void remove_all_listeners(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void close(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
|
||||
// properties
|
||||
static void GetPath(TContext, TObject, ReturnValue &);
|
||||
static void GetSchemaVersion(TContext, TObject, ReturnValue &);
|
||||
static void get_path(TContext, TObject, ReturnValue &);
|
||||
static void get_schema_version(TContext, TObject, ReturnValue &);
|
||||
|
||||
// constructor methods
|
||||
static void Constructor(TContext, TObject, size_t, const TValue[]);
|
||||
static void SchemaVersion(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void ClearTestState(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
// static methods
|
||||
static void constructor(TContext, TObject, size_t, const TValue[]);
|
||||
static void schema_version(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void clear_test_state(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
|
||||
// static properties
|
||||
static void GetDefaultPath(TContext, TObject, ReturnValue &);
|
||||
static void SetDefaultPath(TContext, TObject, TValue value);
|
||||
|
||||
static TFunction create_constructor(TContext ctx) {
|
||||
TFunction realm_constructor = ObjectWrap<T, RealmClass<T>>::create_constructor(ctx);
|
||||
TFunction collection_constructor = ObjectWrap<T, CollectionClass<T>>::create_constructor(ctx);
|
||||
TFunction list_constructor = ObjectWrap<T, ListClass<T>>::create_constructor(ctx);
|
||||
TFunction results_constructor = ObjectWrap<T, ResultsClass<T>>::create_constructor(ctx);
|
||||
|
||||
PropertyAttributes attributes = PropertyAttributes(ReadOnly | DontEnum | DontDelete);
|
||||
Object::set_property(ctx, realm_constructor, "Collection", collection_constructor, attributes);
|
||||
Object::set_property(ctx, realm_constructor, "List", list_constructor, attributes);
|
||||
Object::set_property(ctx, realm_constructor, "Results", results_constructor, attributes);
|
||||
|
||||
return realm_constructor;
|
||||
}
|
||||
static void get_default_path(TContext, TObject, ReturnValue &);
|
||||
static void set_default_path(TContext, TObject, TValue value);
|
||||
|
||||
private:
|
||||
static std::string validated_notification_name(TContext ctx, const TValue &value) {
|
||||
std::string name = Value::validated_to_string(ctx, value, "notification name");
|
||||
if (name != "change") {
|
||||
@ -204,37 +193,52 @@ struct RealmClass : ClassDefinition<T, SharedRealm> {
|
||||
|
||||
std::string const name = "Realm";
|
||||
|
||||
ConstructorType<T>* const constructor = Realm::Constructor;
|
||||
ConstructorType<T>* const constructor = Realm::constructor;
|
||||
|
||||
MethodMap<T> const static_methods = {
|
||||
{"schemaVersion", wrap<Realm::SchemaVersion>},
|
||||
{"clearTestState", wrap<Realm::ClearTestState>},
|
||||
{"schemaVersion", wrap<Realm::schema_version>},
|
||||
{"clearTestState", wrap<Realm::clear_test_state>},
|
||||
};
|
||||
|
||||
PropertyMap<T> const static_properties = {
|
||||
{"defaultPath", {wrap<Realm::GetDefaultPath>, wrap<Realm::SetDefaultPath>}},
|
||||
{"defaultPath", {wrap<Realm::get_default_path>, wrap<Realm::set_default_path>}},
|
||||
};
|
||||
|
||||
MethodMap<T> const methods = {
|
||||
{"objects", wrap<Realm::Objects>},
|
||||
{"create", wrap<Realm::Create>},
|
||||
{"delete", wrap<Realm::Delete>},
|
||||
{"deleteAll", wrap<Realm::DeleteAll>},
|
||||
{"write", wrap<Realm::Write>},
|
||||
{"addListener", wrap<Realm::AddListener>},
|
||||
{"removeListener", wrap<Realm::RemoveListener>},
|
||||
{"removeAllListeners", wrap<Realm::RemoveAllListeners>},
|
||||
{"close", wrap<Realm::Close>},
|
||||
{"objects", wrap<Realm::objects>},
|
||||
{"create", wrap<Realm::create>},
|
||||
{"delete", wrap<Realm::delete_one>},
|
||||
{"deleteAll", wrap<Realm::delete_all>},
|
||||
{"write", wrap<Realm::write>},
|
||||
{"addListener", wrap<Realm::add_listener>},
|
||||
{"removeListener", wrap<Realm::remove_listener>},
|
||||
{"removeAllListeners", wrap<Realm::remove_all_listeners>},
|
||||
{"close", wrap<Realm::close>},
|
||||
};
|
||||
|
||||
PropertyMap<T> const properties = {
|
||||
{"path", {wrap<Realm::GetPath>}},
|
||||
{"schemaVersion", {wrap<Realm::GetSchemaVersion>}},
|
||||
{"path", {wrap<Realm::get_path>, nullptr}},
|
||||
{"schemaVersion", {wrap<Realm::get_schema_version>, nullptr}},
|
||||
};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::Constructor(TContext ctx, TObject this_object, size_t argc, const TValue arguments[]) {
|
||||
inline typename T::Function Realm<T>::create_constructor(TContext ctx) {
|
||||
TFunction realm_constructor = ObjectWrap<T, RealmClass<T>>::create_constructor(ctx);
|
||||
TFunction collection_constructor = ObjectWrap<T, CollectionClass<T>>::create_constructor(ctx);
|
||||
TFunction list_constructor = ObjectWrap<T, ListClass<T>>::create_constructor(ctx);
|
||||
TFunction results_constructor = ObjectWrap<T, ResultsClass<T>>::create_constructor(ctx);
|
||||
|
||||
PropertyAttributes attributes = PropertyAttributes(ReadOnly | DontEnum | DontDelete);
|
||||
Object::set_property(ctx, realm_constructor, "Collection", collection_constructor, attributes);
|
||||
Object::set_property(ctx, realm_constructor, "List", list_constructor, attributes);
|
||||
Object::set_property(ctx, realm_constructor, "Results", results_constructor, attributes);
|
||||
|
||||
return realm_constructor;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::constructor(TContext ctx, TObject this_object, size_t argc, const TValue arguments[]) {
|
||||
static const String path_string = "path";
|
||||
static const String schema_string = "schema";
|
||||
static const String schema_version_string = "schemaVersion";
|
||||
@ -305,7 +309,7 @@ void Realm<T>::Constructor(TContext ctx, TObject this_object, size_t argc, const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::SchemaVersion(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::schema_version(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 1, 2);
|
||||
|
||||
realm::Realm::Config config;
|
||||
@ -326,35 +330,35 @@ void Realm<T>::SchemaVersion(TContext ctx, TObject this_object, size_t argc, con
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::ClearTestState(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::clear_test_state(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 0);
|
||||
clear_test_state();
|
||||
delete_all_realms();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::GetDefaultPath(TContext ctx, TObject object, ReturnValue &return_value) {
|
||||
void Realm<T>::get_default_path(TContext ctx, TObject object, ReturnValue &return_value) {
|
||||
return_value.set(realm::js::default_path());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::SetDefaultPath(TContext ctx, TObject object, TValue value) {
|
||||
void Realm<T>::set_default_path(TContext ctx, TObject object, TValue value) {
|
||||
js::set_default_path(Value::validated_to_string(ctx, value, "defaultPath"));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::GetPath(TContext ctx, TObject object, ReturnValue &return_value) {
|
||||
void Realm<T>::get_path(TContext ctx, TObject object, ReturnValue &return_value) {
|
||||
std::string path = get_internal<T, RealmClass<T>>(object)->get()->config().path;
|
||||
return_value.set(path);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::GetSchemaVersion(TContext ctx, TObject object, ReturnValue &return_value) {
|
||||
void Realm<T>::get_schema_version(TContext ctx, TObject object, ReturnValue &return_value) {
|
||||
double version = get_internal<T, RealmClass<T>>(object)->get()->config().schema_version;
|
||||
return_value.set(version);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::Objects(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::objects(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 1);
|
||||
|
||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
@ -364,7 +368,7 @@ void Realm<T>::Objects(TContext ctx, TObject this_object, size_t argc, const TVa
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::Create(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::create(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 2, 3);
|
||||
|
||||
SharedRealm sharedRealm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
@ -391,7 +395,7 @@ void Realm<T>::Create(TContext ctx, TObject this_object, size_t argc, const TVal
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::Delete(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::delete_one(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 1);
|
||||
|
||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
@ -434,7 +438,7 @@ void Realm<T>::Delete(TContext ctx, TObject this_object, size_t argc, const TVal
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::DeleteAll(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::delete_all(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 0);
|
||||
|
||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
@ -449,7 +453,7 @@ void Realm<T>::DeleteAll(TContext ctx, TObject this_object, size_t argc, const T
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::Write(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::write(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 1);
|
||||
|
||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
@ -469,7 +473,7 @@ void Realm<T>::Write(TContext ctx, TObject this_object, size_t argc, const TValu
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::AddListener(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::add_listener(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 2);
|
||||
|
||||
__unused std::string name = validated_notification_name(ctx, arguments[0]);
|
||||
@ -480,7 +484,7 @@ void Realm<T>::AddListener(TContext ctx, TObject this_object, size_t argc, const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::RemoveListener(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::remove_listener(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 2);
|
||||
|
||||
__unused std::string name = validated_notification_name(ctx, arguments[0]);
|
||||
@ -491,7 +495,7 @@ void Realm<T>::RemoveListener(TContext ctx, TObject this_object, size_t argc, co
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::RemoveAllListeners(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::remove_all_listeners(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 0, 1);
|
||||
if (argc) {
|
||||
validated_notification_name(ctx, arguments[0]);
|
||||
@ -502,7 +506,7 @@ void Realm<T>::RemoveAllListeners(TContext ctx, TObject this_object, size_t argc
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Realm<T>::Close(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Realm<T>::close(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 0);
|
||||
|
||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
|
@ -30,7 +30,7 @@ namespace realm {
|
||||
namespace js {
|
||||
|
||||
template<typename T>
|
||||
struct Results {
|
||||
class Results {
|
||||
using TContext = typename T::Context;
|
||||
using TObject = typename T::Object;
|
||||
using TValue = typename T::Value;
|
||||
@ -38,6 +38,7 @@ struct Results {
|
||||
using Value = Value<T>;
|
||||
using ReturnValue = ReturnValue<T>;
|
||||
|
||||
public:
|
||||
static TObject create_instance(TContext, const realm::Results &, bool live = true);
|
||||
static TObject create_instance(TContext, const realm::List &, bool live = true);
|
||||
static TObject create_instance(TContext, SharedRealm, const std::string &type, bool live = true);
|
||||
@ -49,12 +50,12 @@ struct Results {
|
||||
template<typename U>
|
||||
static TObject create_sorted(TContext, const U &, size_t, const TValue[]);
|
||||
|
||||
static void GetLength(TContext, TObject, ReturnValue &);
|
||||
static void GetIndex(TContext, TObject, uint32_t, ReturnValue &);
|
||||
static void get_length(TContext, TObject, ReturnValue &);
|
||||
static void get_index(TContext, TObject, uint32_t, ReturnValue &);
|
||||
|
||||
static void StaticResults(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Filtered(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void Sorted(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void snapshot(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void filtered(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
static void sorted(TContext, TObject, size_t, const TValue[], ReturnValue &);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -64,16 +65,16 @@ struct ResultsClass : ClassDefinition<T, realm::Results, CollectionClass<T>> {
|
||||
std::string const name = "Results";
|
||||
|
||||
MethodMap<T> const methods = {
|
||||
{"snapshot", wrap<Results::StaticResults>},
|
||||
{"filtered", wrap<Results::Filtered>},
|
||||
{"sorted", wrap<Results::Sorted>},
|
||||
{"snapshot", wrap<Results::snapshot>},
|
||||
{"filtered", wrap<Results::filtered>},
|
||||
{"sorted", wrap<Results::sorted>},
|
||||
};
|
||||
|
||||
PropertyMap<T> const properties = {
|
||||
{"length", {wrap<Results::GetLength>}},
|
||||
{"length", {wrap<Results::get_length>, nullptr}},
|
||||
};
|
||||
|
||||
IndexPropertyType<T> const index_accessor = {wrap<Results::GetIndex>};
|
||||
IndexPropertyType<T> const index_accessor = {wrap<Results::get_index>, nullptr};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -194,13 +195,13 @@ typename T::Object Results<T>::create_sorted(TContext ctx, const U &collection,
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Results<T>::GetLength(TContext ctx, TObject object, ReturnValue &return_value) {
|
||||
void Results<T>::get_length(TContext ctx, TObject object, ReturnValue &return_value) {
|
||||
auto results = get_internal<T, ResultsClass<T>>(object);
|
||||
return_value.set((uint32_t)results->size());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Results<T>::GetIndex(TContext ctx, TObject object, uint32_t index, ReturnValue &return_value) {
|
||||
void Results<T>::get_index(TContext ctx, TObject object, uint32_t index, ReturnValue &return_value) {
|
||||
auto results = get_internal<T, ResultsClass<T>>(object);
|
||||
auto row = results->get(index);
|
||||
|
||||
@ -215,7 +216,7 @@ void Results<T>::GetIndex(TContext ctx, TObject object, uint32_t index, ReturnVa
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Results<T>::StaticResults(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Results<T>::snapshot(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 0);
|
||||
|
||||
auto results = get_internal<T, ResultsClass<T>>(this_object);
|
||||
@ -223,7 +224,7 @@ void Results<T>::StaticResults(TContext ctx, TObject this_object, size_t argc, c
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Results<T>::Filtered(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Results<T>::filtered(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count_at_least(argc, 1);
|
||||
|
||||
auto results = get_internal<T, ResultsClass<T>>(this_object);
|
||||
@ -231,7 +232,7 @@ void Results<T>::Filtered(TContext ctx, TObject this_object, size_t argc, const
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Results<T>::Sorted(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
void Results<T>::sorted(TContext ctx, TObject this_object, size_t argc, const TValue arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 1, 2);
|
||||
|
||||
auto results = get_internal<T, ResultsClass<T>>(this_object);
|
||||
|
@ -65,26 +65,26 @@ typename T::Object Schema<T>::dict_for_property_array(TContext ctx, const Object
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Property Schema<T>::parse_property(TContext ctx, TValue attributes, std::string propertyName, ObjectDefaults &objectDefaults) {
|
||||
static const String defaultString = "default";
|
||||
static const String indexedString = "indexed";
|
||||
static const String typeString = "type";
|
||||
static const String objectTypeString = "objectType";
|
||||
static const String optionalString = "optional";
|
||||
Property Schema<T>::parse_property(TContext ctx, TValue attributes, std::string property_name, ObjectDefaults &object_defaults) {
|
||||
static const String default_string = "default";
|
||||
static const String indexed_string = "indexed";
|
||||
static const String type_string = "type";
|
||||
static const String object_type_string = "objectType";
|
||||
static const String optional_string = "optional";
|
||||
|
||||
Property prop;
|
||||
prop.name = propertyName;
|
||||
prop.name = property_name;
|
||||
|
||||
TObject propertyObject = {};
|
||||
TObject property_object = {};
|
||||
std::string type;
|
||||
|
||||
if (Value::is_object(ctx, attributes)) {
|
||||
propertyObject = Value::validated_to_object(ctx, attributes);
|
||||
type = Object::validated_get_string(ctx, propertyObject, typeString);
|
||||
property_object = Value::validated_to_object(ctx, attributes);
|
||||
type = Object::validated_get_string(ctx, property_object, type_string);
|
||||
|
||||
TValue optionalValue = Object::get_property(ctx, propertyObject, optionalString);
|
||||
if (!Value::is_undefined(ctx, optionalValue)) {
|
||||
prop.is_nullable = Value::validated_to_boolean(ctx, optionalValue, "optional");
|
||||
TValue optional_value = Object::get_property(ctx, property_object, optional_string);
|
||||
if (!Value::is_undefined(ctx, optional_value)) {
|
||||
prop.is_nullable = Value::validated_to_boolean(ctx, optional_value, "optional");
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -113,11 +113,11 @@ Property Schema<T>::parse_property(TContext ctx, TValue attributes, std::string
|
||||
prop.type = PropertyTypeData;
|
||||
}
|
||||
else if (type == "list") {
|
||||
if (!Value::is_valid(propertyObject)) {
|
||||
if (!Value::is_valid(property_object)) {
|
||||
throw std::runtime_error("List property must specify 'objectType'");
|
||||
}
|
||||
prop.type = PropertyTypeArray;
|
||||
prop.object_type = Object::validated_get_string(ctx, propertyObject, objectTypeString);
|
||||
prop.object_type = Object::validated_get_string(ctx, property_object, object_type_string);
|
||||
}
|
||||
else {
|
||||
prop.type = PropertyTypeObject;
|
||||
@ -125,25 +125,25 @@ Property Schema<T>::parse_property(TContext ctx, TValue attributes, std::string
|
||||
|
||||
// The type could either be 'object' or the name of another object type in the same schema.
|
||||
if (type == "object") {
|
||||
if (!Value::is_valid(propertyObject)) {
|
||||
if (!Value::is_valid(property_object)) {
|
||||
throw std::runtime_error("Object property must specify 'objectType'");
|
||||
}
|
||||
prop.object_type = Object::validated_get_string(ctx, propertyObject, objectTypeString);
|
||||
prop.object_type = Object::validated_get_string(ctx, property_object, object_type_string);
|
||||
}
|
||||
else {
|
||||
prop.object_type = type;
|
||||
}
|
||||
}
|
||||
|
||||
if (Value::is_valid(propertyObject)) {
|
||||
TValue defaultValue = Object::get_property(ctx, propertyObject, defaultString);
|
||||
if (!Value::is_undefined(ctx, defaultValue)) {
|
||||
objectDefaults.emplace(prop.name, Protected<TValue>(ctx, defaultValue));
|
||||
if (Value::is_valid(property_object)) {
|
||||
TValue default_value = Object::get_property(ctx, property_object, default_string);
|
||||
if (!Value::is_undefined(ctx, default_value)) {
|
||||
object_defaults.emplace(prop.name, Protected<TValue>(ctx, default_value));
|
||||
}
|
||||
|
||||
TValue indexedValue = Object::get_property(ctx, propertyObject, indexedString);
|
||||
if (!Value::is_undefined(ctx, indexedValue)) {
|
||||
prop.is_indexed = Value::validated_to_boolean(ctx, indexedValue);
|
||||
TValue indexed_value = Object::get_property(ctx, property_object, indexed_string);
|
||||
if (!Value::is_undefined(ctx, indexed_value)) {
|
||||
prop.is_indexed = Value::validated_to_boolean(ctx, indexed_value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,68 +151,68 @@ Property Schema<T>::parse_property(TContext ctx, TValue attributes, std::string
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ObjectSchema Schema<T>::parse_object_schema(TContext ctx, TObject objectSchemaObject, ObjectDefaultsMap &defaults, ConstructorMap &constructors) {
|
||||
static const String nameString = "name";
|
||||
static const String primaryString = "primaryKey";
|
||||
static const String propertiesString = "properties";
|
||||
static const String schemaString = "schema";
|
||||
ObjectSchema Schema<T>::parse_object_schema(TContext ctx, TObject object_schema_object, ObjectDefaultsMap &defaults, ConstructorMap &constructors) {
|
||||
static const String name_string = "name";
|
||||
static const String primary_string = "primaryKey";
|
||||
static const String properties_string = "properties";
|
||||
static const String schema_string = "schema";
|
||||
|
||||
TFunction objectConstructor = {};
|
||||
if (Value::is_constructor(ctx, objectSchemaObject)) {
|
||||
objectConstructor = Value::to_constructor(ctx, objectSchemaObject);
|
||||
objectSchemaObject = Object::validated_get_object(ctx, objectConstructor, schemaString, "Realm object constructor must have a 'schema' property.");
|
||||
TFunction object_constructor = {};
|
||||
if (Value::is_constructor(ctx, object_schema_object)) {
|
||||
object_constructor = Value::to_constructor(ctx, object_schema_object);
|
||||
object_schema_object = Object::validated_get_object(ctx, object_constructor, schema_string, "Realm object constructor must have a 'schema' property.");
|
||||
}
|
||||
|
||||
ObjectDefaults objectDefaults;
|
||||
ObjectSchema objectSchema;
|
||||
objectSchema.name = Object::validated_get_string(ctx, objectSchemaObject, nameString);
|
||||
ObjectDefaults object_defaults;
|
||||
ObjectSchema object_schema;
|
||||
object_schema.name = Object::validated_get_string(ctx, object_schema_object, name_string);
|
||||
|
||||
TObject propertiesObject = Object::validated_get_object(ctx, objectSchemaObject, propertiesString, "ObjectSchema must have a 'properties' object.");
|
||||
if (Value::is_array(ctx, propertiesObject)) {
|
||||
uint32_t length = Object::validated_get_length(ctx, propertiesObject);
|
||||
TObject properties_object = Object::validated_get_object(ctx, object_schema_object, properties_string, "ObjectSchema must have a 'properties' object.");
|
||||
if (Value::is_array(ctx, properties_object)) {
|
||||
uint32_t length = Object::validated_get_length(ctx, properties_object);
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
TObject propertyObject = Object::validated_get_object(ctx, propertiesObject, i);
|
||||
std::string propertyName = Object::validated_get_string(ctx, propertyObject, nameString);
|
||||
objectSchema.properties.emplace_back(parse_property(ctx, propertyObject, propertyName, objectDefaults));
|
||||
TObject property_object = Object::validated_get_object(ctx, properties_object, i);
|
||||
std::string property_name = Object::validated_get_string(ctx, property_object, name_string);
|
||||
object_schema.properties.emplace_back(parse_property(ctx, property_object, property_name, object_defaults));
|
||||
}
|
||||
}
|
||||
else {
|
||||
auto propertyNames = Object::get_property_names(ctx, propertiesObject);
|
||||
for (auto &propertyName : propertyNames) {
|
||||
TValue propertyValue = Object::get_property(ctx, propertiesObject, propertyName);
|
||||
objectSchema.properties.emplace_back(parse_property(ctx, propertyValue, propertyName, objectDefaults));
|
||||
auto property_names = Object::get_property_names(ctx, properties_object);
|
||||
for (auto &property_name : property_names) {
|
||||
TValue property_value = Object::get_property(ctx, properties_object, property_name);
|
||||
object_schema.properties.emplace_back(parse_property(ctx, property_value, property_name, object_defaults));
|
||||
}
|
||||
}
|
||||
|
||||
TValue primaryValue = Object::get_property(ctx, objectSchemaObject, primaryString);
|
||||
if (!Value::is_undefined(ctx, primaryValue)) {
|
||||
objectSchema.primary_key = Value::validated_to_string(ctx, primaryValue);
|
||||
Property *property = objectSchema.primary_key_property();
|
||||
TValue primary_value = Object::get_property(ctx, object_schema_object, primary_string);
|
||||
if (!Value::is_undefined(ctx, primary_value)) {
|
||||
object_schema.primary_key = Value::validated_to_string(ctx, primary_value);
|
||||
Property *property = object_schema.primary_key_property();
|
||||
if (!property) {
|
||||
throw std::runtime_error("Missing primary key property '" + objectSchema.primary_key + "'");
|
||||
throw std::runtime_error("Missing primary key property '" + object_schema.primary_key + "'");
|
||||
}
|
||||
property->is_primary = true;
|
||||
}
|
||||
|
||||
// Store prototype so that objects of this type will have their prototype set to this prototype object.
|
||||
if (Value::is_valid(objectConstructor)) {
|
||||
constructors.emplace(objectSchema.name, Protected<TFunction>(ctx, objectConstructor));
|
||||
if (Value::is_valid(object_constructor)) {
|
||||
constructors.emplace(object_schema.name, Protected<TFunction>(ctx, object_constructor));
|
||||
}
|
||||
|
||||
defaults.emplace(objectSchema.name, std::move(objectDefaults));
|
||||
defaults.emplace(object_schema.name, std::move(object_defaults));
|
||||
|
||||
return objectSchema;
|
||||
return object_schema;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
realm::Schema Schema<T>::parse_schema(TContext ctx, TObject jsonObject, ObjectDefaultsMap &defaults, ConstructorMap &constructors) {
|
||||
realm::Schema Schema<T>::parse_schema(TContext ctx, TObject schema_object, ObjectDefaultsMap &defaults, ConstructorMap &constructors) {
|
||||
std::vector<ObjectSchema> schema;
|
||||
uint32_t length = Object::validated_get_length(ctx, jsonObject);
|
||||
uint32_t length = Object::validated_get_length(ctx, schema_object);
|
||||
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
TObject jsonObjectSchema = Object::validated_get_object(ctx, jsonObject, i);
|
||||
ObjectSchema objectSchema = parse_object_schema(ctx, jsonObjectSchema, defaults, constructors);
|
||||
schema.emplace_back(std::move(objectSchema));
|
||||
TObject object_schema_object = Object::validated_get_object(ctx, schema_object, i);
|
||||
ObjectSchema object_schema = parse_object_schema(ctx, object_schema_object, defaults, constructors);
|
||||
schema.emplace_back(std::move(object_schema));
|
||||
}
|
||||
|
||||
return realm::Schema(schema);
|
||||
|
@ -25,9 +25,6 @@
|
||||
|
||||
#include "jsc_init.hpp"
|
||||
#include "jsc_types.hpp"
|
||||
#include "js_object.hpp"
|
||||
#include "js_results.hpp"
|
||||
#include "js_realm.hpp"
|
||||
|
||||
#include "base64.hpp"
|
||||
#include "object_accessor.hpp"
|
||||
@ -166,7 +163,7 @@ RPCServer::RPCServer() {
|
||||
m_objects.erase(object.first);
|
||||
}
|
||||
JSGarbageCollect(m_context);
|
||||
js::clear_test_state();
|
||||
js::delete_all_realms();
|
||||
return json::object();
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user