| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsScriptEnginePrerequisites.h"
- #include "BsScriptMeta.h"
- #include "BsMonoClass.h"
- namespace bs
- {
- /** Begins the definition for the builtin component lookup table. */
- #define LOOKUP_BEGIN \
- class BuiltinComponents \
- { \
- private: \
- struct META_FirstEntry {}; \
- static void META_GetPrevEntries(Vector<BuiltinComponentInfo>& entries, META_FirstEntry id) { } \
- \
- typedef META_FirstEntry
- /** Registers a new entry in the component lookup table. */
- #define ADD_ENTRY(ComponentType, ScriptType) \
- META_Entry_##ScriptType; \
- \
- public: \
- static ScriptComponentBase* create##ScriptType(const HComponent& component) \
- { \
- MonoObject* managedInstance = ScriptType::getMetaData()->scriptClass->createInstance(); \
- ScriptType* scriptComponent = new (bs_alloc<ScriptType>()) \
- ScriptType(managedInstance, static_object_cast<ComponentType>(component)); \
- \
- return scriptComponent; \
- } \
- \
- struct META_NextEntry_##ScriptType {}; \
- static void META_GetPrevEntries(Vector<BuiltinComponentInfo>& entries, META_NextEntry_##ScriptType id) \
- { \
- META_GetPrevEntries(entries, META_Entry_##ScriptType()); \
- \
- BuiltinComponentInfo entry; \
- entry.metaData = ScriptType::getMetaData(); \
- entry.typeId = ComponentType::getRTTIStatic()->getRTTIId(); \
- entry.monoClass = nullptr; \
- entry.createCallback = &create##ScriptType; \
- \
- entries.push_back(entry); \
- } \
- \
- typedef META_NextEntry_##ScriptType
- /** End the definition for the builtin component lookup table. */
- #define LOOKUP_END \
- META_LastEntry; \
- \
- public: \
- static Vector<BuiltinComponentInfo> getEntries() \
- { \
- Vector<BuiltinComponentInfo> entries; \
- META_GetPrevEntries(entries, META_LastEntry()); \
- return entries; \
- } \
- };
- }
|