From 4f230f061da57777d546d1204310400a68fbd3e0 Mon Sep 17 00:00:00 2001 From: janwas Date: Wed, 6 Oct 2004 14:00:43 +0000 Subject: [PATCH] less dependencies: handle.h forward-defines Handle, so that not everything that uses res headers is dependent on h_mgr This was SVN commit r1213. --- source/lib/res/cursor.cpp | 4 ++-- source/lib/res/file.cpp | 3 +-- source/lib/res/h_mgr.cpp | 3 +-- source/lib/res/h_mgr.h | 14 +++++++------- source/lib/res/handle.h | 9 +++++++++ source/lib/res/hotload.h | 13 +++++++++++++ source/lib/res/mem.cpp | 1 - source/lib/res/mem.h | 2 +- source/lib/res/ogl_tex.cpp | 2 +- source/lib/res/ogl_tex.h | 2 +- source/lib/res/res.cpp | 4 +++- source/lib/res/res.h | 20 ++++---------------- source/lib/res/snd.h | 2 +- source/lib/res/tex.h | 2 +- source/lib/res/unifont.h | 7 +++---- source/lib/res/vfs.cpp | 1 + source/lib/res/vfs.h | 2 +- source/lib/res/zip.h | 2 +- 18 files changed, 51 insertions(+), 42 deletions(-) create mode 100755 source/lib/res/handle.h create mode 100755 source/lib/res/hotload.h diff --git a/source/lib/res/cursor.cpp b/source/lib/res/cursor.cpp index c625f206e5..85e0ae9c55 100755 --- a/source/lib/res/cursor.cpp +++ b/source/lib/res/cursor.cpp @@ -9,8 +9,8 @@ #include "lib/sysdep/win/win_internal.h" #endif -#include "lib/res/res.h" -#include "lib/res/ogl_tex.h" +#include "res.h" +#include "ogl_tex.h" #include "lib/ogl.h" #include "CVFSFile.h" diff --git a/source/lib/res/file.cpp b/source/lib/res/file.cpp index 54f212afbb..091d507a2b 100755 --- a/source/lib/res/file.cpp +++ b/source/lib/res/file.cpp @@ -20,9 +20,8 @@ #include "precompiled.h" #include "lib.h" +#include "res.h" #include "file.h" -#include "h_mgr.h" -#include "mem.h" #include "detect.h" #include "adts.h" #include "sysdep/sysdep.h" diff --git a/source/lib/res/h_mgr.cpp b/source/lib/res/h_mgr.cpp index a1c1684b07..f7728de7e0 100755 --- a/source/lib/res/h_mgr.cpp +++ b/source/lib/res/h_mgr.cpp @@ -19,8 +19,7 @@ #include "precompiled.h" #include "lib.h" -#include "h_mgr.h" -#include "mem.h" +#include "res.h" #include #include // CHAR_BIT diff --git a/source/lib/res/h_mgr.h b/source/lib/res/h_mgr.h index fe897a9804..05e41fb31c 100755 --- a/source/lib/res/h_mgr.h +++ b/source/lib/res/h_mgr.h @@ -19,18 +19,18 @@ #ifndef H_MGR_H__ #define H_MGR_H__ +// do not include from public header files! +// handle.h declares type Handle, and avoids making +// everything dependent on this (rather often updated) header. + #include // type init routines get va_list of args #include "lib.h" - -// 0 = invalid handle value; < 0 is an error code. -// 64 bits, because we want tags to remain unique: tag overflow may -// let handle use errors slip through, or worse, cause spurious errors. -// with 32 bits, we'd need >= 12 for the index, leaving < 512K tags - -// not a lot. -typedef i64 Handle; +#ifndef HANDLE_DEFINED +#include "handle.h" +#endif diff --git a/source/lib/res/handle.h b/source/lib/res/handle.h new file mode 100755 index 0000000000..87facc6c62 --- /dev/null +++ b/source/lib/res/handle.h @@ -0,0 +1,9 @@ +// define type Handle. split out of h_mgr.h to reduce dependencies. + +// 0 = invalid handle value; < 0 is an error code. +// 64 bits, because we want tags to remain unique: tag overflow may +// let handle use errors slip through, or worse, cause spurious errors. +// with 32 bits, we'd need >= 12 for the index, leaving < 512K tags - +// not a lot. +typedef i64 Handle; +#define HANDLE_DEFINED \ No newline at end of file diff --git a/source/lib/res/hotload.h b/source/lib/res/hotload.h new file mode 100755 index 0000000000..15379088fc --- /dev/null +++ b/source/lib/res/hotload.h @@ -0,0 +1,13 @@ + +extern int res_reload(const char* fn); + + +// the following functions must be called from the same thread! +// (wdir_watch limitation) + + +extern int res_watch_dir(const char* const path, intptr_t* const watch); + +extern int res_cancel_watch(const intptr_t watch); + +extern int res_reload_changed_files(); diff --git a/source/lib/res/mem.cpp b/source/lib/res/mem.cpp index c319b4b2ae..6b54e8840c 100755 --- a/source/lib/res/mem.cpp +++ b/source/lib/res/mem.cpp @@ -4,7 +4,6 @@ #include "lib.h" #include "res.h" -#include "h_mgr.h" #include #include diff --git a/source/lib/res/mem.h b/source/lib/res/mem.h index 9252e5c8a7..d50a3380a1 100755 --- a/source/lib/res/mem.h +++ b/source/lib/res/mem.h @@ -1,7 +1,7 @@ #ifndef MEM_H #define MEM_H -#include "h_mgr.h" +#include "handle.h" #ifdef __cplusplus diff --git a/source/lib/res/ogl_tex.cpp b/source/lib/res/ogl_tex.cpp index 3d4af30325..e0ed7ce810 100755 --- a/source/lib/res/ogl_tex.cpp +++ b/source/lib/res/ogl_tex.cpp @@ -1,7 +1,7 @@ #include "precompiled.h" -#include "ogl.h" #include "res.h" +#include "ogl.h" #include "tex.h" #include "ogl_tex.h" diff --git a/source/lib/res/ogl_tex.h b/source/lib/res/ogl_tex.h index 6e5596363a..6a66895460 100755 --- a/source/lib/res/ogl_tex.h +++ b/source/lib/res/ogl_tex.h @@ -1,7 +1,7 @@ #ifndef OGL_TEX_H__ #define OGL_TEX_H__ -#include "lib/res/h_mgr.h" +#include "handle.h" // load and return a handle to the texture given in . // supports RAW, BMP, JP2, PNG, TGA, DDS diff --git a/source/lib/res/res.cpp b/source/lib/res/res.cpp index e1e853df36..ec11d67509 100755 --- a/source/lib/res/res.cpp +++ b/source/lib/res/res.cpp @@ -1,13 +1,15 @@ #include "precompiled.h" #include "res.h" -#include "file.h" +#include "file.h" // file_make_native_path #include "timer.h" +#include "hotload.h" // we implement that interface #include "sysdep/dir_watch.h" #include + int res_reload(const char* const fn) { return h_reload(fn); diff --git a/source/lib/res/res.h b/source/lib/res/res.h index 8f03a60701..a6d85c1e46 100755 --- a/source/lib/res/res.h +++ b/source/lib/res/res.h @@ -1,17 +1,5 @@ -#include "res/h_mgr.h" -#include "res/vfs.h" -#include "res/mem.h" +// common headers needed by lib/res code - -extern int res_reload(const char* fn); - - -// the following functions must be called from the same thread! -// (wfam limitation) - - -extern int res_watch_dir(const char* const path, intptr_t* const watch); - -extern int res_cancel_watch(const intptr_t watch); - -extern int res_reload_changed_files(); +#include "h_mgr.h" +#include "vfs.h" +#include "mem.h" diff --git a/source/lib/res/snd.h b/source/lib/res/snd.h index aed91a719a..a8345b9f24 100755 --- a/source/lib/res/snd.h +++ b/source/lib/res/snd.h @@ -1,4 +1,4 @@ -#include "res/h_mgr.h" +#include "handle.h" // prepare to enumerate all device names (this resets the list returned by diff --git a/source/lib/res/tex.h b/source/lib/res/tex.h index 65c274fd84..ed75e77892 100755 --- a/source/lib/res/tex.h +++ b/source/lib/res/tex.h @@ -19,7 +19,7 @@ #ifndef __TEX_H__ #define __TEX_H__ -#include "h_mgr.h" +#include "handle.h" diff --git a/source/lib/res/unifont.h b/source/lib/res/unifont.h index cb5808597f..f6b3c724f2 100755 --- a/source/lib/res/unifont.h +++ b/source/lib/res/unifont.h @@ -1,15 +1,14 @@ -// $Id: unifont.h,v 1.6 2004/09/06 02:24:05 gee Exp $ +// $Id: unifont.h,v 1.7 2004/10/06 14:00:43 janwas Exp $ #ifndef __UNIFONT_H__ #define __UNIFONT_H__ -//#include "types.h" -#include "h_mgr.h" +#include "handle.h" // Load and return a handle to the font defined // in fn+".fnt" with texture fn+".tga" -Handle unifont_load(const char* fn, int scope = RES_STATIC); +Handle unifont_load(const char* fn, int scope = 0); // Release a handle to a previously loaded font int unifont_unload(Handle& h); diff --git a/source/lib/res/vfs.cpp b/source/lib/res/vfs.cpp index 45607e3628..711e9bd7f1 100755 --- a/source/lib/res/vfs.cpp +++ b/source/lib/res/vfs.cpp @@ -24,6 +24,7 @@ #include "zip.h" #include "file.h" #include "adts.h" +#include "hotload.h" // see NO_DIR_WATCH #include diff --git a/source/lib/res/vfs.h b/source/lib/res/vfs.h index ae7d06174c..5b5fe8c243 100755 --- a/source/lib/res/vfs.h +++ b/source/lib/res/vfs.h @@ -20,7 +20,7 @@ #ifndef __VFS_H__ #define __VFS_H__ -#include "h_mgr.h" // Handle +#include "handle.h" // Handle def #include "posix.h" // struct stat #include "file.h" // file open flags (renamed) diff --git a/source/lib/res/zip.h b/source/lib/res/zip.h index 197069f736..d7f3ba8f27 100755 --- a/source/lib/res/zip.h +++ b/source/lib/res/zip.h @@ -19,7 +19,7 @@ #ifndef ZIP_H__ #define ZIP_H__ -#include "h_mgr.h" +#include "handle.h" #include "file.h" // FileCB for zip_enum