void CJavascriptException::PrintCallStack(py::object file) { CPythonGIL python_gil; PyObject *out = file.is_none() ? ::PySys_GetObject((char *) "stdout") : file.ptr(); int fd = ::PyObject_AsFileDescriptor(out); Message()->PrintCurrentStackTrace(m_isolate, fdopen(fd, "w+")); }
CContext::CContext(py::object global, py::list extensions) : m_global(global) { v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); std::auto_ptr<v8::ExtensionConfiguration> cfg; std::vector<std::string> ext_names; std::vector<const char *> ext_ptrs; for (Py_ssize_t i=0; i<PyList_Size(extensions.ptr()); i++) { py::extract<const std::string> extractor(::PyList_GetItem(extensions.ptr(), i)); if (extractor.check()) { ext_names.push_back(extractor()); } } for (size_t i=0; i<ext_names.size(); i++) { ext_ptrs.push_back(ext_names[i].c_str()); } if (!ext_ptrs.empty()) cfg.reset(new v8::ExtensionConfiguration(ext_ptrs.size(), &ext_ptrs[0])); v8::Handle<v8::Context> context = v8::Context::New(v8::Isolate::GetCurrent(), cfg.get()); m_context.Reset(v8::Isolate::GetCurrent(), context); v8::Context::Scope context_scope(Handle()); if (!global.is_none()) { Handle()->Global()->Set(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "__proto__"), CPythonObject::Wrap(global)); Py_DECREF(global.ptr()); } }