Exemplo n.º 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();
    }
}
Exemplo n.º 2
0
inline handle::handle(handle const& other)
  : m_interpreter(other.m_interpreter)
  , m_index(LUA_NOREF)
{
    if (m_interpreter == 0) return;
    other.push(m_interpreter);
    m_index = luaL_ref(m_interpreter, LUA_REGISTRYINDEX);
}
Exemplo n.º 3
0
    static attribute create(handle const& loc, const char* name,
			    datatype const& type, dataspace const& space)
    {
      hid_t id = H5Acreate(loc.getId(), name, type, space,
			   H5P_DEFAULT, H5P_DEFAULT);
      assert(id >= 0);
      return attribute(std::move(id));
    }
Exemplo n.º 4
0
  attribute get_attribute(handle const& loc,
			  const char* obj_name,
			  const char* attr_name)
  {
    hid_t id = H5Aopen_by_name(loc.getId(), obj_name, attr_name,
			       H5P_DEFAULT, H5P_DEFAULT);
    if (id < 0) throw std::runtime_error("H5Aopen_by_name failed");
    return attribute(std::move(id));
  }
Exemplo n.º 5
0
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();
}
Exemplo n.º 6
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;
}
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();
}
Exemplo n.º 8
0
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"));
}
Exemplo n.º 9
0
 static void unwrap(lua_State* L, handle const& value)
 {
     value.push(L);
 }
Exemplo n.º 10
0
 static void unwrap(lua_State* interpreter, handle const& value)
 {
     value.push(interpreter);
 }
Exemplo n.º 11
0
// 1枚の絵 - 通常の画像であるかチェック
inline
bool is_simple(handle const& i) {
	return i.count() == 1;
}
Exemplo n.º 12
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())));
}
Exemplo n.º 13
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)));
}
Exemplo n.º 14
0
 /**
  * Constructs a new process object.
  *
  * Creates a new process object that represents a running process
  * within the system.
  *
  * This operation is only available on Windows systems. The handle is
  * closed when the process instance (and all of its copies) is destroyed.
  */
 process(handle h)
     : id_(GetProcessId(h.native())),
     handle_(h)
 {
 }
Exemplo n.º 15
0
 handle(handle<Y> const& r)
     : m_p(python::xincref(python::upcast<T>(r.get())))
 {
 }
Exemplo n.º 16
0
inline void swap(handle &a, handle &b) noexcept { a.swap(b); }