PyAPI: fast keyword parsing for bpy modules
No functional changes.
This commit is contained in:
		@@ -118,10 +118,11 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
 | 
			
		||||
	bool absolute = false;
 | 
			
		||||
	bool packed   = false;
 | 
			
		||||
	bool local    = false;
 | 
			
		||||
	static const char *kwlist[] = {"absolute", "packed", "local", NULL};
 | 
			
		||||
 | 
			
		||||
	if (!PyArg_ParseTupleAndKeywords(
 | 
			
		||||
	        args, kw, "|O&O&O&:blend_paths", (char **)kwlist,
 | 
			
		||||
	static const char *_keywords[] = {"absolute", "packed", "local", NULL};
 | 
			
		||||
	static _PyArg_Parser _parser = {"|O&O&O&:blend_paths", _keywords, 0};
 | 
			
		||||
	if (!_PyArg_ParseTupleAndKeywordsFast(
 | 
			
		||||
	        args, kw, &_parser,
 | 
			
		||||
	        PyC_ParseBool, &absolute,
 | 
			
		||||
	        PyC_ParseBool, &packed,
 | 
			
		||||
	        PyC_ParseBool, &local))
 | 
			
		||||
@@ -147,13 +148,18 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
 | 
			
		||||
	const char *type;
 | 
			
		||||
	const char *subdir = NULL;
 | 
			
		||||
	int folder_id;
 | 
			
		||||
	static const char *kwlist[] = {"type", "subdir", NULL};
 | 
			
		||||
 | 
			
		||||
	const char *path;
 | 
			
		||||
 | 
			
		||||
	if (!PyArg_ParseTupleAndKeywords(args, kw, "s|s:user_resource", (char **)kwlist, &type, &subdir))
 | 
			
		||||
	static const char *_keywords[] = {"type", "subdir", NULL};
 | 
			
		||||
	static _PyArg_Parser _parser = {"s|s:user_resource", _keywords, 0};
 | 
			
		||||
	if (!_PyArg_ParseTupleAndKeywordsFast(
 | 
			
		||||
	        args, kw, &_parser,
 | 
			
		||||
	        &type, &subdir))
 | 
			
		||||
	{
 | 
			
		||||
		return NULL;
 | 
			
		||||
	
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* stupid string compare */
 | 
			
		||||
	if      (STREQ(type, "DATAFILES")) folder_id = BLENDER_USER_DATAFILES;
 | 
			
		||||
	else if (STREQ(type, "CONFIG"))    folder_id = BLENDER_USER_CONFIG;
 | 
			
		||||
@@ -191,12 +197,17 @@ static PyObject *bpy_resource_path(PyObject *UNUSED(self), PyObject *args, PyObj
 | 
			
		||||
{
 | 
			
		||||
	const char *type;
 | 
			
		||||
	int major = BLENDER_VERSION / 100, minor = BLENDER_VERSION % 100;
 | 
			
		||||
	static const char *kwlist[] = {"type", "major", "minor", NULL};
 | 
			
		||||
	int folder_id;
 | 
			
		||||
	const char *path;
 | 
			
		||||
 | 
			
		||||
	if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ii:resource_path", (char **)kwlist, &type, &major, &minor))
 | 
			
		||||
	static const char *_keywords[] = {"type", "major", "minor", NULL};
 | 
			
		||||
	static _PyArg_Parser _parser = {"s|ii:resource_path", _keywords, 0};
 | 
			
		||||
	if (!_PyArg_ParseTupleAndKeywordsFast(
 | 
			
		||||
	        args, kw, &_parser,
 | 
			
		||||
	        &type, &major, &minor))
 | 
			
		||||
	{
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* stupid string compare */
 | 
			
		||||
	if      (STREQ(type, "USER"))    folder_id = BLENDER_RESOURCE_PATH_USER;
 | 
			
		||||
 
 | 
			
		||||
@@ -183,17 +183,17 @@ PyDoc_STRVAR(bpy_lib_load_doc,
 | 
			
		||||
"   :arg relative: When True the path is stored relative to the open blend file.\n"
 | 
			
		||||
"   :type relative: bool\n"
 | 
			
		||||
);
 | 
			
		||||
static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
 | 
			
		||||
static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 | 
			
		||||
{
 | 
			
		||||
	static const char *kwlist[] = {"filepath", "link", "relative", NULL};
 | 
			
		||||
	Main *bmain = CTX_data_main(BPy_GetContext());
 | 
			
		||||
	BPy_Library *ret;
 | 
			
		||||
	const char *filename = NULL;
 | 
			
		||||
	bool is_rel = false, is_link = false;
 | 
			
		||||
 | 
			
		||||
	if (!PyArg_ParseTupleAndKeywords(
 | 
			
		||||
	        args, kwds,
 | 
			
		||||
	        "s|O&O&:load", (char **)kwlist,
 | 
			
		||||
	static const char *_keywords[] = {"filepath", "link", "relative", NULL};
 | 
			
		||||
	static _PyArg_Parser _parser = {"s|O&O&:load", _keywords, 0};
 | 
			
		||||
	if (!_PyArg_ParseTupleAndKeywordsFast(
 | 
			
		||||
	        args, kw, &_parser,
 | 
			
		||||
	        &filename,
 | 
			
		||||
	        PyC_ParseBool, &is_link,
 | 
			
		||||
	        PyC_ParseBool, &is_rel))
 | 
			
		||||
 
 | 
			
		||||
@@ -69,24 +69,23 @@ PyDoc_STRVAR(bpy_lib_write_doc,
 | 
			
		||||
"   :arg compress: When True, write a compressed blend file.\n"
 | 
			
		||||
"   :type compress: bool\n"
 | 
			
		||||
);
 | 
			
		||||
static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
 | 
			
		||||
static PyObject *bpy_lib_write(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 | 
			
		||||
{
 | 
			
		||||
	static const char *kwlist[] = {
 | 
			
		||||
		"filepath", "datablocks",
 | 
			
		||||
		/* optional */
 | 
			
		||||
		"relative_remap", "fake_user", "compress",
 | 
			
		||||
		NULL,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	/* args */
 | 
			
		||||
	const char *filepath;
 | 
			
		||||
	char filepath_abs[FILE_MAX];
 | 
			
		||||
	PyObject *datablocks = NULL;
 | 
			
		||||
	bool use_relative_remap = false, use_fake_user = false, use_compress = false;
 | 
			
		||||
 | 
			
		||||
	if (!PyArg_ParseTupleAndKeywords(
 | 
			
		||||
	        args, kwds,
 | 
			
		||||
	        "sO!|$O&O&O&:write", (char **)kwlist,
 | 
			
		||||
	static const char *_keywords[] = {
 | 
			
		||||
		"filepath", "datablocks",
 | 
			
		||||
		/* optional */
 | 
			
		||||
		"relative_remap", "fake_user", "compress",
 | 
			
		||||
		NULL,
 | 
			
		||||
	};
 | 
			
		||||
	static _PyArg_Parser _parser = {"sO!|$O&O&O&:write", _keywords, 0};
 | 
			
		||||
	if (!_PyArg_ParseTupleAndKeywordsFast(
 | 
			
		||||
	        args, kw, &_parser,
 | 
			
		||||
	        &filepath,
 | 
			
		||||
	        &PySet_Type, &datablocks,
 | 
			
		||||
	        PyC_ParseBool, &use_relative_remap,
 | 
			
		||||
 
 | 
			
		||||
@@ -163,7 +163,6 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
 | 
			
		||||
	Main *bmain = G.main;  /* XXX Ugly, but should work! */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	static const char *kwlist[] = {"subset", "key_types", "value_types", NULL};
 | 
			
		||||
	PyObject *subset = NULL;
 | 
			
		||||
 | 
			
		||||
	PyObject *key_types = NULL;
 | 
			
		||||
@@ -173,9 +172,10 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
 | 
			
		||||
 | 
			
		||||
	PyObject *ret = NULL;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (!PyArg_ParseTupleAndKeywords(
 | 
			
		||||
	        args, kwds, "|O$O!O!:user_map", (char **)kwlist,
 | 
			
		||||
	static const char *_keywords[] = {"subset", "key_types", "value_types", NULL};
 | 
			
		||||
	static _PyArg_Parser _parser = {"|O$O!O!:user_map", _keywords, 0};
 | 
			
		||||
	if (!_PyArg_ParseTupleAndKeywordsFast(
 | 
			
		||||
	        args, kwds, &_parser,
 | 
			
		||||
	        &subset,
 | 
			
		||||
	        &PySet_Type, &key_types,
 | 
			
		||||
	        &PySet_Type, &val_types))
 | 
			
		||||
 
 | 
			
		||||
@@ -174,8 +174,6 @@ PyDoc_STRVAR(bpyunits_to_value_doc,
 | 
			
		||||
);
 | 
			
		||||
static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 | 
			
		||||
{
 | 
			
		||||
	static const char *kwlist[] = {"unit_system", "unit_category", "str_input", "str_ref_unit", NULL};
 | 
			
		||||
 | 
			
		||||
	char *usys_str = NULL, *ucat_str = NULL, *inpt = NULL, *uref = NULL;
 | 
			
		||||
	const float scale = 1.0f;
 | 
			
		||||
 | 
			
		||||
@@ -185,8 +183,13 @@ static PyObject *bpyunits_to_value(PyObject *UNUSED(self), PyObject *args, PyObj
 | 
			
		||||
	int usys, ucat;
 | 
			
		||||
	PyObject *ret;
 | 
			
		||||
 | 
			
		||||
	if (!PyArg_ParseTupleAndKeywords(args, kw, "sss#|z:bpy.utils.units.to_value", (char **)kwlist,
 | 
			
		||||
	                                 &usys_str, &ucat_str, &inpt, &str_len, &uref))
 | 
			
		||||
	static const char *_keywords[] = {
 | 
			
		||||
		"unit_system", "unit_category", "str_input", "str_ref_unit", NULL,
 | 
			
		||||
	};
 | 
			
		||||
	static _PyArg_Parser _parser = {"sss#|z:to_value", _keywords, 0};
 | 
			
		||||
	if (!_PyArg_ParseTupleAndKeywordsFast(
 | 
			
		||||
	        args, kw, &_parser,
 | 
			
		||||
	        &usys_str, &ucat_str, &inpt, &str_len, &uref))
 | 
			
		||||
	{
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
@@ -244,9 +247,6 @@ PyDoc_STRVAR(bpyunits_to_string_doc,
 | 
			
		||||
);
 | 
			
		||||
static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 | 
			
		||||
{
 | 
			
		||||
	static const char *kwlist[] = {"unit_system", "unit_category", "value",
 | 
			
		||||
	                               "precision", "split_unit", "compatible_unit", NULL};
 | 
			
		||||
 | 
			
		||||
	char *usys_str = NULL, *ucat_str = NULL;
 | 
			
		||||
	double value = 0.0;
 | 
			
		||||
	int precision = 3;
 | 
			
		||||
@@ -254,9 +254,13 @@ static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyOb
 | 
			
		||||
 | 
			
		||||
	int usys, ucat;
 | 
			
		||||
 | 
			
		||||
	if (!PyArg_ParseTupleAndKeywords(
 | 
			
		||||
	        args, kw,
 | 
			
		||||
	        "ssd|iO&O&:bpy.utils.units.to_string", (char **)kwlist,
 | 
			
		||||
	static const char *_keywords[] = {
 | 
			
		||||
		"unit_system", "unit_category", "value",
 | 
			
		||||
		"precision", "split_unit", "compatible_unit", NULL,
 | 
			
		||||
	};
 | 
			
		||||
	static _PyArg_Parser _parser = {"ssd|iO&O&:to_string", _keywords, 0};
 | 
			
		||||
	if (!_PyArg_ParseTupleAndKeywordsFast(
 | 
			
		||||
	        args, kw, &_parser,
 | 
			
		||||
	        &usys_str, &ucat_str, &value, &precision,
 | 
			
		||||
	        PyC_ParseBool, &split_unit,
 | 
			
		||||
	        PyC_ParseBool, &compatible_unit))
 | 
			
		||||
 
 | 
			
		||||
@@ -207,7 +207,7 @@ PyDoc_STRVAR(GPU_export_shader_doc,
 | 
			
		||||
"   :return: Dictionary defining the shader, uniforms and attributes.\n"
 | 
			
		||||
"   :rtype: Dict"
 | 
			
		||||
);
 | 
			
		||||
static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
 | 
			
		||||
static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 | 
			
		||||
{
 | 
			
		||||
	PyObject *pyscene;
 | 
			
		||||
	PyObject *pymat;
 | 
			
		||||
@@ -224,11 +224,14 @@ static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObj
 | 
			
		||||
	GPUInputUniform *uniform;
 | 
			
		||||
	GPUInputAttribute *attribute;
 | 
			
		||||
 | 
			
		||||
	static const char *kwlist[] = {"scene", "material", NULL};
 | 
			
		||||
 | 
			
		||||
	if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO:export_shader", (char **)(kwlist), &pyscene, &pymat))
 | 
			
		||||
	static const char *_keywords[] = {"scene", "material", NULL};
 | 
			
		||||
	static _PyArg_Parser _parser = {"OO:export_shader", _keywords, 0};
 | 
			
		||||
	if (!_PyArg_ParseTupleAndKeywordsFast(
 | 
			
		||||
	        args, kw, &_parser,
 | 
			
		||||
	        &pyscene, &pymat))
 | 
			
		||||
	{
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	scene = (Scene *)PyC_RNA_AsPointer(pyscene, "Scene");
 | 
			
		||||
	if (scene == NULL) {
 | 
			
		||||
		return NULL;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user