1076 lines · 43.4 KB · C++
RawDownload
ScriptEngine::DemarshalFunction CustomTypeInstance<i>::demarshalFunc; // I would *LOVE* it if there was a different way to do this, jeez!// Qt requires two functions that have no parameters that give any context,// one of the must return a QScriptValue (so we can't void* them into generics and stick them in the templates).// This *has* to be done via templates but the whole point of this is to avoid leaking types into the rest of// the system that would require anyone other than us to have a dependency on QtScript#define CUSTOM_TYPE_ENTRY(idx) \        case idx: \            CustomTypeInstance<idx>::marshalFunc = marshalFunc; \            CustomTypeInstance<idx>::demarshalFunc = demarshalFunc; \            internalMarshalFunc = CustomTypeInstance<idx>::internalMarshalFunc; \            internalDemarshalFunc = CustomTypeInstance<idx>::internalDemarshalFunc; \            break;#define CUSTOM_TYPE_ENTRY_10(idx) \        CUSTOM_TYPE_ENTRY((idx * 10)); \        CUSTOM_TYPE_ENTRY((idx * 10) + 1); \        CUSTOM_TYPE_ENTRY((idx * 10) + 2); \        CUSTOM_TYPE_ENTRY((idx * 10) + 3); \        CUSTOM_TYPE_ENTRY((idx * 10) + 4); \        CUSTOM_TYPE_ENTRY((idx * 10) + 5); \        CUSTOM_TYPE_ENTRY((idx * 10) + 6); \        CUSTOM_TYPE_ENTRY((idx * 10) + 7); \        CUSTOM_TYPE_ENTRY((idx * 10) + 8); \        CUSTOM_TYPE_ENTRY((idx * 10) + 9); void ScriptEngineQtScript::registerCustomType(int type,                                              ScriptEngine::MarshalFunction marshalFunc,                                              ScriptEngine::DemarshalFunction demarshalFunc,                                              const ScriptValue& prototype){    QScriptValue unwrapped = ScriptValueQtWrapper::fullUnwrap(this, prototype);    QScriptEngine::MarshalFunction internalMarshalFunc;    QScriptEngine::DemarshalFunction internalDemarshalFunc;     if (_nextCustomType >= 300) { // have we ran out of translators?        Q_ASSERT(false);        return;    }     switch (_nextCustomType++) {        CUSTOM_TYPE_ENTRY_10(0);        CUSTOM_TYPE_ENTRY_10(1);        CUSTOM_TYPE_ENTRY_10(2);        CUSTOM_TYPE_ENTRY_10(3);        CUSTOM_TYPE_ENTRY_10(4);        CUSTOM_TYPE_ENTRY_10(5);        CUSTOM_TYPE_ENTRY_10(6);        CUSTOM_TYPE_ENTRY_10(7);        CUSTOM_TYPE_ENTRY_10(8);        CUSTOM_TYPE_ENTRY_10(9);        CUSTOM_TYPE_ENTRY_10(10);        CUSTOM_TYPE_ENTRY_10(11);        CUSTOM_TYPE_ENTRY_10(12);        CUSTOM_TYPE_ENTRY_10(13);        CUSTOM_TYPE_ENTRY_10(14);        CUSTOM_TYPE_ENTRY_10(15);        CUSTOM_TYPE_ENTRY_10(16);        CUSTOM_TYPE_ENTRY_10(17);        CUSTOM_TYPE_ENTRY_10(18);        CUSTOM_TYPE_ENTRY_10(19);        CUSTOM_TYPE_ENTRY_10(20);        CUSTOM_TYPE_ENTRY_10(21);        CUSTOM_TYPE_ENTRY_10(22);        CUSTOM_TYPE_ENTRY_10(23);        CUSTOM_TYPE_ENTRY_10(24);        CUSTOM_TYPE_ENTRY_10(25);        CUSTOM_TYPE_ENTRY_10(26);        CUSTOM_TYPE_ENTRY_10(27);        CUSTOM_TYPE_ENTRY_10(28);        CUSTOM_TYPE_ENTRY_10(29);        CUSTOM_TYPE_ENTRY_10(30);    }     qScriptRegisterMetaType_helper(this, type, internalMarshalFunc, internalDemarshalFunc, unwrapped);}

Lines 1001–1076 of 1076. Previous lines

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t