//////////////////////////////////////////////////////////////////////////// // // Copyright 2016 Realm Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////// #pragma once #include #include #include #include "js_types.hpp" namespace realm { namespace js { template using ConstructorType = void(typename T::Context, typename T::Object, size_t, const typename T::Value[]); template using MethodType = void(typename T::Context, typename T::Object, size_t, const typename T::Value[], ReturnValue &); template struct PropertyType { using GetterType = void(typename T::Context, typename T::Object, ReturnValue &); using SetterType = void(typename T::Context, typename T::Object, typename T::Value); typename T::PropertyGetterCallback getter; typename T::PropertySetterCallback setter; }; template struct IndexPropertyType { using GetterType = void(typename T::Context, typename T::Object, uint32_t, ReturnValue &); using SetterType = bool(typename T::Context, typename T::Object, uint32_t, typename T::Value); typename T::IndexPropertyGetterCallback getter; typename T::IndexPropertySetterCallback setter; }; template struct StringPropertyType { using GetterType = void(typename T::Context, typename T::Object, const String &, ReturnValue &); using SetterType = bool(typename T::Context, typename T::Object, const String &, typename T::Value); using EnumeratorType = std::vector>(typename T::Context, typename T::Object); typename T::StringPropertyGetterCallback getter; typename T::StringPropertySetterCallback setter; typename T::StringPropertyEnumeratorCallback enumerator; }; template using MethodMap = std::map; template using PropertyMap = std::map>; template struct ClassDefinition { using Internal = U; using Parent = V; // Every subclass *must* at least have a name. // std::string const name; // ClassDefinition specializations should inherit from this class and override what's needed below. ConstructorType* const constructor = nullptr; MethodMap const static_methods = {}; PropertyMap const static_properties = {}; MethodMap const methods = {}; PropertyMap const properties = {}; IndexPropertyType const index_accessor = {}; StringPropertyType const string_accessor = {}; }; template class ObjectWrap; } // js } // realm