Skip to content

Commit

Permalink
some refactoring, include cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jonklein committed Nov 22, 2009
1 parent eb295c0 commit 38f2a4d
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 210 deletions.
8 changes: 4 additions & 4 deletions breve/bin/breve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int brGLUTUnpause() {
}


int main( int argc, char **argv ) {
int main( int argc, const char **argv ) {
char *text;
const char *simulationFile;

Expand Down Expand Up @@ -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 ) ) );
Expand Down Expand Up @@ -343,7 +343,7 @@ void brQuit( brEngine *e ) {
printf( "%f simulated/real\n", age / diff );
}

brEngineFree( gEngine );
delete gEngine;

if( gOffscreenBuffer )
slFree( gOffscreenBuffer );
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion breve/include/breve/breve.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
10 changes: 9 additions & 1 deletion breve/include/breve/breveEval.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions breve/include/breve/breveObjectAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
/*@{*/
Expand Down
44 changes: 14 additions & 30 deletions breve/include/breve/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -201,7 +196,6 @@ class brEngine {

FILE* _logFile;

private:
brInstance* _controller;

std::map< std::string, brObject* > objectAliases;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 *);

Expand Down
37 changes: 0 additions & 37 deletions breve/include/breve/kernelTypedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions breve/include/breve/namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#define _NAMESPACE_H
#include "slutil.h"

class brNamespaceSymbol;

enum symbolTypes {
ST_METHODS = 1,
ST_VAR
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions breve/include/breve/plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -49,3 +51,5 @@ void brEngineRemoveDlPlugins(brEngine *);
void *brDlLoadPlugin(char *, char *, brNamespace *);

DLLEXPORT char *brPluginFindFile(char *, void *);

#endif
3 changes: 2 additions & 1 deletion breve/include/breve/steveFrontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions breve/include/breve/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#ifndef _URL_H
#define _URL_H

#include "slutil.h"

#ifdef HAVE_LIBCURL

#include <curl/curl.h>
Expand Down
Loading

0 comments on commit 38f2a4d

Please sign in to comment.