Now with extra "supports nested components" goodness.
qDeleteAll(cachedPrograms);
qDeleteAll(cachedClosures);
- qPersistentDispose(v8bindings);
+ for (int ii = 0; ii < v8bindings.count(); ++ii)
+ qPersistentDispose(v8bindings[ii]);
}
void QDeclarativeCompiledData::clear()
QDeclarativeInstruction bindings;
bindings.setType(QDeclarativeInstruction::InitV8Bindings);
bindings.initV8Bindings.program = output->indexForString(compileState.v8BindingProgram);
+ bindings.initV8Bindings.programIndex = compileState.v8BindingProgramIndex;
bindings.initV8Bindings.line = compileState.v8BindingProgramLine;
output->addInstruction(bindings);
}
QDeclarativeInstruction bindings;
bindings.setType(QDeclarativeInstruction::InitV8Bindings);
bindings.initV8Bindings.program = output->indexForString(compileState.v8BindingProgram);
+ bindings.initV8Bindings.programIndex = compileState.v8BindingProgramIndex;
bindings.initV8Bindings.line = compileState.v8BindingProgramLine;
output->addInstruction(bindings);
}
bool isSharable = false;
binding.rewrittenExpression = rewriteBinding(binding.expression.asAST(), expression, &isSharable);
- if (0 && isSharable && !binding.property->isAlias /* See above re alias */ &&
+ if (isSharable && !binding.property->isAlias /* See above re alias */ &&
binding.property->type != qMetaTypeId<QDeclarativeBinding*>()) {
binding.dataType = BindingReference::V8;
sharedBindings.append(&iter.value());
compileState.v8BindingProgram = functionArray;
compileState.v8BindingProgramLine = startLineNumber;
+ compileState.v8BindingProgramIndex = output->v8bindings.count();
+ output->v8bindings.append(v8::Persistent<v8::Array>());
}
if (bindingCompiler.isValid())
};
QList<TypeReference> types;
- v8::Persistent<v8::Array> v8bindings;
+ QList<v8::Persistent<v8::Array> > v8bindings;
const QMetaObject *root;
QAbstractDynamicMetaObject rootData;
QByteArray compiledBindingData;
QString v8BindingProgram;
int v8BindingProgramLine;
+ int v8BindingProgramIndex;
QHash<QDeclarativeParser::Value *, BindingReference> bindings;
QHash<QDeclarativeParser::Value *, BindingContext> signalExpressions;
qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.primitive << "\t" << instr->assignCustomType.type;
break;
case QDeclarativeInstruction::InitV8Bindings:
- qWarning().nospace() << idx << "\t\t" << "INIT_V8_BINDING\t" << instr->initV8Bindings.program << "\t" << instr->initV8Bindings.line;
+ qWarning().nospace() << idx << "\t\t" << "INIT_V8_BINDING\t" << instr->initV8Bindings.program << "\t" << instr->initV8Bindings.programIndex << "\t" << instr->initV8Bindings.line;
break;
case QDeclarativeInstruction::StoreBinding:
qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
struct instr_initV8Bindings {
QML_INSTR_HEADER
int program;
- int line;
+ ushort programIndex;
+ ushort line;
};
struct instr_assignBinding {
QML_INSTR_HEADER
QML_END_INSTR(BeginObject)
QML_BEGIN_INSTR(InitV8Bindings)
- ctxt->v8bindings = new QV8Bindings(primitives.at(instr.program), instr.line, comp, ctxt);
+ ctxt->v8bindings = new QV8Bindings(primitives.at(instr.program), instr.programIndex,
+ instr.line, comp, ctxt);
QML_END_INSTR(InitV8Bindings)
QML_BEGIN_INSTR(StoreBinding)
parent->q_func()->release();
}
-QV8Bindings::QV8Bindings(const QString &program, int line,
+QV8Bindings::QV8Bindings(const QString &program, int index, int line,
QDeclarativeCompiledData *compiled,
QDeclarativeContextData *context)
: QObject(*(new QV8BindingsPrivate))
QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(context->engine);
- if (compiled->v8bindings.IsEmpty()) {
+ if (compiled->v8bindings[index].IsEmpty()) {
v8::HandleScope handle_scope;
v8::Context::Scope scope(engine->context());
v8::Local<v8::Value> result = script->Run(engine->contextWrapper()->sharedContext());
if (result->IsArray())
- compiled->v8bindings = qPersistentNew(v8::Local<v8::Array>::Cast(result));
+ compiled->v8bindings[index] = qPersistentNew(v8::Local<v8::Array>::Cast(result));
}
d->url = compiled->url;
- d->functions = qPersistentNew(compiled->v8bindings);
+ d->functions = qPersistentNew(compiled->v8bindings[index]);
d->bindingsCount = d->functions->Length();
d->bindings = new QV8BindingsPrivate::Binding[d->bindingsCount];
public QDeclarativeRefCount
{
public:
- QV8Bindings(const QString &program, int line,
+ QV8Bindings(const QString &program, int index, int line,
QDeclarativeCompiledData *compiled,
QDeclarativeContextData *context);
virtual ~QV8Bindings();
{
QDeclarativeInstruction i;
- i.setType(QDeclarativeInstruction::StoreCompiledBinding);
+ i.setType(QDeclarativeInstruction::StoreV4Binding);
i.assignBinding.property = 27;
i.assignBinding.value = 2;
i.assignBinding.context = 4;