mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
Merge pull request #2228 from lukaspj/fix-enginexmlexport
Make EngineAPI Export work properly
This commit is contained in:
commit
e0591ddd2f
5 changed files with 577 additions and 364 deletions
|
|
@ -663,6 +663,29 @@ public:
|
||||||
T::initPersistFields();
|
T::initPersistFields();
|
||||||
T::consoleInit();
|
T::consoleInit();
|
||||||
|
|
||||||
|
EnginePropertyTable::Property* props = new EnginePropertyTable::Property[sg_tempFieldList.size()];
|
||||||
|
|
||||||
|
for (int i = 0; i < sg_tempFieldList.size(); ++i)
|
||||||
|
{
|
||||||
|
EnginePropertyTable::Property prop;
|
||||||
|
prop.mDocString = sg_tempFieldList[i].pFieldDocs;
|
||||||
|
prop.mName = sg_tempFieldList[i].pFieldname;
|
||||||
|
prop.mNumElements = sg_tempFieldList[i].elementCount;
|
||||||
|
prop.mFlags = 0;
|
||||||
|
if (sg_tempFieldList[i].type == StartGroupFieldType)
|
||||||
|
prop.mFlags |= EnginePropertyGroupBegin;
|
||||||
|
if (sg_tempFieldList[i].type == EndGroupFieldType)
|
||||||
|
prop.mFlags |= EnginePropertyGroupEnd;
|
||||||
|
prop.mType = sg_tempFieldList[i].type;
|
||||||
|
|
||||||
|
props[i] = prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
_smPropertyTable = EnginePropertyTable(sg_tempFieldList.size(), props);
|
||||||
|
smPropertyTable = _smPropertyTable;
|
||||||
|
|
||||||
|
const_cast<EngineTypeInfo*>(mTypeInfo)->mPropertyTable = &_smPropertyTable;
|
||||||
|
|
||||||
// Let the base finish up.
|
// Let the base finish up.
|
||||||
AbstractClassRep::init();
|
AbstractClassRep::init();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,10 @@
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
|
#ifndef _FIXEDTUPLE_H_
|
||||||
|
#include "fixedTuple.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _ENGINEEXPORTS_H_
|
#ifndef _ENGINEEXPORTS_H_
|
||||||
#include "console/engineExports.h"
|
#include "console/engineExports.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -94,6 +98,7 @@ template<typename ...ArgTs>
|
||||||
struct _EngineFunctionDefaultArguments< void(ArgTs...) > : public EngineFunctionDefaultArguments
|
struct _EngineFunctionDefaultArguments< void(ArgTs...) > : public EngineFunctionDefaultArguments
|
||||||
{
|
{
|
||||||
template<typename T> using DefVST = typename EngineTypeTraits<T>::DefaultArgumentValueStoreType;
|
template<typename T> using DefVST = typename EngineTypeTraits<T>::DefaultArgumentValueStoreType;
|
||||||
|
fixed_tuple<DefVST<ArgTs> ...> mFixedArgs;
|
||||||
std::tuple<DefVST<ArgTs> ...> mArgs;
|
std::tuple<DefVST<ArgTs> ...> mArgs;
|
||||||
private:
|
private:
|
||||||
using SelfType = _EngineFunctionDefaultArguments< void(ArgTs...) >;
|
using SelfType = _EngineFunctionDefaultArguments< void(ArgTs...) >;
|
||||||
|
|
@ -130,7 +135,9 @@ private:
|
||||||
public:
|
public:
|
||||||
template<typename ...TailTs> _EngineFunctionDefaultArguments(TailTs ...tail)
|
template<typename ...TailTs> _EngineFunctionDefaultArguments(TailTs ...tail)
|
||||||
: EngineFunctionDefaultArguments({sizeof...(TailTs)}), mArgs(SelfType::tailInit(tail...))
|
: EngineFunctionDefaultArguments({sizeof...(TailTs)}), mArgs(SelfType::tailInit(tail...))
|
||||||
{}
|
{
|
||||||
|
fixed_tuple_mutator<void(DefVST<ArgTs>...), void(DefVST<ArgTs>...)>::copy(mArgs, mFixedArgs);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack( pop )
|
#pragma pack( pop )
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,9 @@ class EnginePropertyTable
|
||||||
/// Combination of EnginePropertyFlags.
|
/// Combination of EnginePropertyFlags.
|
||||||
U32 mFlags;
|
U32 mFlags;
|
||||||
|
|
||||||
|
/// Type-id of the property
|
||||||
|
U32 mType;
|
||||||
|
|
||||||
/// Return the name of the property.
|
/// Return the name of the property.
|
||||||
const char* getName() const { return mName; }
|
const char* getName() const { return mName; }
|
||||||
|
|
||||||
|
|
@ -255,6 +258,9 @@ class EnginePropertyTable
|
||||||
|
|
||||||
///
|
///
|
||||||
bool hideInInspectors() const { return ( mFlags & EnginePropertyHideInInspectors ); }
|
bool hideInInspectors() const { return ( mFlags & EnginePropertyHideInInspectors ); }
|
||||||
|
|
||||||
|
/// Return the type-id of the property.
|
||||||
|
U32 getType() const { return mType; }
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ static String getDefaultArgumentValue( const EngineFunctionInfo* function, const
|
||||||
//TODO: for now we store string literals in ASCII; needs to be sorted out
|
//TODO: for now we store string literals in ASCII; needs to be sorted out
|
||||||
if (TYPE< const char* >() == type)
|
if (TYPE< const char* >() == type)
|
||||||
{
|
{
|
||||||
const char* val = getArgValue< const char* >( defaultArgs, offset );
|
const char* val = reinterpret_cast<const char*>(defaultArgs->getArgs() + offset);
|
||||||
value = val;
|
value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -467,6 +467,10 @@ static void exportType( const EngineTypeInfo* type, SimXMLDocument* xml )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (property.getType() == AbstractClassRep::StartArrayFieldType
|
||||||
|
|| property.getType() == AbstractClassRep::EndArrayFieldType) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
xml->pushNewElement("EngineProperty");
|
xml->pushNewElement("EngineProperty");
|
||||||
|
|
||||||
xml->setAttribute("name", property.getName());
|
xml->setAttribute("name", property.getName());
|
||||||
|
|
@ -476,6 +480,26 @@ static void exportType( const EngineTypeInfo* type, SimXMLDocument* xml )
|
||||||
xml->setAttribute("isVisible", property.hideInInspectors() ? "0" : "1");
|
xml->setAttribute("isVisible", property.hideInInspectors() ? "0" : "1");
|
||||||
xml->setAttribute("docs", property.getDocString() ? property.getDocString() : "");
|
xml->setAttribute("docs", property.getDocString() ? property.getDocString() : "");
|
||||||
|
|
||||||
|
|
||||||
|
const bool isDeprecated = (property.getType() == AbstractClassRep::DeprecatedFieldType);
|
||||||
|
|
||||||
|
if (isDeprecated)
|
||||||
|
{
|
||||||
|
xml->setAttribute("type", "deprecated");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConsoleBaseType *cbt = ConsoleBaseType::getType(property.getType());
|
||||||
|
if (cbt != NULL)
|
||||||
|
{
|
||||||
|
xml->setAttribute("type", cbt->getTypeClassName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xml->setAttribute("type", "unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xml->popElement();
|
xml->popElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
153
Engine/source/console/fixedTuple.h
Normal file
153
Engine/source/console/fixedTuple.h
Normal file
|
|
@ -0,0 +1,153 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2012 GarageGames, LLC
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to
|
||||||
|
// deal in the Software without restriction, including without limitation the
|
||||||
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
// sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
// IN THE SOFTWARE.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef _FIXEDTUPLE_H_
|
||||||
|
#define _FIXEDTUPLE_H_
|
||||||
|
/// @name Fixed-layout tuple definition
|
||||||
|
/// These structs and templates serve as a way to pass arguments from external
|
||||||
|
/// applications and into the T3D console system.
|
||||||
|
/// They work as std::tuple, but they ensure a standardized fixed memory
|
||||||
|
/// layout. Allowing for unmanaged calls with these tuples as the parameter
|
||||||
|
/// lists.
|
||||||
|
///
|
||||||
|
/// The implementation is from a SO solution:
|
||||||
|
/// https://codereview.stackexchange.com/a/52279
|
||||||
|
/// As out use-case is pretty simple, this code could probably be simplified by
|
||||||
|
/// stripping out a lot of extra functionality. But eh.
|
||||||
|
///
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
template <typename ...Ts>
|
||||||
|
struct fixed_tuple;
|
||||||
|
|
||||||
|
template <typename T, typename ...Ts>
|
||||||
|
struct fixed_tuple<T, Ts...>
|
||||||
|
{
|
||||||
|
T first;
|
||||||
|
fixed_tuple<Ts...> rest;
|
||||||
|
|
||||||
|
fixed_tuple() = default;
|
||||||
|
template <class U, class...Us, class = typename ::std::enable_if<!::std::is_base_of<fixed_tuple, typename ::std::decay<U>::type>::value>::type>
|
||||||
|
fixed_tuple(U&& u, Us&&...tail) :
|
||||||
|
first(::std::forward<U>(u)),
|
||||||
|
rest(::std::forward<Us>(tail)...) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct fixed_tuple<T>
|
||||||
|
{
|
||||||
|
T first;
|
||||||
|
|
||||||
|
fixed_tuple() = default;
|
||||||
|
template <class U, class = typename ::std::enable_if<!::std::is_base_of<fixed_tuple, typename ::std::decay<U>::type>::value>::type>
|
||||||
|
fixed_tuple(U&& u) :
|
||||||
|
first(::std::forward<U>(u)) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct fixed_tuple<> {};
|
||||||
|
|
||||||
|
|
||||||
|
template < ::std::size_t i, class T>
|
||||||
|
struct fixed_tuple_element;
|
||||||
|
|
||||||
|
template < ::std::size_t i, class T, class... Ts>
|
||||||
|
struct fixed_tuple_element<i, fixed_tuple<T, Ts...> >
|
||||||
|
: fixed_tuple_element<i - 1, fixed_tuple<Ts...> >
|
||||||
|
{};
|
||||||
|
|
||||||
|
template <class T, class... Ts>
|
||||||
|
struct fixed_tuple_element<0, fixed_tuple<T, Ts...> >
|
||||||
|
{
|
||||||
|
using type = T;
|
||||||
|
};
|
||||||
|
|
||||||
|
template < ::std::size_t i>
|
||||||
|
struct fixed_tuple_accessor
|
||||||
|
{
|
||||||
|
template <class... Ts>
|
||||||
|
static inline typename fixed_tuple_element<i, fixed_tuple<Ts...> >::type & get(fixed_tuple<Ts...> & t)
|
||||||
|
{
|
||||||
|
return fixed_tuple_accessor<i - 1>::get(t.rest);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class... Ts>
|
||||||
|
static inline const typename fixed_tuple_element<i, fixed_tuple<Ts...> >::type & get(const fixed_tuple<Ts...> & t)
|
||||||
|
{
|
||||||
|
return fixed_tuple_accessor<i - 1>::get(t.rest);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct fixed_tuple_accessor<0>
|
||||||
|
{
|
||||||
|
template <class... Ts>
|
||||||
|
static inline typename fixed_tuple_element<0, fixed_tuple<Ts...> >::type & get(fixed_tuple<Ts...> & t)
|
||||||
|
{
|
||||||
|
return t.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class... Ts>
|
||||||
|
static inline const typename fixed_tuple_element<0, fixed_tuple<Ts...> >::type & get(const fixed_tuple<Ts...> & t)
|
||||||
|
{
|
||||||
|
return t.first;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T1, typename T2 >
|
||||||
|
struct fixed_tuple_mutator {};
|
||||||
|
|
||||||
|
template<typename... Tdest, typename... Tsrc>
|
||||||
|
struct fixed_tuple_mutator<void(Tdest...), void(Tsrc...)>
|
||||||
|
{
|
||||||
|
template<std::size_t I = 0>
|
||||||
|
static inline typename std::enable_if<I == sizeof...(Tsrc), void>::type
|
||||||
|
copy_r_t_l(fixed_tuple<Tsrc...>& src, fixed_tuple<Tdest...>& dest)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
template<std::size_t I = 0>
|
||||||
|
static inline typename std::enable_if<I < sizeof...(Tsrc), void>::type
|
||||||
|
copy_r_t_l(fixed_tuple<Tsrc...>& src, fixed_tuple<Tdest...>& dest)
|
||||||
|
{
|
||||||
|
fixed_tuple_accessor<I + (sizeof...(Tdest)-sizeof...(Tsrc))>::get(dest) = fixed_tuple_accessor<I>::get(src);
|
||||||
|
copy_r_t_l<I + 1>(src, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t I = 0>
|
||||||
|
static inline typename std::enable_if<I == sizeof...(Tsrc), void>::type
|
||||||
|
copy(std::tuple<Tsrc...>& src, fixed_tuple<Tdest...>& dest)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
template<std::size_t I = 0>
|
||||||
|
static inline typename std::enable_if<I < sizeof...(Tsrc), void>::type
|
||||||
|
copy(std::tuple<Tsrc...>& src, fixed_tuple<Tdest...>& dest)
|
||||||
|
{
|
||||||
|
fixed_tuple_accessor<I>::get(dest) = std::get<I>(src);
|
||||||
|
copy<I + 1>(src, dest);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // !_FIXEDTUPLE_H_
|
||||||
Loading…
Add table
Add a link
Reference in a new issue