예제 #1
0
BOOST_PYTHON_DECL void delslice(object const& target, handle<> const& begin, handle<> const& end)
{
    if (assign_slice(
            target.ptr(), begin.get(), end.get(), 0) == -1
        )
    {
        throw_error_already_set();
    }
}
예제 #2
0
파일: win32.cpp 프로젝트: ATNoG/ODTONE
wlan_if_list wlan_enum_interfaces(handle const& h)
{
	WLAN_INTERFACE_INFO_LIST* iflist = nullptr;
	DWORD res;

	res = ::WlanEnumInterfaces(h.get(), nullptr, &iflist);
	if (res == ERROR_SUCCESS)
		return wlan_if_list(iflist, ::WlanFreeMemory);

	boost::throw_exception(boost::system::system_error(res,
													   boost::system::system_category(),
													   "win::wlan_enum_interfaces"));
	return wlan_if_list();
}
예제 #3
0
string python_get_error(handle<> exType, handle<> val, handle<> trace)
{
    string msg("Python: ");
    try
    {
        if (val)
        {
            if (const char* str = to_string(val.get()))
            {
                msg += str;
            }
        }
        else if (exType)
        {
            msg += to_string(exType.get());
        }

        PycString_IMPORT;
        if (trace && PycStringIO)
        {
            object traceOut(handle<>(PycStringIO->NewOutput(128)));
            PyTraceBack_Print(trace.get(), traceOut.ptr());
            msg += "\n";
            msg += PyString_AsString(object(
                handle<>(PycStringIO->cgetvalue(traceOut.ptr()))).ptr());
        }
    }
    catch (const exception& e)
    {
        msg += e.what() + string(__func__);
    }
    catch (...)
    {
        msg += "Unknown error in " + string(__func__);
    }
    return msg;
}
예제 #4
0
파일: win32.cpp 프로젝트: ATNoG/ODTONE
void wlan_register_notification(handle const& h, wlan_register_notification_handler const& handler)
{
	wlan_register_notification_handler* cb = new wlan_register_notification_handler(handler);
	DWORD res;

	res = ::WlanRegisterNotification(h.get(), WLAN_NOTIFICATION_SOURCE_ALL, TRUE,
									 detail::wlan_notify_handler, cb,
									 nullptr, nullptr);
	if (res == ERROR_SUCCESS)
		return;

	delete cb;
	boost::throw_exception(boost::system::system_error(res,
													   boost::system::system_category(),
													   "win::wlan_register_notification"));
}
void function::argument_error(PyObject* args, PyObject* /*keywords*/) const
{
    static handle<> exception(
        PyErr_NewException(const_cast<char*>("Boost.Python.ArgumentError"), PyExc_TypeError, 0));

    object message = "Python argument types in\n    %s.%s("
        % make_tuple(this->m_namespace, this->m_name);
    
    list actual_args;
    for (ssize_t i = 0; i < PyTuple_Size(args); ++i)
    {
        char const* name = PyTuple_GetItem(args, i)->ob_type->tp_name;
        actual_args.append(str(name));
    }
    message += str(", ").join(actual_args);
    message += ")\ndid not match C++ signature:\n    ";
    message += str("\n    ").join(signatures());

#if BOOST_PYTHON_DEBUG_ERROR_MESSAGES
    std::printf("\n--------\n%s\n--------\n", extract<const char*>(message)());
#endif 
    PyErr_SetObject(exception.get(), message.ptr());
    throw_error_already_set();
}
예제 #6
0
BOOST_PYTHON_DECL object getslice(object const& target, handle<> const& begin, handle<> const& end)
{
    return object(
        detail::new_reference(
            apply_slice(target.ptr(), begin.get(), end.get())));
}
예제 #7
0
handle<> apply_to_own_type(handle<> x)
{
    // Tests that we can return handle<> from a callback and that we
    // can pass arbitrary handle<T>.
    return call<handle<> >(x.get(), type_handle(borrowed(x->ob_type)));
}
예제 #8
0
 handle(handle<Y> const& r)
     : m_p(python::xincref(python::upcast<T>(r.get())))
 {
 }