/** * Constructs a new AdaptSRNParametersOperator. */ AdaptSRNParametersOperator::AdaptSRNParametersOperator(const QString &name) : NeuralNetworkManipulationOperator(name) { mChangeProbability = new NormalizedDoubleValue(0.1, 0.0, 1.0, 0.0, 1.0); mGlobalSettings = new BoolValue(true); mChangeProbability->setDescription("The probability for a parameter change to occur at all.\n" "If used with ApplyGlobally = false, then this probability\n" "is applied to each SRN neuron separately."); mGlobalSettings->setDescription("If true, then all parameters of all SRN neurons are changed\n" "at once."); for(int i = 0; i < 5; ++i) { mProbabilities.append(new NormalizedDoubleValue(0.5, 0.0, 1.0, 0.0, 1.0)); mDeviations.append(new NormalizedDoubleValue(0.05, 0.0, 1.0, 0.0, 1.0)); mMins.append(new DoubleValue(0.0)); mMaxs.append(new DoubleValue(1.0)); } addParameters("Alpha", 0); addParameters("Beta", 1); addParameters("Gamma", 2); addParameters("Delta", 3); addParameters("AStar", 4); addParameter("ProbabilityForChange", mChangeProbability); addParameter("ApplyGlobally", mGlobalSettings); getEnableOperatorValue()->set(false); getHiddenValue()->set(true); }
void V8AbstractEventListener::invokeEventHandler(ExecutionContext* context, Event* event, v8::Local<v8::Value> jsEvent) { // If jsEvent is empty, attempt to set it as a hidden value would crash v8. if (jsEvent.IsEmpty()) return; v8::Local<v8::Context> v8Context = toV8Context(context, world()); if (v8Context.IsEmpty()) return; // We push the event being processed into the global object, so that it can be exposed by DOMWindow's bindings. v8::Handle<v8::String> eventSymbol = v8AtomicString(v8Context->GetIsolate(), "event"); v8::Local<v8::Value> returnValue; { // Catch exceptions thrown in the event handler so they do not propagate to javascript code that caused the event to fire. v8::TryCatch tryCatch; tryCatch.SetVerbose(true); // Save the old 'event' property so we can restore it later. v8::Local<v8::Value> savedEvent = getHiddenValue(v8Context->GetIsolate(), v8Context->Global(), eventSymbol); tryCatch.Reset(); // Make the event available in the global object, so DOMWindow can expose it. setHiddenValue(v8Context->GetIsolate(), v8Context->Global(), eventSymbol, jsEvent); tryCatch.Reset(); returnValue = callListenerFunction(context, jsEvent, event); if (tryCatch.HasCaught()) event->target()->uncaughtExceptionInEventHandler(); if (!tryCatch.CanContinue()) { // Result of TerminateExecution(). if (context->isWorkerGlobalScope()) toWorkerGlobalScope(context)->script()->forbidExecution(); return; } tryCatch.Reset(); // Restore the old event. This must be done for all exit paths through this method. if (savedEvent.IsEmpty()) setHiddenValue(v8Context->GetIsolate(), v8Context->Global(), eventSymbol, v8::Undefined(v8Context->GetIsolate())); else setHiddenValue(v8Context->GetIsolate(), v8Context->Global(), eventSymbol, savedEvent); tryCatch.Reset(); } ASSERT(!handleOutOfMemory() || returnValue.IsEmpty()); if (returnValue.IsEmpty()) return; if (!returnValue->IsNull() && !returnValue->IsUndefined() && event->isBeforeUnloadEvent()) { V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringReturnValue, returnValue); toBeforeUnloadEvent(event)->setReturnValue(stringReturnValue); } if (m_isAttribute && shouldPreventDefault(returnValue)) event->preventDefault(); }
v8::Local<v8::Value> V8HiddenValue::getHiddenValueFromMainWorldWrapper( ScriptState* scriptState, ScriptWrappable* wrappable, v8::Local<v8::String> key) { v8::Local<v8::Object> wrapper = wrappable->mainWorldWrapper(scriptState->isolate()); return wrapper.IsEmpty() ? v8::Local<v8::Value>() : getHiddenValue(scriptState, wrapper, key); }
void V8Window::eventAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info) { Frame* frame = V8Window::toNative(info.Holder())->frame(); ExceptionState exceptionState(ExceptionState::GetterContext, "event", "Window", info.Holder(), info.GetIsolate()); if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exceptionState)) { exceptionState.throwIfNeeded(); return; } ASSERT(frame); v8::Local<v8::Context> context = toV8Context(info.GetIsolate(), frame, DOMWrapperWorld::current(info.GetIsolate())); if (context.IsEmpty()) return; v8::Handle<v8::Value> jsEvent = getHiddenValue(info.GetIsolate(), context->Global(), "event"); if (jsEvent.IsEmpty()) return; v8SetReturnValue(info, jsEvent); }
v8::Local<v8::Value> getHiddenValueFromMainWorldWrapper(v8::Isolate* isolate, ScriptWrappable* wrappable, v8::Handle<v8::String> key) { v8::Local<v8::Object> wrapper = wrappable->newLocalWrapper(isolate); return wrapper.IsEmpty() ? v8::Local<v8::Value>() : getHiddenValue(isolate, wrapper, key); }
v8::Local<v8::Value> getHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, const char* key) { return getHiddenValue(isolate, object, v8AtomicString(isolate, key)); }
static void V8LazyEventListenerToString(const v8::FunctionCallbackInfo<v8::Value>& info) { v8SetReturnValue(info, getHiddenValue(info.GetIsolate(), info.Holder(), "toStringString")); }