fix for building, also use const char in more places.

This commit is contained in:
Campbell Barton 2010-11-11 07:51:12 +00:00
parent 80a650dfb1
commit 030253cdf6
12 changed files with 86 additions and 90 deletions

View File

@ -34,11 +34,11 @@ struct rctf;
int BLF_init(int points, int dpi);
void BLF_exit(void);
int BLF_load(char *name);
int BLF_load_mem(char *name, unsigned char *mem, int mem_size);
int BLF_load(const char *name);
int BLF_load_mem(const char *name, unsigned char *mem, int mem_size);
int BLF_load_unique(char *name);
int BLF_load_mem_unique(char *name, unsigned char *mem, int mem_size);
int BLF_load_unique(const char *name);
int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size);
/* Attach a file with metrics information from memory. */
void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size);
@ -59,21 +59,21 @@ void BLF_draw_ascii(int fontid, const char *str, size_t len);
* This function return the bounding box of the string
* and are not multiplied by the aspect.
*/
void BLF_boundbox(int fontid, char *str, struct rctf *box);
void BLF_boundbox(int fontid, const char *str, struct rctf *box);
/*
* The next both function return the width and height
* of the string, using the current font and both value
* are multiplied by the aspect of the font.
*/
float BLF_width(int fontid, char *str);
float BLF_height(int fontid, char *str);
float BLF_width(int fontid, const char *str);
float BLF_height(int fontid, const char *str);
/*
* The following function return the width and height of the string, but
* just in one call, so avoid extra freetype2 stuff.
*/
void BLF_width_and_height(int fontid, char *str, float *width, float *height);
void BLF_width_and_height(int fontid, const char *str, float *width, float *height);
/*
* For fixed width fonts only, returns the width of a
@ -86,8 +86,8 @@ float BLF_fixed_width(int fontid);
* of the string, using the default font and both value
* are multiplied by the aspect of the font.
*/
float BLF_width_default(char *str);
float BLF_height_default(char *str);
float BLF_width_default(const char *str);
float BLF_height_default(const char *str);
/*
* Set rotation for default font.
@ -147,7 +147,7 @@ void BLF_buffer_col(int fontid, float r, float g, float b, float a);
* Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_
* it's not necessary set both buffer, NULL is valid here.
*/
void BLF_draw_buffer(int fontid, char *str);
void BLF_draw_buffer(int fontid, const char *str);
/*
* Search the path directory to the locale files, this try all

View File

@ -99,7 +99,7 @@ void BLF_exit(void)
blf_font_exit();
}
static int blf_search(char *name)
static int blf_search(const char *name)
{
FontBLF *font;
int i;
@ -112,7 +112,7 @@ static int blf_search(char *name)
return(-1);
}
int BLF_load(char *name)
int BLF_load(const char *name)
{
FontBLF *font;
char *filename;
@ -153,7 +153,7 @@ int BLF_load(char *name)
return(i);
}
int BLF_load_unique(char *name)
int BLF_load_unique(const char *name)
{
FontBLF *font;
char *filename;
@ -199,7 +199,7 @@ void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size)
blf_font_attach_from_mem(font, mem, mem_size);
}
int BLF_load_mem(char *name, unsigned char *mem, int mem_size)
int BLF_load_mem(const char *name, unsigned char *mem, int mem_size)
{
FontBLF *font;
int i;
@ -235,7 +235,7 @@ int BLF_load_mem(char *name, unsigned char *mem, int mem_size)
return(i);
}
int BLF_load_mem_unique(char *name, unsigned char *mem, int mem_size)
int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size)
{
FontBLF *font;
int i;
@ -452,7 +452,7 @@ void BLF_draw_ascii(int fontid, const char *str, size_t len)
}
}
void BLF_boundbox(int fontid, char *str, rctf *box)
void BLF_boundbox(int fontid, const char *str, rctf *box)
{
FontBLF *font;
@ -461,7 +461,7 @@ void BLF_boundbox(int fontid, char *str, rctf *box)
blf_font_boundbox(font, str, box);
}
void BLF_width_and_height(int fontid, char *str, float *width, float *height)
void BLF_width_and_height(int fontid, const char *str, float *width, float *height)
{
FontBLF *font;
@ -470,7 +470,7 @@ void BLF_width_and_height(int fontid, char *str, float *width, float *height)
blf_font_width_and_height(font, str, width, height);
}
float BLF_width(int fontid, char *str)
float BLF_width(int fontid, const char *str)
{
FontBLF *font;
@ -490,7 +490,7 @@ float BLF_fixed_width(int fontid)
return(0.0f);
}
float BLF_width_default(char *str)
float BLF_width_default(const char *str)
{
float width;
@ -507,7 +507,7 @@ float BLF_width_default(char *str)
return(width);
}
float BLF_height(int fontid, char *str)
float BLF_height(int fontid, const char *str)
{
FontBLF *font;
@ -517,7 +517,7 @@ float BLF_height(int fontid, char *str)
return(0.0f);
}
float BLF_height_default(char *str)
float BLF_height_default(const char *str)
{
float height;
@ -621,7 +621,7 @@ void BLF_buffer_col(int fontid, float r, float g, float b, float a)
}
}
void BLF_draw_buffer(int fontid, char *str)
void BLF_draw_buffer(int fontid, const char *str)
{
FontBLF *font;

View File

@ -121,7 +121,7 @@ void BLF_dir_free(char **dirs, int count)
MEM_freeN(dirs);
}
char *blf_dir_search(char *file)
char *blf_dir_search(const char *file)
{
DirBLF *dir;
char full_path[FILE_MAXDIR+FILE_MAXFILE];
@ -175,7 +175,7 @@ int blf_dir_split(const char *str, char *file, int *size)
/* Some font have additional file with metrics information,
* in general, the extension of the file is: .afm or .pfm
*/
char *blf_dir_metrics_search(char *filename)
char *blf_dir_metrics_search(const char *filename)
{
char *mfile;
char *s;

View File

@ -205,7 +205,7 @@ void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len)
}
}
void blf_font_buffer(FontBLF *font, char *str)
void blf_font_buffer(FontBLF *font, const char *str)
{
unsigned char *cbuf;
unsigned int c;
@ -339,7 +339,7 @@ void blf_font_buffer(FontBLF *font, char *str)
}
}
void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
void blf_font_boundbox(FontBLF *font, const char *str, rctf *box)
{
unsigned int c;
GlyphBLF *g, *g_prev;
@ -418,7 +418,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box)
}
}
void blf_font_width_and_height(FontBLF *font, char *str, float *width, float *height)
void blf_font_width_and_height(FontBLF *font, const char *str, float *width, float *height)
{
rctf box;
@ -429,7 +429,7 @@ void blf_font_width_and_height(FontBLF *font, char *str, float *width, float *he
}
}
float blf_font_width(FontBLF *font, char *str)
float blf_font_width(FontBLF *font, const char *str)
{
rctf box;
@ -440,7 +440,7 @@ float blf_font_width(FontBLF *font, char *str)
return((box.xmax - box.xmin) * font->aspect);
}
float blf_font_height(FontBLF *font, char *str)
float blf_font_height(FontBLF *font, const char *str)
{
rctf box;
@ -523,7 +523,7 @@ static void blf_font_fill(FontBLF *font)
memset(font->glyph_ascii_table, 0, sizeof(font->glyph_ascii_table));
}
FontBLF *blf_font_new(char *name, char *filename)
FontBLF *blf_font_new(const char *name, const char *filename)
{
FontBLF *font;
FT_Error err;
@ -566,7 +566,7 @@ void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_s
FT_Attach_Stream(font->face, &open);
}
FontBLF *blf_font_new_from_mem(char *name, unsigned char *mem, int mem_size)
FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_size)
{
FontBLF *font;
FT_Error err;

View File

@ -33,24 +33,24 @@ unsigned int blf_hash(unsigned int val);
int blf_utf8_next(unsigned char *buf, int *iindex);
char *blf_dir_search(const char *file);
char *blf_dir_metrics_search(char *filename);
char *blf_dir_metrics_search(const char *filename);
int blf_dir_split(const char *str, char *file, int *size);
int blf_font_init(void);
void blf_font_exit(void);
FontBLF *blf_font_new(char *name, char *filename);
FontBLF *blf_font_new_from_mem(char *name, unsigned char *mem, int mem_size);
FontBLF *blf_font_new(const char *name, const char *filename);
FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_size);
void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_size);
void blf_font_size(FontBLF *font, int size, int dpi);
void blf_font_draw(FontBLF *font, const char *str, unsigned int len);
void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len);
void blf_font_buffer(FontBLF *font, char *str);
void blf_font_boundbox(FontBLF *font, char *str, rctf *box);
void blf_font_width_and_height(FontBLF *font, char *str, float *width, float *height);
float blf_font_width(FontBLF *font, char *str);
float blf_font_height(FontBLF *font, char *str);
void blf_font_buffer(FontBLF *font, const char *str);
void blf_font_boundbox(FontBLF *font, const char *str, rctf *box);
void blf_font_width_and_height(FontBLF *font, const char *str, float *width, float *height);
float blf_font_width(FontBLF *font, const char *str);
float blf_font_height(FontBLF *font, const char *str);
float blf_font_fixed_width(FontBLF *font);
void blf_font_free(FontBLF *font);

