mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 06:19:02 +02:00
Provide basic conversions to/from SharedObjectPointer (still have to work out
how to handle reference counting correctly).
This commit is contained in:
parent
a13d8559e6
commit
2d4134afaf
3 changed files with 13 additions and 2 deletions
|
@ -129,10 +129,19 @@ QList<const QMetaObject*> Bitstream::getMetaObjectSubClasses(const QMetaObject*
|
||||||
return getMetaObjectSubClasses().values(metaObject);
|
return getMetaObjectSubClasses().values(metaObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bitstream::configureScriptEngine(QScriptEngine* engine) {
|
QScriptValue sharedObjectPointerToScriptValue(QScriptEngine* engine, const SharedObjectPointer& pointer) {
|
||||||
|
return pointer ? engine->newQObject(pointer.data()) : engine->nullValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void sharedObjectPointerFromScriptValue(const QScriptValue& object, SharedObjectPointer& pointer) {
|
||||||
|
pointer = qobject_cast<SharedObject*>(object.toQObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bitstream::registerTypes(QScriptEngine* engine) {
|
||||||
foreach (const QMetaObject* metaObject, getMetaObjects()) {
|
foreach (const QMetaObject* metaObject, getMetaObjects()) {
|
||||||
engine->globalObject().setProperty(metaObject->className(), engine->newQMetaObject(metaObject));
|
engine->globalObject().setProperty(metaObject->className(), engine->newQMetaObject(metaObject));
|
||||||
}
|
}
|
||||||
|
qScriptRegisterMetaType(engine, sharedObjectPointerToScriptValue, sharedObjectPointerFromScriptValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitstream::Bitstream(QDataStream& underlying, MetadataType metadataType, GenericsMode genericsMode, QObject* parent) :
|
Bitstream::Bitstream(QDataStream& underlying, MetadataType metadataType, GenericsMode genericsMode, QObject* parent) :
|
||||||
|
|
|
@ -323,7 +323,7 @@ public:
|
||||||
|
|
||||||
/// Configures the supplied script engine with our registered meta-objects, allowing all of them to be instantiated from
|
/// Configures the supplied script engine with our registered meta-objects, allowing all of them to be instantiated from
|
||||||
/// scripts.
|
/// scripts.
|
||||||
static void configureScriptEngine(QScriptEngine* engine);
|
static void registerTypes(QScriptEngine* engine);
|
||||||
|
|
||||||
enum MetadataType { NO_METADATA, HASH_METADATA, FULL_METADATA };
|
enum MetadataType { NO_METADATA, HASH_METADATA, FULL_METADATA };
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <AudioInjector.h>
|
#include <AudioInjector.h>
|
||||||
#include <AudioRingBuffer.h>
|
#include <AudioRingBuffer.h>
|
||||||
#include <AvatarData.h>
|
#include <AvatarData.h>
|
||||||
|
#include <Bitstream.h>
|
||||||
#include <CollisionInfo.h>
|
#include <CollisionInfo.h>
|
||||||
#include <ModelsScriptingInterface.h>
|
#include <ModelsScriptingInterface.h>
|
||||||
#include <NetworkAccessManager.h>
|
#include <NetworkAccessManager.h>
|
||||||
|
@ -229,6 +230,7 @@ void ScriptEngine::init() {
|
||||||
registerMenuItemProperties(&_engine);
|
registerMenuItemProperties(&_engine);
|
||||||
registerAnimationTypes(&_engine);
|
registerAnimationTypes(&_engine);
|
||||||
registerAvatarTypes(&_engine);
|
registerAvatarTypes(&_engine);
|
||||||
|
Bitstream::registerTypes(&_engine);
|
||||||
|
|
||||||
qScriptRegisterMetaType(&_engine, ParticlePropertiesToScriptValue, ParticlePropertiesFromScriptValue);
|
qScriptRegisterMetaType(&_engine, ParticlePropertiesToScriptValue, ParticlePropertiesFromScriptValue);
|
||||||
qScriptRegisterMetaType(&_engine, ParticleIDtoScriptValue, ParticleIDfromScriptValue);
|
qScriptRegisterMetaType(&_engine, ParticleIDtoScriptValue, ParticleIDfromScriptValue);
|
||||||
|
|
Loading…
Reference in a new issue