[#18961] Use const char * where appropriate (2.5)

from Sean Bartell (wtachi) 

added own changes bpy_props.c
This commit is contained in:
Campbell Barton
2010-02-16 16:47:41 +00:00
parent ed540dd1f1
commit aefe9be5db
12 changed files with 55 additions and 46 deletions

View File

@@ -122,7 +122,7 @@ extern "C" {
void MEM_printmemlist_stats(void);
/** Set the callback function for error output. */
void MEM_set_error_callback(void (*func)(char *));
void MEM_set_error_callback(void (*func)(const char *));
/**
* Are the start/end block markers still correct ?

View File

@@ -135,7 +135,7 @@ static volatile uintptr_t mem_in_use= 0, mmap_in_use= 0;
static volatile struct localListBase _membase;
static volatile struct localListBase *membase = &_membase;
static void (*error_callback)(char *) = NULL;
static void (*error_callback)(const char *) = NULL;
static void (*thread_lock_callback)(void) = NULL;
static void (*thread_unlock_callback)(void) = NULL;
@@ -197,7 +197,7 @@ int MEM_check_memory_integrity()
}
void MEM_set_error_callback(void (*func)(char *))
void MEM_set_error_callback(void (*func)(const char *))
{
error_callback = func;
}

View File

@@ -47,6 +47,12 @@
#include <config.h>
#endif
static void mem_error_cb(const char *errorStr)
{
fprintf(stderr, "%s", errorStr);
fflush(stderr);
}
int main (int argc, char *argv[])
{
int verbose = 0;
@@ -75,7 +81,7 @@ int main (int argc, char *argv[])
/* Round one, do a normal allocation, and free the blocks again. */
/* ----------------------------------------------------------------- */
/* flush mem lib output to stderr */
MEM_set_error_callback(stderr);
MEM_set_error_callback(mem_error_cb);
for (i = 0; i < NUM_BLOCKS; i++) {
int blocksize = 10000;

View File

@@ -2590,7 +2590,7 @@ static int rna_preprocess(char *outfile)
return status;
}
static void mem_error_cb(char *errorStr)
static void mem_error_cb(const char *errorStr)
{
fprintf(stderr, "%s", errorStr);
fflush(stderr);

View File

@@ -122,7 +122,7 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
char *pysubtype= NULL;
int subtype= PROP_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiO!s:BoolProperty", kwlist, &id, &name, &description, &def, &PySet_Type, &pyopts, &pysubtype))
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiO!s:BoolProperty", (char **)kwlist, &id, &name, &description, &def, &PySet_Type, &pyopts, &pysubtype))
return NULL;
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "BoolProperty(options={...}):"))
@@ -173,7 +173,7 @@ PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
return NULL; /* self's type was compatible but error getting the srna */
}
else if(srna) {
static char *kwlist[] = {"attr", "name", "description", "default", "options", "subtype", "size", NULL};
static const char *kwlist[] = {"attr", "name", "description", "default", "options", "subtype", "size", NULL};
char *id=NULL, *name="", *description="";
int def[PYRNA_STACK_ARRAY]={0};
int size=3;
@@ -184,7 +184,7 @@ PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
char *pysubtype= NULL;
int subtype= PROP_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOO!si:BoolVectorProperty", kwlist, &id, &name, &description, &pydef, &PySet_Type, &pyopts, &pysubtype, &size))
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOO!si:BoolVectorProperty", (char **)kwlist, &id, &name, &description, &pydef, &PySet_Type, &pyopts, &pysubtype, &size))
return NULL;
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "BoolVectorProperty(options={...}):"))
@@ -244,7 +244,7 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
return NULL; /* self's type was compatible but error getting the srna */
}
else if(srna) {
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", NULL};
static const char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", NULL};
char *id=NULL, *name="", *description="";
int min=INT_MIN, max=INT_MAX, soft_min=INT_MIN, soft_max=INT_MAX, step=1, def=0;
PropertyRNA *prop;
@@ -253,7 +253,7 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
char *pysubtype= NULL;
int subtype= PROP_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiiiiiiO!s:IntProperty", kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &PySet_Type, &pyopts, &pysubtype))
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssiiiiiiO!s:IntProperty", (char **)kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &PySet_Type, &pyopts, &pysubtype))
return NULL;
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "IntProperty(options={...}):"))
@@ -305,7 +305,7 @@ PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
return NULL; /* self's type was compatible but error getting the srna */
}
else if(srna) {
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "size", NULL};
static const char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "size", NULL};
char *id=NULL, *name="", *description="";
int min=INT_MIN, max=INT_MAX, soft_min=INT_MIN, soft_max=INT_MAX, step=1, def[PYRNA_STACK_ARRAY]={0};
int size=3;
@@ -316,7 +316,7 @@ PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
char *pysubtype= NULL;
int subtype= PROP_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOiiiiO!si:IntVectorProperty", kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &PySet_Type, &pyopts, &pysubtype, &size))
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOiiiiO!si:IntVectorProperty", (char **)kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &PySet_Type, &pyopts, &pysubtype, &size))
return NULL;
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "IntVectorProperty(options={...}):"))
@@ -380,7 +380,7 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
return NULL; /* self's type was compatible but error getting the srna */
}
else if(srna) {
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "unit", NULL};
static const char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "unit", NULL};
char *id=NULL, *name="", *description="";
float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def=0.0f;
int precision= 2;
@@ -392,7 +392,7 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
char *pyunit= NULL;
int unit= PROP_UNIT_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssffffffiO!ss:FloatProperty", kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &pyunit))
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssffffffiO!ss:FloatProperty", (char **)kwlist, &id, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &pyunit))
return NULL;
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "FloatProperty(options={...}):"))
@@ -449,7 +449,7 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
return NULL; /* self's type was compatible but error getting the srna */
}
else if(srna) {
static char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "size", NULL};
static const char *kwlist[] = {"attr", "name", "description", "default", "min", "max", "soft_min", "soft_max", "step", "precision", "options", "subtype", "size", NULL};
char *id=NULL, *name="", *description="";
float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def[PYRNA_STACK_ARRAY]={0.0f};
int precision= 2, size=3;
@@ -460,7 +460,7 @@ PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObject *kw)
char *pysubtype= NULL;
int subtype= PROP_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOfffffiO!si:FloatVectorProperty", kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &size))
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssOfffffiO!si:FloatVectorProperty", (char **)kwlist, &id, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &size))
return NULL;
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "FloatVectorProperty(options={...}):"))
@@ -521,7 +521,7 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
return NULL; /* self's type was compatible but error getting the srna */
}
else if(srna) {
static char *kwlist[] = {"attr", "name", "description", "default", "maxlen", "options", "subtype", NULL};
static const char *kwlist[] = {"attr", "name", "description", "default", "maxlen", "options", "subtype", NULL};
char *id=NULL, *name="", *description="", *def="";
int maxlen=0;
PropertyRNA *prop;
@@ -530,7 +530,7 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw)
char *pysubtype= NULL;
int subtype= PROP_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|sssiO!s:StringProperty", kwlist, &id, &name, &description, &def, &maxlen, &PySet_Type, &pyopts, &pysubtype))
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|sssiO!s:StringProperty", (char **)kwlist, &id, &name, &description, &def, &maxlen, &PySet_Type, &pyopts, &pysubtype))
return NULL;
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "StringProperty(options={...}):"))
@@ -627,7 +627,7 @@ PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
return NULL; /* self's type was compatible but error getting the srna */
}
else if(srna) {
static char *kwlist[] = {"attr", "items", "name", "description", "default", "options", NULL};
static const char *kwlist[] = {"attr", "items", "name", "description", "default", "options", NULL};
char *id=NULL, *name="", *description="", *def="";
int defvalue=0;
PyObject *items= Py_None;
@@ -636,7 +636,7 @@ PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject *pyopts= NULL;
int opts=0;
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|sssO!:EnumProperty", kwlist, &id, &items, &name, &description, &def, &PySet_Type, &pyopts))
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|sssO!:EnumProperty", (char **)kwlist, &id, &items, &name, &description, &def, &PySet_Type, &pyopts))
return NULL;
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "EnumProperty(options={...}):"))
@@ -702,7 +702,7 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
return NULL; /* self's type was compatible but error getting the srna */
}
else if(srna) {
static char *kwlist[] = {"attr", "type", "name", "description", "options", NULL};
static const char *kwlist[] = {"attr", "type", "name", "description", "options", NULL};
char *id=NULL, *name="", *description="";
PropertyRNA *prop;
StructRNA *ptype;
@@ -710,7 +710,7 @@ PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject *pyopts= NULL;
int opts=0;
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssO!:PointerProperty", kwlist, &id, &type, &name, &description, &PySet_Type, &pyopts))
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssO!:PointerProperty", (char **)kwlist, &id, &type, &name, &description, &PySet_Type, &pyopts))
return NULL;
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "PointerProperty(options={...}):"))
@@ -757,7 +757,7 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
return NULL; /* self's type was compatible but error getting the srna */
}
else if(srna) {
static char *kwlist[] = {"attr", "type", "name", "description", "options", NULL};
static const char *kwlist[] = {"attr", "type", "name", "description", "options", NULL};
char *id=NULL, *name="", *description="";
PropertyRNA *prop;
StructRNA *ptype;
@@ -765,7 +765,7 @@ PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject *pyopts= NULL;
int opts=0;
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssO!:CollectionProperty", kwlist, &id, &type, &name, &description, &PySet_Type, &pyopts))
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|ssO!:CollectionProperty", (char **)kwlist, &id, &type, &name, &description, &PySet_Type, &pyopts))
return NULL;
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "CollectionProperty(options={...}):"))