View File

@ -41,39 +41,39 @@ struct BPathIteratorSeqData {
struct BPathIterator {
char* path;
char* lib;
char* name;
const char* lib;
const char* name;
void* data;
int len;
int type;
void (*setpath_callback)(struct BPathIterator *, char *);
void (*setpath_callback)(struct BPathIterator *, const char *);
void (*getpath_callback)(struct BPathIterator *, char *);
char* base_path; /* base path, the directry the blend file is in - normally G.main->name */
const char* base_path; /* base path, the directry the blend file is in - normally G.main->name */
/* only for seq data */
struct BPathIteratorSeqData seqdata;
};
void BLI_bpathIterator_init (struct BPathIterator *bpi, char *base_path);
void BLI_bpathIterator_init (struct BPathIterator *bpi, const char *base_path);
void BLI_bpathIterator_free (struct BPathIterator *bpi);
char* BLI_bpathIterator_getLib (struct BPathIterator *bpi);
char* BLI_bpathIterator_getName (struct BPathIterator *bpi);
const char* BLI_bpathIterator_getLib (struct BPathIterator *bpi);
const char* BLI_bpathIterator_getName (struct BPathIterator *bpi);
int BLI_bpathIterator_getType (struct BPathIterator *bpi);
int BLI_bpathIterator_getPathMaxLen (struct BPathIterator *bpi);
void BLI_bpathIterator_step (struct BPathIterator *bpi);
int BLI_bpathIterator_isDone (struct BPathIterator *bpi);
void BLI_bpathIterator_getPath (struct BPathIterator *bpi, char *path);
void BLI_bpathIterator_getPathExpanded (struct BPathIterator *bpi, char *path_expanded);
void BLI_bpathIterator_setPath (struct BPathIterator *bpi, char *path);
void BLI_bpathIterator_setPath (struct BPathIterator *bpi, const char *path);
/* high level funcs */
/* creates a text file with missing files if there are any */
void checkMissingFiles(char *basepath, ReportList *reports);
void makeFilesRelative(char *basepath, ReportList *reports);
void makeFilesAbsolute(char *basepath, ReportList *reports);
void findMissingFiles(char *basepath, char *str);
void checkMissingFiles(const char *basepath, ReportList *reports);
void makeFilesRelative(const char *basepath, ReportList *reports);
void makeFilesAbsolute(const char *basepath, ReportList *reports);
void findMissingFiles(const char *basepath, const char *str);
#endif // BLI_BPATH_H

View File

@ -38,19 +38,19 @@ struct direntry;
void BLI_adddirstrings(void);
void BLI_builddir(char *dirname, char *relname);
void BLI_builddir(const char *dirname, const char *relname);
int BLI_compare(struct direntry *entry1, struct direntry *entry2);
size_t BLI_filesize(int file);
size_t BLI_filepathsize(const char *path);
double BLI_diskfree(char *dir);
char *BLI_getwdN(char *dir);
double BLI_diskfree(const char *dir);
char *BLI_getwdN(const char *dir);
unsigned int BLI_getdir(char *dirname, struct direntry **filelist);
unsigned int BLI_getdir(const char *dirname, struct direntry **filelist);
/**
* @attention Do not confuse with BLI_exists
*/
int BLI_exist(char *name);
int BLI_exist(const char *name);
/**
* Read a file as ASCII lines. An empty list is
* returned if the file cannot be opened or read.
@ -62,9 +62,9 @@ int BLI_exist(char *name);
* @retval A list of strings representing the file lines.
*/
int BLI_is_dir(char *file);
int BLI_is_dir(const char *file);
struct LinkNode *BLI_read_file_as_lines(char *name);
struct LinkNode *BLI_read_file_as_lines(const char *name);
/**
* Free the list returned by BLI_read_file_as_lines.

View File

@ -79,7 +79,7 @@ enum BPathTypes {
BPATH_DONE
};
void BLI_bpathIterator_init( struct BPathIterator *bpi, char *base_path ) {
void BLI_bpathIterator_init( struct BPathIterator *bpi, const char *base_path ) {
bpi->type = BPATH_IMAGE;
bpi->data = NULL;
@ -112,7 +112,7 @@ void BLI_bpathIterator_getPath( struct BPathIterator *bpi, char *path) {
}
}
void BLI_bpathIterator_setPath( struct BPathIterator *bpi, char *path) {
void BLI_bpathIterator_setPath( struct BPathIterator *bpi, const char *path) {
if (bpi->setpath_callback) {
bpi->setpath_callback( bpi, path );
} else {
@ -121,7 +121,7 @@ void BLI_bpathIterator_setPath( struct BPathIterator *bpi, char *path) {
}
void BLI_bpathIterator_getPathExpanded( struct BPathIterator *bpi, char *path_expanded) {
char *libpath;
const char *libpath;
BLI_bpathIterator_getPath(bpi, path_expanded);
libpath = BLI_bpathIterator_getLib(bpi);
@ -133,10 +133,10 @@ void BLI_bpathIterator_getPathExpanded( struct BPathIterator *bpi, char *path_ex
}
BLI_cleanup_file(NULL, path_expanded);
}
char* BLI_bpathIterator_getLib( struct BPathIterator *bpi) {
const char* BLI_bpathIterator_getLib( struct BPathIterator *bpi) {
return bpi->lib;
}
char* BLI_bpathIterator_getName( struct BPathIterator *bpi) {
const char* BLI_bpathIterator_getName( struct BPathIterator *bpi) {
return bpi->name;
}
int BLI_bpathIterator_getType( struct BPathIterator *bpi) {
@ -275,7 +275,7 @@ static void seq_getpath(struct BPathIterator *bpi, char *path) {
}
}
static void seq_setpath(struct BPathIterator *bpi, char *path) {
static void seq_setpath(struct BPathIterator *bpi, const char *path) {
Sequence *seq = (Sequence *)bpi->data;
if (seq==NULL) return;
@ -443,7 +443,7 @@ int BLI_bpathIterator_isDone( struct BPathIterator *bpi) {
static void bpath_as_report(struct BPathIterator *bpi, const char *message, ReportList *reports)
{
char *prefix;
char *name;
const char *name;
char path_expanded[FILE_MAXDIR*2];
if(reports==NULL)
@ -484,7 +484,7 @@ static void bpath_as_report(struct BPathIterator *bpi, const char *message, Repo
}
/* high level function */
void checkMissingFiles(char *basepath, ReportList *reports) {
void checkMissingFiles(const char *basepath, ReportList *reports) {
struct BPathIterator bpi;
/* be sure there is low chance of the path being too short */
@ -503,10 +503,11 @@ void checkMissingFiles(char *basepath, ReportList *reports) {
}
/* dont log any errors at the moment, should probably do this */
void makeFilesRelative(char *basepath, ReportList *reports) {
void makeFilesRelative(const char *basepath, ReportList *reports) {
int tot= 0, changed= 0, failed= 0, linked= 0;
struct BPathIterator bpi;
char filepath[FILE_MAX], *libpath;
char filepath[FILE_MAX];
const char *libpath;
/* be sure there is low chance of the path being too short */
char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE];
@ -551,12 +552,13 @@ void makeFilesRelative(char *basepath, ReportList *reports) {
/* dont log any errors at the moment, should probably do this -
* Verry similar to makeFilesRelative - keep in sync! */
void makeFilesAbsolute(char *basepath, ReportList *reports)
void makeFilesAbsolute(const char *basepath, ReportList *reports)
{
int tot= 0, changed= 0, failed= 0, linked= 0;
struct BPathIterator bpi;
char filepath[FILE_MAX], *libpath;
char filepath[FILE_MAX];
const char *libpath;
/* be sure there is low chance of the path being too short */
char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE];
@ -652,12 +654,13 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char
}
/* high level function - call from fileselector */
void findMissingFiles(char *basepath, char *str) {
void findMissingFiles(const char *basepath, const char *str) {
struct BPathIterator bpi;
/* be sure there is low chance of the path being too short */
char filepath_expanded[FILE_MAXDIR*2];
char filepath[FILE_MAX], *libpath;
char filepath[FILE_MAX];
const char *libpath;
int filesize, recur_depth;
char dirname[FILE_MAX], filename_new[FILE_MAX];

View File

@ -146,7 +146,7 @@ int BLI_compare(struct direntry *entry1, struct direntry *entry2)
}
double BLI_diskfree(char *dir)
double BLI_diskfree(const char *dir)
{
#ifdef WIN32
DWORD sectorspc, bytesps, freec, clusters;
@ -201,7 +201,7 @@ double BLI_diskfree(char *dir)
#endif
}
void BLI_builddir(char *dirname, char *relname)
void BLI_builddir(const char *dirname, char *relname)
{
struct dirent *fname;
struct dirlink *dlink;
@ -397,7 +397,7 @@ void BLI_adddirstrings()
}
}
unsigned int BLI_getdir(char *dirname, struct direntry **filelist)
unsigned int BLI_getdir(const char *dirname, struct direntry **filelist)
{
// reset global variables
// memory stored in files is free()'d in
@ -443,7 +443,7 @@ size_t BLI_filepathsize(const char *path)
}
int BLI_exist(char *name)
int BLI_exist(const char *name)
{
#if defined(WIN32) && !defined(__MINGW32__)
struct _stat64i32 st;

View File

@ -342,7 +342,7 @@ float file_string_width(const char* str)
{
uiStyle *style= U.uistyles.first;
uiStyleFontSet(&style->widget);
return BLF_width(style->widget.uifont_id, (char *)str);
return BLF_width(style->widget.uifont_id, str);
}
/* gives the exact width of the string after being shortened to

View File

@ -81,7 +81,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
PyObject *list = PyList_New(0), *st; /* stupidly big string to be safe */
/* be sure there is low chance of the path being too short */
char filepath_expanded[1024];
char *lib;
const char *lib;
int absolute = 0;
static char *kwlist[] = {"absolute", NULL};

View File

@ -28,14 +28,6 @@
#include "KX_BlenderGL.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "BLF_api.h"
#ifdef __cplusplus
}
#endif
/*
* This little block needed for linking to Blender...
*/
@ -81,6 +73,7 @@ extern "C" {
#include "wm_event_system.h"
#include "wm_cursors.h"
#include "wm_window.h"
#include "BLF_api.h"
}
/* end of blender block */
@ -156,7 +149,7 @@ void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int
/* the actual drawing */
glColor3ub(255, 255, 255);
BLF_draw_default(xco, height-yco, 0.0f, (char *)text);
BLF_draw_default(xco, height-yco, 0.0f, (char *)text, 65535); /* XXX, use real len */
glMatrixMode(GL_PROJECTION);
glPopMatrix();
@ -184,9 +177,9 @@ void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int widt
/* draw in black first*/
glColor3ub(0, 0, 0);
BLF_draw_default(xco+2, height-yco-2, 0.0f, (char *)text);
BLF_draw_default(xco+2, height-yco-2, 0.0f, text, 65535); /* XXX, use real len */
glColor3ub(255, 255, 255);
BLF_draw_default(xco, height-yco, 0.0f, (char *)text);
BLF_draw_default(xco, height-yco, 0.0f, text, 65535); /* XXX, use real len */
glMatrixMode(GL_PROJECTION);
glPopMatrix();