void CodeGen::nonLifoTrap(RegisterState* s) { a.Comment("nonLifoTrap"); static PrimDesc* non_lifo_abort = NULL; if (non_lifo_abort == NULL) non_lifo_abort = getPrimDescOfFunction( fntype(&NLRSupport::non_lifo_abort), true); Label next(a.printing); a.call(&next); // prim needs some PC in this method next.define(); a.popl(Temp1); move(ReceiverReg, Temp1); s->allocateArgs(0, true); // for receiver Label* nlr_dest = cPrimCall(non_lifo_abort, s, true, true, 1); assert(nlr_dest == NULL, "should not need a label"); }
void initDeadBlockNode() { DeadBlockNode::non_lifo_abort = getPrimDescOfFunction(fntype(&NLRSupport::non_lifo_abort), true); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void PySingleToCefValueList( boost::python::object value, CefListValue *result, int i ) { boost::python::object jsobject = _cef.attr("JSObject"); boost::python::object valuetype = fntype( value ); if( value == boost::python::object() ) { result->SetNull( i ); } else if( valuetype == builtins.attr("int") ) { result->SetInt( i, boost::python::extract<int>(value) ); } else if( valuetype == builtins.attr("float") ) { result->SetDouble( i, boost::python::extract<float>(value) ); } else if( valuetype == builtins.attr("str") ) { const char *pStr = boost::python::extract<const char *>(value); result->SetString( i, pStr ); } #if PY_VERSION_HEX < 0x03000000 else if( valuetype == builtins.attr("unicode") ) { const wchar_t *pStr = PyUnicode_AS_UNICODE( value.ptr() ); if( !pStr ) { PyErr_SetString(PyExc_ValueError, "PyToCefValueList: Invalid unicode object in message list" ); throw boost::python::error_already_set(); } result->SetString( i, pStr ); } #endif // PY_VERSION_HEX < 0x03000000 else if( valuetype == builtins.attr("bool") ) { result->SetBool( i, boost::python::extract<bool>(value) ); } #if PY_VERSION_HEX >= 0x03000000 else if( fnisinstance( value, boost::python::object( builtins.attr("list") ) ) || valuetype == builtins.attr("tuple") || valuetype == builtins.attr("set") || valuetype == builtins.attr("map") ) #else else if( fnisinstance( value, boost::python::object( builtins.attr("list") ) ) || valuetype == builtins.attr("tuple") || valuetype == builtins.attr("set") ) #endif // PY_VERSION_HEX >= 0x03000000 { result->SetList( i, PyToCefValueList( value ) ); } else if( fnisinstance( value, boost::python::object( builtins.attr("dict") ) ) ) { result->SetDictionary( i, PyToCefDictionaryValue( value ) ); } else if( valuetype == srcbuiltins.attr("Color") ) { Color c = boost::python::extract<Color>(value); result->SetString( i, UTIL_VarArgs("rgba(%d, %d, %d, %.2f)", c.r(), c.g(), c.b(), c.a() / 255.0f) ); } else if( valuetype == jsobject ) { PyJSObject *pJSObject = boost::python::extract< PyJSObject * >( value ); WarsCefJSObject_t warsCefJSObject; V_strncpy( warsCefJSObject.uuid, pJSObject->GetJSObject()->GetIdentifier().ToString().c_str(), sizeof( warsCefJSObject.uuid ) ); CefRefPtr<CefBinaryValue> pRefData = CefBinaryValue::Create( &warsCefJSObject, sizeof( warsCefJSObject ) ); result->SetBinary( i, pRefData ); } else { const char *pObjectTypeStr = boost::python::extract<const char *>( boost::python::str( valuetype ) ); const char *pObjectStr = boost::python::extract<const char *>( boost::python::str( value ) ); char buf[512]; V_snprintf( buf, sizeof(buf), "PyToCefValueList: Unsupported type \"%s\" for object \"%s\" in message list", pObjectTypeStr, pObjectStr ); PyErr_SetString( PyExc_ValueError, buf ); throw boost::python::error_already_set(); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- CefRefPtr<CefDictionaryValue> PyToCefDictionaryValue( boost::python::object d ) { CefRefPtr<CefDictionaryValue> result = CefDictionaryValue::Create(); boost::python::object items = d.attr("items")(); boost::python::object iterator = items.attr("__iter__")(); boost::python::ssize_t length = boost::python::len(items); for( boost::python::ssize_t u = 0; u < length; u++ ) { boost::python::object item = iterator.attr( PY_NEXT_METHODNAME )(); boost::python::object value = item[1]; boost::python::object valuetype = fntype( value ); CefString cefkey = boost::python::extract< const char * >( boost::python::str( item[0] ) ); if( value == boost::python::object() ) { result->SetNull( cefkey ); } else if( valuetype == builtins.attr("int") ) { result->SetInt( cefkey, boost::python::extract<int>(value) ); } else if( valuetype == builtins.attr("float") ) { result->SetDouble( cefkey, boost::python::extract<float>(value) ); } else if( valuetype == builtins.attr("str") ) { const char *pStr = boost::python::extract<const char *>(value); result->SetString( cefkey, pStr ); } #if PY_VERSION_HEX < 0x03000000 else if( valuetype == builtins.attr("unicode") ) { const wchar_t *pStr = PyUnicode_AS_UNICODE( value.ptr() ); if( !pStr ) { PyErr_SetString(PyExc_ValueError, "PyToCefDictionaryValue: Invalid unicode object in message list" ); throw boost::python::error_already_set(); } result->SetString( cefkey, pStr ); } #endif // PY_VERSION_HEX < 0x03000000 else if( valuetype == builtins.attr("bool") ) { result->SetBool( cefkey, boost::python::extract<bool>(value) ); } #if PY_VERSION_HEX >= 0x03000000 else if( fnisinstance( value, boost::python::object( builtins.attr("list") ) ) || valuetype == builtins.attr("tuple") || valuetype == builtins.attr("set") || valuetype == builtins.attr("map") ) #else else if( fnisinstance( value, boost::python::object( builtins.attr("list") ) ) || valuetype == builtins.attr("tuple") || valuetype == builtins.attr("set") ) #endif // PY_VERSION_HEX >= 0x03000000 { result->SetList( cefkey, PyToCefValueList( value ) ); } else if( fnisinstance( value, boost::python::object( builtins.attr("dict") ) ) ) { result->SetDictionary( cefkey, PyToCefDictionaryValue( value ) ); } else if( valuetype == srcbuiltins.attr("Color") ) { Color c = boost::python::extract<Color>(value); result->SetString( cefkey, UTIL_VarArgs("rgba(%d, %d, %d, %.2f)", c.r(), c.g(), c.b(), c.a() / 255.0f) ); } else { const char *pObjectTypeStr = boost::python::extract<const char *>( boost::python::str( valuetype ) ); const char *pObjectStr = boost::python::extract<const char *>( boost::python::str( value ) ); char buf[512]; V_snprintf( buf, sizeof(buf), "PyToCefDictionaryValue: Unsupported type \"%s\" for object \"%s\" in message list", pObjectTypeStr, pObjectStr ); PyErr_SetString(PyExc_ValueError, buf ); throw boost::python::error_already_set(); } } return result; }