Permalink
Browse files

some refactoring, include cleanups

  • Loading branch information...
jonklein
jonklein committed Nov 22, 2009
1 parent eb295c0 commit 38f2a4d9baca6483a443b84b516ae78999c0e286
View
@@ -112,7 +112,7 @@ int brGLUTUnpause() {
}
-int main( int argc, char **argv ) {
+int main( int argc, const char **argv ) {
char *text;
const char *simulationFile;
@@ -161,7 +161,7 @@ int main( int argc, char **argv ) {
exit( 0 );
}
- gEngine = brEngineNewWithArguments( argc, argv );
+ gEngine = new brEngine( argc, argv );
char currentDir[ MAXPATHLEN ];
brEngineSetIOPath( gEngine, getcwd( currentDir, sizeof( currentDir ) ) );
@@ -343,7 +343,7 @@ void brQuit( brEngine *e ) {
printf( "%f simulated/real\n", age / diff );
}
- brEngineFree( gEngine );
+ delete gEngine;
if( gOffscreenBuffer )
slFree( gOffscreenBuffer );
@@ -393,7 +393,7 @@ void brClick( int inX, int inY ) {
glutAttachMenu( GLUT_MIDDLE_BUTTON );
}
-int brParseArgs( int argc, char **argv ) {
+int brParseArgs( int argc, const char **argv ) {
int level, r;
int error = 0;
@@ -68,7 +68,7 @@ const struct option gCLIOptions[] = {
{ "python", no_argument , 0, 'Y' }
};
-int brParseArgs(int, char **);
+int brParseArgs(int, const char **);
__dead void brPrintUsage(const char *);
__dead void brQuit(brEngine *);
@@ -21,10 +21,18 @@
#ifndef _BREVEEVAL_H
#define _BREVEEVAL_H
-#include "slutil.h"
#include <string>
#include <set>
+#include "slutil.h"
+
+class brEvalHash;
+class brEvalList;
+class brEvalListHead;
+class brInstance;
+class brData;
+class brObject;
+
enum evaluationCodes {
EC_ERROR_HANDLED = -2,
EC_ERROR,
@@ -9,12 +9,13 @@ enum allocStatus {
AS_ACTIVE // active object
};
-typedef struct brObjectType brObjectType;
-typedef struct brMethod brMethod;
-typedef struct brCollisionHandler brCollisionHandler;
-
+class brObjectType;
+class brMethod;
+class brCollisionHandler;
class brEngine;
class brEval;
+class brMenuEntry;
+class brObserver;
/** \addtogroup breveObjectAPI */
/*@{*/
@@ -24,21 +24,25 @@
#include <pthread.h>
#include <sys/stat.h>
#include <gsl/gsl_rng.h>
-
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include "timeval.h"
-#include "url.h"
-#include "sound.h"
-#include "render.h"
class slCamera;
class slWorld;
class slRenderGL;
class brInstance;
+class brDlPlugin;
+class brObject;
+class brEvent;
+class brURLFetcher;
+class brSoundMixer;
+class brNamespace;
+class brInternalFunction;
+class brInstance;
// the maximum error size
@@ -147,13 +151,7 @@ typedef struct brObjectType brObjectType;
class brEngine {
public:
- brEngine();
-
- brEngine( int inArgc, char **inArgv ) {
- _argc = inArgc;
- _argv = inArgv;
- }
-
+ brEngine( int inArgc = 0, const char **inArgv = NULL );
~brEngine();
std::vector< brObjectType* > _objectTypes;
@@ -176,18 +174,15 @@ class brEngine {
void pauseTimer();
void unpauseTimer();
-#ifdef HAVE_LIBCURL
- brURLFetcher _url;
-#endif
+ void addSearchPath( const char *inPath );
-#if HAVE_LIBPORTAUDIO && HAVE_LIBSNDFILE
- brSoundMixer _soundMixer;
-#endif
+ brURLFetcher* _url;
+ brSoundMixer* _soundMixer;
slWorld* world;
slCamera* camera;
- slRenderGL _renderer;
+ slRenderGL* _renderer;
gsl_rng* RNG;
@@ -201,7 +196,6 @@ class brEngine {
FILE* _logFile;
-private:
brInstance* _controller;
std::map< std::string, brObject* > objectAliases;
@@ -237,14 +231,10 @@ class brEngine {
struct timeval accumulatedTime;
int _argc;
- char** _argv;
+ const char** _argv;
int nThreads;
pthread_mutex_t lock;
- pthread_mutex_t scheduleLock;
- pthread_mutex_t conditionLock;
- pthread_cond_t condition;
-
int lastScheduled;
std::vector<void*> windows;
@@ -327,17 +317,11 @@ const std::vector< std::string > &brEngineGetSearchPaths( brEngine * );
std::vector< std::string > brEngineGetAllObjectNames( brEngine *e );
-brEngine *brEngineNew();
-brEngine *brEngineNewWithArguments( int inArgc, char **inArgv );
-
-void brEngineFree(brEngine *);
-
void brAddToInstanceLists(brInstance *);
void brRemoveFromInstanceLists(brInstance *);
int brFileLogWrite(void *, const char *, int);
-void brAddSearchPath(brEngine *, const char *);
char *brFindFile(brEngine *, const char *, struct stat *);
void brFreeSearchPath(brEngine *);
@@ -21,41 +21,4 @@
#ifndef _BREVETYPEDEFS_H
#define _BREVETYPEDEFS_H
-typedef struct brEngine brEngine;
-typedef struct brVersionRequirement brVersionRequirement;
-typedef struct brVisualData brVisualData;
-typedef struct briTunesData briTunesData;
-typedef struct brMenuEntry brMenuEntry;
-typedef struct brEvent brEvent;
-typedef struct stStackRecord stStackRecord;
-typedef struct brErrorInfo brErrorInfo;
-typedef struct brEvalList brEvalList;
-typedef struct brEvalData brEvalData;
-typedef struct brEvalListHead brEvalListHead;
-typedef struct brObserver brObserver;
-typedef struct brEval brEval;
-typedef struct brNamespaceSymbol brNamespaceSymbol;
-typedef struct brNamespace brNamespace;
-
-typedef struct brInstance brInstance;
-typedef struct brObject brObject;
-
-typedef struct brInternalFunction brInternalFunction;
-
-typedef struct brData brData;
-
-typedef struct brEvalHash brEvalHash;
-typedef struct brSoundMixer brSoundMixer;
-typedef struct brSoundData brSoundData;
-typedef struct brSoundPlayer brSoundPlayer;
-
-typedef struct brDlPlugin brDlPlugin;
-
-typedef struct stThreadData stThreadData;
-
-typedef struct brNetworkClientData brNetworkClientData;
-typedef struct brNetworkServer brNetworkServer;
-typedef struct brNetworkRequest brNetworkRequest;
-typedef struct brStringHeader brStringHeader;
-
#endif
@@ -22,6 +22,8 @@
#define _NAMESPACE_H
#include "slutil.h"
+class brNamespaceSymbol;
+
enum symbolTypes {
ST_METHODS = 1,
ST_VAR
@@ -48,9 +50,10 @@ class brNamespace {
* \brief A symbol in a brNamespace.
*/
-struct brNamespaceSymbol {
- int type;
- void *data;
+class brNamespaceSymbol {
+ public:
+ int type;
+ void *data;
};
brNamespace *brNamespaceNew(void);
@@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
*****************************************************************************/
+#ifndef _PLUGINS_H
+#define _PLUGINS_H
#ifdef MINGW
#include <windows.h>
@@ -49,3 +51,5 @@ void brEngineRemoveDlPlugins(brEngine *);
void *brDlLoadPlugin(char *, char *, brNamespace *);
DLLEXPORT char *brPluginFindFile(char *, void *);
+
+#endif
@@ -2,11 +2,12 @@
#define _STEVE_FRONTEND_H
#define ST_STACK_SIZE 0x4000
+#define STEVE_TYPE_SIGNATURE 0x73747665
#include <vector>
#include <map>
-#define STEVE_TYPE_SIGNATURE 0x73747665
+class stStackRecord;
struct stSteveData {
stSteveData() {
@@ -2,8 +2,6 @@
#ifndef _URL_H
#define _URL_H
-#include "slutil.h"
-
#ifdef HAVE_LIBCURL
#include <curl/curl.h>
Oops, something went wrong.

0 comments on commit 38f2a4d

Please sign in to comment.