⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 puremodule.c

📁 python s60 1.4.5版本的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
 * pure_purify_map_pool() and pure_purify_map_pool_id().  Since they cache
 * this variable it should be safe in the face of recursion or cross
 * calling.
 *
 * Further note that the prototype for the callback function is wrong in
 * the Purify manual.  The manual says the function takes a single char*,
 * but the header file says it takes an additional int and void*.  I have
 * no idea what these are for!
 */
static PyObject* MapCallable = NULL;

static void
map_pool_callback(char* mem, int user_size, void *user_aux_data)
{
	long memrep = (long)mem;
	long user_aux_data_rep = (long)user_aux_data;
	PyObject* result;
	PyObject* memobj = Py_BuildValue("lil", memrep, user_size,
					 user_aux_data_rep);

	if (memobj == NULL)
		return;

	result = PyEval_CallObject(MapCallable, memobj);
	Py_DECREF(result);
	Py_DECREF(memobj);
}

static PyObject*
pure_purify_map_pool(PyObject *self, PyObject *args)
{
        /* cache global variable in case of recursion */
	PyObject* saved_callable = MapCallable;
	PyObject* arg_callable;
	int id;

	if (!PyArg_ParseTuple(args, "iO:purify_map_pool", &id, &arg_callable))
		return NULL;

	if (!PyCallable_Check(arg_callable)) {
		PyErr_SetString(PyExc_TypeError,
				"Second argument must be callable");
		return NULL;
	}
	MapCallable = arg_callable;
	purify_map_pool(id, map_pool_callback);
	MapCallable = saved_callable;

	Py_INCREF(Py_None);
	return Py_None;
}

static void
PurifyMapPoolIdCallback(int id)
{
	PyObject* result;
	PyObject* intobj = Py_BuildValue("i", id);

	if (intobj == NULL)
		return;

	result = PyEval_CallObject(MapCallable, intobj);
	Py_DECREF(result);
	Py_DECREF(intobj);
}

static PyObject*
pure_purify_map_pool_id(PyObject *self, PyObject *args)
{
        /* cache global variable in case of recursion */
	PyObject* saved_callable = MapCallable;
	PyObject* arg_callable;

	if (!PyArg_ParseTuple(args, "O:purify_map_pool_id", &arg_callable))
		return NULL;

	if (!PyCallable_Check(arg_callable)) {
		PyErr_SetString(PyExc_TypeError, "Argument must be callable.");
		return NULL;
	}

	MapCallable = arg_callable;
	purify_map_pool_id(PurifyMapPoolIdCallback);
	MapCallable = saved_callable;

	Py_INCREF(Py_None);
	return Py_None;
}



