ScriptPreprocessor::ScriptPreprocessor(const ScriptSourceCode& preprocessorSourceCode, ScriptController& controller, PageConsole& console) : m_isPreprocessing(false) { v8::TryCatch tryCatch; tryCatch.SetVerbose(true); Vector<ScriptSourceCode> sources; sources.append(preprocessorSourceCode); Vector<ScriptValue> scriptResults; controller.executeScriptInIsolatedWorld(ScriptPreprocessorIsolatedWorldId, sources, DOMWrapperWorld::mainWorldExtensionGroup, &scriptResults); if (scriptResults.size() != 1) { console.addMessage(JSMessageSource, ErrorMessageLevel, "ScriptPreprocessor internal error, one ScriptSourceCode must give exactly one result."); return; } ScriptValue preprocessorFunction = scriptResults[0]; if (!preprocessorFunction.isFunction()) { console.addMessage(JSMessageSource, ErrorMessageLevel, "The preprocessor must compile to a function."); return; } m_world = DOMWrapperWorld::ensureIsolatedWorld(ScriptPreprocessorIsolatedWorldId, DOMWrapperWorld::mainWorldExtensionGroup); v8::Local<v8::Context> context = m_world->context(controller); m_isolate = context->GetIsolate(); m_context.set(m_isolate, context); m_preprocessorFunction.set(m_isolate, v8::Handle<v8::Function>::Cast(preprocessorFunction.v8Value())); }
void XSLTProcessor::parseErrorFunc(void* userData, xmlError* error) { PageConsole* console = static_cast<PageConsole*>(userData); if (!console) return; MessageLevel level; switch (error->level) { case XML_ERR_NONE: level = DebugMessageLevel; break; case XML_ERR_WARNING: level = WarningMessageLevel; break; case XML_ERR_ERROR: case XML_ERR_FATAL: default: level = ErrorMessageLevel; break; } console->addMessage(XMLMessageSource, level, error->message, error->file, error->line); }
void XSLTProcessor::parseErrorFunc(void* userData, xmlError* error) { PageConsole* console = static_cast<PageConsole*>(userData); if (!console) return; MessageLevel level; switch (error->level) { case XML_ERR_NONE: level = MessageLevel::Debug; break; case XML_ERR_WARNING: level = MessageLevel::Warning; break; case XML_ERR_ERROR: case XML_ERR_FATAL: default: level = MessageLevel::Error; break; } // xmlError->int2 is the column number of the error or 0 if N/A. console->addMessage(MessageSource::XML, level, error->message, error->file, error->line, error->int2); }