View File

@@ -1053,7 +1053,7 @@ static void error_cb(char *err)
printf("%s\n", err); /* XXX do this in WM too */
}
static void mem_error_cb(char *errorStr)
static void mem_error_cb(const char *errorStr)
{
fputs(errorStr, stderr);
fflush(stderr);

View File

@@ -30,7 +30,7 @@ template <class PyObj> class BlendType
{
public:
/// constructor
BlendType (char * name) : m_name(name) {}
BlendType (const char * name) : m_name(name) {}
/// check blender type and return pointer to contained object or NULL (if type is not valid)
PyObj * checkType (PyObject * obj)
@@ -68,7 +68,7 @@ public:
protected:
/// name of Python type
char * m_name;
const char * m_name;
/// pointer to Python type
PyTypeObject * m_objType;
};

View File

@@ -41,7 +41,7 @@ ExpDesc errNFoundDesc (ErrNotFound, "Error description not found");
// implementation of ExpDesc
// constructor
ExpDesc::ExpDesc (ExceptionID & exp, char * desc, RESULT hres)
ExpDesc::ExpDesc (ExceptionID & exp, const char * desc, RESULT hres)
: m_expID(exp), m_hRslt(hres), m_description(desc)
{
}
@@ -60,7 +60,7 @@ std::vector<ExpDesc*> ExpDesc::m_expDescs;
std::string Exception::m_lastError;
// log file name
char * Exception::m_logFile = NULL;
const char * Exception::m_logFile = NULL;
// basic constructor
@@ -98,7 +98,7 @@ const char * Exception::what()
// debug version - with file and line of exception
Exception::Exception (ExceptionID & expID, RESULT rslt, char * fil, int lin)
Exception::Exception (ExceptionID & expID, RESULT rslt, const char * fil, int lin)
: m_expID (&expID), m_hRslt (rslt)
{
// set file and line
@@ -108,7 +108,7 @@ Exception::Exception (ExceptionID & expID, RESULT rslt, char * fil, int lin)
// set file and line
void Exception::setFileLine (char * fil, int lin)
void Exception::setFileLine (const char * fil, int lin)
{
if (fil != NULL) m_fileName = fil;
m_line = lin;

View File

@@ -91,7 +91,7 @@ class ExpDesc
{
public:
// constructor a destructor
ExpDesc (ExceptionID & exp, char * desc, RESULT hres = S_OK);
ExpDesc (ExceptionID & exp, const char * desc, RESULT hres = S_OK);
~ExpDesc (void);
// comparision function
@@ -132,7 +132,7 @@ private:
// result
RESULT m_hRslt;
// description
char * m_description;
const char * m_description;
// not allowed
ExpDesc (const ExpDesc & obj) : m_expID (ErrNotFound) {}
@@ -157,9 +157,9 @@ public:
virtual const char * what(void);
// debug version of constructor
Exception (ExceptionID & expID, RESULT rslt, char * fil, int lin);
Exception (ExceptionID & expID, RESULT rslt, const char * fil, int lin);
// set source file and line of exception
void setFileLine (char * fil, int lin);
void setFileLine (const char * fil, int lin);
// get description in string
std::string & getDesc (void) throw() { return m_desc; }
@@ -174,7 +174,7 @@ public:
static std::string m_lastError;
/// log file name
static char * m_logFile;
static const char * m_logFile;
protected:
// exception identification

View File

@@ -282,9 +282,10 @@ static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds
// camera object
PyObject * camera;
// parameter keywords
static char *kwlist[] = {"sceneObj", "cameraObj", NULL};
static const char *kwlist[] = {"sceneObj", "cameraObj", NULL};
// get parameters
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &scene, &camera))
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO",
const_cast<char**>(kwlist), &scene, &camera))
return -1;
try
{
@@ -428,9 +429,10 @@ static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds
// material of the mirror
short materialID = 0;
// parameter keywords
static char *kwlist[] = {"scene", "observer", "mirror", "material", NULL};
static const char *kwlist[] = {"scene", "observer", "mirror", "material", NULL};
// get parameters
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOO|h", kwlist, &scene, &observer, &mirror, &materialID))
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOO|h",
const_cast<char**>(kwlist), &scene, &observer, &mirror, &materialID))
return -1;
try
{

View File

@@ -186,11 +186,12 @@ int Texture_init (Texture *self, PyObject *args, PyObject *kwds)
// texture object with shared texture ID
Texture * texObj = NULL;
static char *kwlist[] = {"gameObj", "materialID", "textureID", "textureObj", NULL};
static const char *kwlist[] = {"gameObj", "materialID", "textureID", "textureObj", NULL};
// get parameters
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|hhO!", kwlist, &obj, &matID,
&texID, &TextureType, &texObj))
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|hhO!",
const_cast<char**>(kwlist), &obj, &matID, &texID, &TextureType,
&texObj))
return -1;
// if parameters are available

View File

@@ -1074,11 +1074,11 @@ static int VideoFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds
// capture rate, only if capt is >= 0
float rate = 25.f;
static char *kwlist[] = {"file", "capture", "rate", "width", "height", NULL};
static const char *kwlist[] = {"file", "capture", "rate", "width", "height", NULL};
// get parameters
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|hfhh", kwlist, &file, &capt,
&rate, &width, &height))
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|hfhh",
const_cast<char**>(kwlist), &file, &capt, &rate, &width, &height))
return -1;
try