bool ParseProgramOptions(int32 &return_code, int32 argc, char **argv) { // Convert the argument list to a vector of strings for convenience std::vector<std::string> options(argv, argv + argc); return_code = 0; for(uint32 i = 1; i < options.size(); i++) { if(options[i] == "-c" || options[i] == "--check") { if(CheckFiles() == true) { return_code = 0; } else { return_code = 1; } return false; } else if(options[i] == "-d" || options[i] == "--debug") { if((i + 1) >= options.size()) { std::cerr << "Option " << options[i] << " requires an argument." << std::endl; PrintUsage(); return_code = 1; return false; } if(EnableDebugging(options[i + 1]) == false) { return_code = 1; return false; } i++; } else if(options[i] == "--disable-audio") { vt_audio::AUDIO_ENABLE = false; } else if(options[i] == "-h" || options[i] == "--help") { PrintUsage(); return_code = 0; return false; } else if(options[i] == "-i" || options[i] == "--info") { if(PrintSystemInformation() == true) { return_code = 0; } else { return_code = 1; } return false; } else if(options[i] == "-r" || options[i] == "--reset") { if(ResetSettings() == true) { return_code = 0; } else { return_code = 1; } return_code = 0; return false; } else { std::cerr << "Unrecognized option: " << options[i] << std::endl; PrintUsage(); return_code = 1; return false; } } return true; } // bool ParseProgramOptions(int32_t &return_code, int32_t argc, char **argv)
void V8IsolateImpl::AddContext(V8ContextImpl* pContextImpl, bool enableDebugging, int debugPort) { _ASSERTE(IsCurrent() && IsLocked()); if (!enableDebugging) { m_ContextPtrs.push_back(pContextImpl); } else { m_ContextPtrs.push_front(pContextImpl); EnableDebugging(debugPort); } }
void V8IsolateImpl::AddContext(V8ContextImpl* pContextImpl, bool enableDebugging, int debugPort) { _ASSERTE(m_pIsolate == Isolate::GetCurrent()); _ASSERTE(Locker::IsLocked(m_pIsolate)); if (!enableDebugging) { m_ContextPtrs.push_back(pContextImpl); } else { m_ContextPtrs.push_front(pContextImpl); EnableDebugging(debugPort); } }
V8IsolateImpl::V8IsolateImpl(const StdString& name, const V8IsolateConstraints* pConstraints, bool enableDebugging, int debugPort) : m_Name(name), m_DebuggingEnabled(false), m_DebugMessageDispatchCount(0), m_MaxHeapSize(0), m_HeapWatchLevel(0), m_MaxStackUsage(0), m_StackWatchLevel(0), m_pStackLimit(nullptr), m_IsOutOfMemory(false), m_IsExecutionTerminating(false) { V8Platform::EnsureInstalled(); V8ArrayBufferAllocator::EnsureInstalled(); v8::Isolate::CreateParams params; if (pConstraints != nullptr) { params.constraints.set_max_semi_space_size(pConstraints->GetMaxNewSpaceSize()); params.constraints.set_max_old_space_size(pConstraints->GetMaxOldSpaceSize()); params.constraints.set_max_executable_size(pConstraints->GetMaxExecutableSize()); } m_pIsolate = v8::Isolate::New(params); BEGIN_ADDREF_SCOPE m_pIsolate->SetData(0, this); BEGIN_ISOLATE_ENTRY_SCOPE v8::V8::SetCaptureStackTraceForUncaughtExceptions(true, 64, v8::StackTrace::kDetailed); END_ISOLATE_ENTRY_SCOPE if (enableDebugging) { BEGIN_ISOLATE_SCOPE EnableDebugging(debugPort); END_ISOLATE_SCOPE } END_ADDREF_SCOPE ++s_InstanceCount; }
V8IsolateImpl::V8IsolateImpl(const wchar_t* pName, const V8IsolateConstraints* pConstraints, bool enableDebugging, int debugPort) : m_pIsolate(Isolate::New()), m_DebuggingEnabled(false), m_DebugMessageDispatchCount(0), m_MaxStackUsage(0), m_ExecutionLevel(0), m_pStackLimit(nullptr), m_IsOutOfMemory(false) { BEGIN_ADDREF_SCOPE if (pName != nullptr) { m_Name = pName; } BEGIN_ISOLATE_ENTRY_SCOPE V8::SetCaptureStackTraceForUncaughtExceptions(true, 64, StackTrace::kDetailed); V8::IgnoreOutOfMemoryException(); if (pConstraints != nullptr) { ResourceConstraints constraints; constraints.set_max_young_space_size(pConstraints->GetMaxYoungSpaceSize()); constraints.set_max_old_space_size(pConstraints->GetMaxOldSpaceSize()); constraints.set_max_executable_size(pConstraints->GetMaxExecutableSize()); ASSERT_EVAL(SetResourceConstraints(m_pIsolate, &constraints)); } END_ISOLATE_ENTRY_SCOPE if (enableDebugging) { BEGIN_ISOLATE_SCOPE EnableDebugging(debugPort); END_ISOLATE_SCOPE } END_ADDREF_SCOPE }