static PyObject*
pure_purify_new_messages(PyObject *self, PyObject *args)
{
	return call_voidarg_function(purify_new_messages, self, args);
}
static PyObject*
pure_purify_all_messages(PyObject *self, PyObject *args)
{
	return call_voidarg_function(purify_all_messages, self, args);
}
static PyObject*
pure_purify_clear_messages(PyObject *self, PyObject *args)
{
	return call_voidarg_function(purify_clear_messages, self, args);
}
static PyObject*
pure_purify_clear_new_messages(PyObject *self, PyObject *args)
{
	return call_voidarg_function(purify_clear_new_messages, self, args);
}
static PyObject*
pure_purify_start_batch(PyObject *self, PyObject *args)
{
	return call_voidarg_function(purify_start_batch, self, args);
}
static PyObject*
pure_purify_start_batch_show_first(PyObject *self, PyObject *args)
{
	return call_voidarg_function(purify_start_batch_show_first,
				     self, args);
}
static PyObject*
pure_purify_stop_batch(PyObject *self, PyObject *args)
{
	return call_voidarg_function(purify_stop_batch, self, args);
}
static PyObject*
pure_purify_name_thread(PyObject *self, PyObject *args)
{
        /* can't strictly use call_stringarg_function since
         * purify_name_thread takes a const char*, not a char*
         */
	int status;
	char* stringarg;

	if (!PyArg_ParseTuple(args, "s:purify_name_thread", &stringarg))
		return NULL;

	status = purify_name_thread(stringarg);
	return Py_BuildValue("i", status);
}
static PyObject*
pure_purify_watch(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch, self, args);
}
static PyObject*
pure_purify_watch_1(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_1, self, args);
}
static PyObject*
pure_purify_watch_2(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_2, self, args);
}
static PyObject*
pure_purify_watch_4(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_4, self, args);
}
static PyObject*
pure_purify_watch_8(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_8, self, args);
}
static PyObject*
pure_purify_watch_w_1(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_w_1, self, args);
}
static PyObject*
pure_purify_watch_w_2(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_w_2, self, args);
}
static PyObject*
pure_purify_watch_w_4(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_w_4, self, args);
}
static PyObject*
pure_purify_watch_w_8(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_w_8, self, args);
}
static PyObject*
pure_purify_watch_r_1(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_r_1, self, args);
}
static PyObject*
pure_purify_watch_r_2(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_r_2, self, args);
}
static PyObject*
pure_purify_watch_r_4(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_r_4, self, args);
}
static PyObject*
pure_purify_watch_r_8(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_r_8, self, args);
}
static PyObject*
pure_purify_watch_rw_1(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_rw_1, self, args);
}
static PyObject*
pure_purify_watch_rw_2(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_rw_2, self, args);
}
static PyObject*
pure_purify_watch_rw_4(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_rw_4, self, args);
}
static PyObject*
pure_purify_watch_rw_8(PyObject *self, PyObject *args)
{
	return call_intasaddr_function(purify_watch_rw_8, self, args);
}

static PyObject*
pure_purify_watch_n(PyObject *self, PyObject *args)
{
	long addrrep;
	unsigned int size;
	char* type;
	int status;

	if (!PyArg_ParseTuple(args, "lis:purify_watch_n", &addrrep, &size, &type))
		return NULL;

	status = purify_watch_n((char*)addrrep, size, type);
	return Py_BuildValue("i", status);
}

static PyObject*
pure_purify_watch_info(PyObject *self, PyObject *args)
{
	return call_voidarg_function(purify_watch_info, self, args);
}

static PyObject*
pure_purify_watch_remove(PyObject *self, PyObject *args)
{
	int watchno;
	int status;

	if (!PyArg_ParseTuple(args, "i:purify_watch_remove", &watchno))
		return NULL;

	status = purify_watch_remove(watchno);
	return Py_BuildValue("i", status);
}

static PyObject*
pure_purify_watch_remove_all(PyObject *self, PyObject *args)
{
	return call_voidarg_function(purify_watch_remove_all, self, args);
}
static PyObject*
pure_purify_describe(PyObject *self, PyObject *args)
{
	long addrrep;
	char* rtn;

	if (!PyArg_ParseTuple(args, "l:purify_describe", &addrrep))
		return NULL;

	rtn = purify_describe((char*)addrrep);
	return Py_BuildValue("l", (long)rtn);
}

static PyObject*
pure_purify_what_colors(PyObject *self, PyObject *args)
{
	long addrrep;
	unsigned int size;
	int status;
    
	if (!PyArg_ParseTuple(args, "li:purify_what_colors", &addrrep, &size))
		return NULL;

	status = purify_what_colors((char*)addrrep, size);
	return Py_BuildValue("i", status);
}

static PyObject*
pure_purify_is_running(PyObject *self, PyObject *args)
{
	return call_voidarg_function(purify_is_running, self, args);
}

static PyObject*
pure_purify_assert_is_readable(PyObject *self, PyObject *args)
{
	return call_stringandint_function(purify_assert_is_readable,
					  self, args);
}
static PyObject*
pure_purify_assert_is_writable(PyObject *self, PyObject *args)
{
	return call_stringandint_function(purify_assert_is_writable,
					  self, args);
}

#if HAS_PURIFY_EXIT

/* I wish I could include this, but I can't.  See the notes at the top of
 * the file.
 */

static PyObject*
pure_purify_exit(PyObject *self, PyObject *args)
{
	int status;

	if (!PyArg_ParseTuple(args, "i:purify_exit", &status))
		return NULL;

        /* purify_exit doesn't always act like exit(). See the manual */
	purify_exit(status);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -