コード例 #1
0
boost::python::object CreatePyHandleHelper( const CBaseEntity *pEnt, const char *handlename )
{	
	boost::python::object clshandle;
	if( pEnt->GetPyInstance().ptr() != Py_None )	
	{							
		try 
		{																
			clshandle = _entities.attr("PyHandle");							
		} 
		catch(boost::python::error_already_set &) 
		{
#ifdef CLIENT_DLL
			Warning("CLIENT: ");
#else
			Warning("SERVER: ");
#endif // CLIENT_DLL
			Warning("Failed to create a PyHandle\n");				
			PyErr_Print();																		
			PyErr_Clear();																		
			return boost::python::object();														
		}																						
		return clshandle(pEnt->GetPyInstance());														
	}																							
	try 
	{																												
		clshandle = _entities.attr(handlename);		
		return clshandle(boost::python::ptr(pEnt));
	} 
	catch(boost::python::error_already_set &) 
	{				
#ifdef CLIENT_DLL
		Warning("CLIENT: ");
#else
		Warning("SERVER: ");
#endif // CLIENT_DLL
		Warning("Failed to create handle %s\n", handlename);								
		PyErr_Print();																			
		PyErr_Clear();																			
		return boost::python::object();															
	}																							
	return boost::python::object();											
}
コード例 #2
0
bp::object CreatePyHandle( int iEntry, int iSerialNumber )
{
	try 
	{
		boost::python::object clshandle;
		clshandle = _entities.attr("PyHandle");
		return clshandle(iEntry, iSerialNumber);
	}
	catch( bp::error_already_set & )
	{
		PyErr_Print();	
	}
	return bp::object();
}