Commit 427a3d0e authored by IOhannes m zmölnig's avatar IOhannes m zmölnig
Browse files

astyle -n --style=1tbs --indent=spaces=2

parent 337d820d

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -32,7 +32,8 @@
#include <stdarg.h>
void *Obj_header::operator new(size_t, void *location, void *) {
void *Obj_header::operator new(size_t, void *location, void *)
{
return(location);
}
......@@ -83,7 +84,7 @@ void CPPExtern :: post(const char*fmt,...) const
va_start(ap, fmt);
vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
va_end(ap);
if(m_endpost && NULL!=m_objectname && NULL!=m_objectname->s_name && &s_ != m_objectname){
if(m_endpost && NULL!=m_objectname && NULL!=m_objectname->s_name && &s_ != m_objectname) {
::post("[%s]: %s", m_objectname->s_name, buf);
} else {
::post("%s", buf);
......@@ -97,7 +98,7 @@ void CPPExtern :: startpost(const char*fmt,...) const
va_start(ap, fmt);
vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
va_end(ap);
if(m_endpost && NULL!=m_objectname && NULL!=m_objectname->s_name && &s_ != m_objectname){
if(m_endpost && NULL!=m_objectname && NULL!=m_objectname->s_name && &s_ != m_objectname) {
::startpost("[%s]: %s", m_objectname->s_name, buf);
} else {
::startpost("%s", buf);
......@@ -130,13 +131,13 @@ void CPPExtern :: verbose(const int level, const char*fmt,...) const
/* only pd>=0.39(?) supports ::verbose() */
if(rte_verbose) {
if(NULL!=m_objectname && NULL!=m_objectname->s_name && &s_ != m_objectname){
if(NULL!=m_objectname && NULL!=m_objectname->s_name && &s_ != m_objectname) {
rte_verbose(level, "[%s]: %s", m_objectname->s_name, buf);
} else {
rte_verbose(level, "%s", buf);
}
} else {
if(NULL!=m_objectname && NULL!=m_objectname->s_name && &s_ != m_objectname){
if(NULL!=m_objectname && NULL!=m_objectname->s_name && &s_ != m_objectname) {
::post("[%s]: %s", m_objectname->s_name, buf);
} else {
::post("%s", buf);
......@@ -151,27 +152,30 @@ void CPPExtern :: error(const char*fmt,...) const
va_start(ap, fmt);
vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
va_end(ap);
if(NULL!=m_objectname && NULL!=m_objectname->s_name && &s_ != m_objectname){
if(NULL!=m_objectname && NULL!=m_objectname->s_name && &s_ != m_objectname) {
char*objname=m_objectname->s_name;
if(x_obj)
if(x_obj) {
pd_error(x_obj, "[%s]: %s", objname, buf);
else if (m_holder)
} else if (m_holder) {
pd_error(m_holder, "[%s]: %s", objname, buf);
else
} else {
::error("[%s]: %s", objname, buf);
}
} else {
if(x_obj)
if(x_obj) {
pd_error(x_obj, "%s", buf);
else if (m_holder)
} else if (m_holder) {
pd_error(m_holder, "%s", buf);
else
} else {
::error("%s", buf);
}
}
}
typedef int (*close_t)(int fd);
std::string CPPExtern::findFile(const std::string&f, const std::string&e) const {
std::string CPPExtern::findFile(const std::string&f, const std::string&e) const
{
std::string result;
gem::RTE::RTE*rte=gem::RTE::RTE::getRuntimeEnvironment();
if(rte) {
......@@ -180,11 +184,13 @@ std::string CPPExtern::findFile(const std::string&f, const std::string&e) const
return result;
}
std::string CPPExtern::findFile(const std::string&file) const {
std::string CPPExtern::findFile(const std::string&file) const
{
return findFile(file, "");
}
bool CPPExtern :: checkGemVersion(const int major, const int minor) {
bool CPPExtern :: checkGemVersion(const int major, const int minor)
{
if(!GemVersion::versionCheck(major, minor)) {
::error("GEM version mismatch: compiled for %d.%d but we are running %s",
major, minor,
......@@ -195,7 +201,8 @@ bool CPPExtern :: checkGemVersion(const int major, const int minor) {
}
CPPExtern&CPPExtern::operator=(const CPPExtern&org) {
CPPExtern&CPPExtern::operator=(const CPPExtern&org)
{
x_obj=org.x_obj;
m_objectname=org.m_objectname;
m_canvas=org.m_canvas;
......@@ -203,6 +210,7 @@ CPPExtern&CPPExtern::operator=(const CPPExtern&org) {
return *this;
}
void CPPExtern::beforeDeletion(void) {
void CPPExtern::beforeDeletion(void)
{
//post("CPPExtern to be deleted");
}
......@@ -24,8 +24,9 @@ LOG
class CPPExtern;
/* forward declaration of a generic exception handler for GemExceptions */
namespace gem {
GEM_EXTERN void catchGemException(const char*objname, const t_object*obj);
namespace gem
{
GEM_EXTERN void catchGemException(const char*objname, const t_object*obj);
};
/*-----------------------------------------------------------------
......@@ -43,15 +44,14 @@ DESCRIPTION
the vtable.
-----------------------------------------------------------------*/
struct GEM_EXTERN Obj_header
{
//////////
// The obligatory object header
t_object pd_obj;
struct GEM_EXTERN Obj_header {
//////////
// The obligatory object header
t_object pd_obj;
//////////
// Our data structure
CPPExtern *data;
//////////
// Our data structure
CPPExtern *data;
// This has a dummy arg so that NT won't complain
void *operator new(size_t, void *location, void *dummy);
......@@ -89,69 +89,72 @@ DESCRIPTION
-----------------------------------------------------------------*/
class GEM_EXTERN CPPExtern
{
public:
//////////
// Constructor
CPPExtern(void);
//////////
// The Pd header
t_object *x_obj;
//////////
// Destructor
virtual ~CPPExtern(void) = 0;
//////////
// Get the object's canvas
const t_canvas *getCanvas(void) const { return(m_canvas); }
//////////
// This is a holder - don't touch it
static t_object *m_holder;
//////////
// my name
static char *m_holdname;
t_symbol *m_objectname;
protected:
//////////
// Creation callback
static void real_obj_setupCallback(t_class *) {}
///////////
// called directly before the destructor
// normally you should not override this (use the dtor!)
// if you do override this, make sure that you call the parent as well
virtual void beforeDeletion();
private:
//////////
// The canvas that the object is in
t_canvas *m_canvas;
public:
// these call pd's print-functions, and eventually prepend the object's name
void startpost(const char*format, ...) const;
void post(const char*format, ...) const;
void endpost(void) const;
void verbose(const int level, const char*format, ...) const;
void error(const char*format, ...) const; /* internally uses pd_error() */
// searches for a file based on the parent abstraction's path
// wraps open_via_path() and canvas_makefilename()
// the full filename is returned
// if the file does not exist, it is constructed
std::string findFile(const std::string&filename, const std::string&ext) const;
std::string findFile(const std::string&filename) const;
private:
mutable bool m_endpost; /* internal state for startpost/post/endpost */
static bool checkGemVersion(const int major, const int minor);
public:
//////////
// Constructor
CPPExtern(void);
//////////
// The Pd header
t_object *x_obj;
//////////
// Destructor
virtual ~CPPExtern(void) = 0;
//////////
// Get the object's canvas
const t_canvas *getCanvas(void) const
{
return(m_canvas);
}
//////////
// This is a holder - don't touch it
static t_object *m_holder;
//////////
// my name
static char *m_holdname;
t_symbol *m_objectname;
protected:
//////////
// Creation callback
static void real_obj_setupCallback(t_class *) {}
///////////
// called directly before the destructor
// normally you should not override this (use the dtor!)
// if you do override this, make sure that you call the parent as well
virtual void beforeDeletion();
private:
//////////
// The canvas that the object is in
t_canvas *m_canvas;
public:
// these call pd's print-functions, and eventually prepend the object's name
void startpost(const char*format, ...) const;
void post(const char*format, ...) const;
void endpost(void) const;
void verbose(const int level, const char*format, ...) const;
void error(const char*format, ...) const; /* internally uses pd_error() */
// searches for a file based on the parent abstraction's path
// wraps open_via_path() and canvas_makefilename()
// the full filename is returned
// if the file does not exist, it is constructed
std::string findFile(const std::string&filename, const std::string&ext) const;
std::string findFile(const std::string&filename) const;
private:
mutable bool m_endpost; /* internal state for startpost/post/endpost */
static bool checkGemVersion(const int major, const int minor);
CPPExtern(const CPPExtern&);
virtual CPPExtern&operator=(const CPPExtern&);
};
......
......@@ -83,13 +83,14 @@ GemBase :: GemBase(void)
/////////////////////////////////////////////////////////
GemBase :: ~GemBase(void)
{
if (gem_amRendering){
if (gem_amRendering) {
stopRendering();
gem_amRendering=false;
}
if (m_out1)
outlet_free(m_out1);
if (m_out1) {
outlet_free(m_out1);
}
pd_unbind(&this->x_obj->ob_pd, gensym("__gemBase"));
}
......@@ -101,14 +102,13 @@ void GemBase :: gem_startstopMess(int state)
{
// for now, this is important, as it is the only way to call the stopRendering
#if 1
if (state && !gem_amRendering){
if (state && !gem_amRendering) {
m_enabled = isRunnable();
if(m_enabled) {
startRendering();
m_state=RENDERING;
}
}
else if (!state && gem_amRendering){
} else if (!state && gem_amRendering) {
if(m_enabled) {
stopRendering();
m_state=ENABLED;
......@@ -134,8 +134,9 @@ void GemBase :: gem_startstopMess(int state)
void GemBase :: gem_renderMess(GemCache* cache, GemState*state)
{
m_cache=cache;
if(m_cache && m_cache->m_magic!=GEMCACHE_MAGIC)
if(m_cache && m_cache->m_magic!=GEMCACHE_MAGIC) {
m_cache=NULL;
}
if(INIT==m_state) {
if(isRunnable()) {
m_state=ENABLED;
......@@ -153,14 +154,19 @@ void GemBase :: gem_renderMess(GemCache* cache, GemState*state)
}
if(RENDERING==m_state) {
gem_amRendering=true;
if(state)render(state);
if(state) {
render(state);
}
continueRender(state);
if(state)postrender(state);
if(state) {
postrender(state);
}
}
m_modified=false;
}
void GemBase :: continueRender(GemState*state){
void GemBase :: continueRender(GemState*state)
{
t_atom ap[2];
ap->a_type=A_POINTER;
ap->a_w.w_gpointer=(t_gpointer *)m_cache; // the cache ?
......@@ -177,9 +183,12 @@ void GemBase :: continueRender(GemState*state){
/////////////////////////////////////////////////////////
void GemBase :: setModified(void)
{
if (m_cache&& (m_cache->m_magic!=GEMCACHE_MAGIC))
if (m_cache&& (m_cache->m_magic!=GEMCACHE_MAGIC)) {
m_cache=NULL;
if (m_cache) m_cache->dirty = true;
}
if (m_cache) {
m_cache->dirty = true;
}
m_modified=true;
switch(m_state) {
case DISABLED:
......@@ -214,12 +223,14 @@ bool GemBase :: isRunnable(void)
return true;
}
enum GemBase::RenderState GemBase::getState(void) {
enum GemBase::RenderState GemBase::getState(void)
{
return m_state;
}
#include "Base/GemWindow.h"
void GemBase::beforeDeletion(void) {
void GemBase::beforeDeletion(void)
{
//post("GemBase to be deleted");
GemWindow::stopInAllContexts(this);
CPPExtern::beforeDeletion();
......@@ -234,36 +245,38 @@ void GemBase::beforeDeletion(void) {
/////////////////////////////////////////////////////////
void GemBase :: obj_setupCallback(t_class *classPtr)
{
class_addmethod(classPtr, reinterpret_cast<t_method>(&GemBase::gem_MessCallback),
gensym("gem_state"), A_GIMME, A_NULL);
struct _CallbackClass_gemContext {
static void callback(void*data, t_float v0) {
GemBase*obj=GetMyClass(data);
bool state=(bool)v0;
if(!state && obj->gem_amRendering) {
if(obj->m_enabled) {
//obj->post("stop rendering");
obj->stopRendering();
obj->m_state=obj->ENABLED;
}
class_addmethod(classPtr, reinterpret_cast<t_method>(&GemBase::gem_MessCallback),
gensym("gem_state"), A_GIMME, A_NULL);
struct _CallbackClass_gemContext {
static void callback(void*data, t_float v0)
{
GemBase*obj=GetMyClass(data);
bool state=(bool)v0;
if(!state && obj->gem_amRendering) {
if(obj->m_enabled) {
//obj->post("stop rendering");
obj->stopRendering();
obj->m_state=obj->ENABLED;
}
obj->gem_amRendering=(!state);
}
explicit _CallbackClass_gemContext (struct _class*c) {
class_addmethod(c, reinterpret_cast<t_method>(callback), gensym("__gem_context"), A_FLOAT, A_NULL);
}
};
_CallbackClass_gemContext _CallbackClassInstance_gemContext (classPtr);
obj->gem_amRendering=(!state);
}
explicit _CallbackClass_gemContext (struct _class*c)
{
class_addmethod(c, reinterpret_cast<t_method>(callback), gensym("__gem_context"), A_FLOAT, A_NULL);
}
};
_CallbackClass_gemContext _CallbackClassInstance_gemContext (classPtr);
}
void GemBase :: gem_MessCallback(void *data, t_symbol *s, int argc, t_atom *argv)
{
if (argc==2 && argv->a_type==A_POINTER && (argv+1)->a_type==A_POINTER){
if (argc==2 && argv->a_type==A_POINTER && (argv+1)->a_type==A_POINTER) {
GetMyClass(data)->gem_renderMess(
reinterpret_cast<GemCache *>(argv->a_w.w_gpointer),
reinterpret_cast<GemState *>((argv+1)->a_w.w_gpointer));
reinterpret_cast<GemCache *>(argv->a_w.w_gpointer),
reinterpret_cast<GemState *>((argv+1)->a_w.w_gpointer));
#if 1
} else if (argc==1 && argv->a_type==A_FLOAT){
} else if (argc==1 && argv->a_type==A_FLOAT) {
GetMyClass(data)->gem_startstopMess(atom_getint(argv)); // start rendering (forget this !?)
#endif
} else {
......
......@@ -34,7 +34,7 @@ class GemState;
-----------------------------------------------------------------*/
class GEM_EXTERN GemBase : public CPPExtern
{
protected:
protected:
//////////
// Constructor
......@@ -59,7 +59,10 @@ class GEM_EXTERN GemBase : public CPPExtern
// Called when rendering stops
#if 1/*(jmz) this seems to be for gem2pdp*/
virtual void stoprender() { realStopRendering(); }
virtual void stoprender()
{
realStopRendering();
}
#endif
//////////
......@@ -104,17 +107,23 @@ class GEM_EXTERN GemBase : public CPPExtern
//////////
// creation callback
static void real_obj_setupCallback(t_class *classPtr)
{ CPPExtern::real_obj_setupCallback(classPtr); GemBase::obj_setupCallback(classPtr); }
{
CPPExtern::real_obj_setupCallback(classPtr);
GemBase::obj_setupCallback(classPtr);
}
enum RenderState {INIT, ENABLED, DISABLED, RENDERING, MODIFIED};
private:
private:
void realStopRendering();
void gem_startstopMess(int state);
void gem_renderMess(GemCache* cache, GemState* state);
static inline GemBase *GetMyClass(void *data) {return((GemBase *)((Obj_header *)data)->data);}
static inline GemBase *GetMyClass(void *data)
{
return((GemBase *)((Obj_header *)data)->data);
}
friend class gemhead;
static void obj_setupCallback(t_class *classPtr);
......@@ -126,7 +135,7 @@ class GEM_EXTERN GemBase : public CPPExtern
gem::ContextData<bool>m_enabled;
gem::ContextData<enum RenderState>m_state;
protected:
protected:
enum RenderState getState(void);
virtual void beforeDeletion(void);
......
......@@ -32,7 +32,8 @@ static GemGlewXContext*s_glewxcontext=NULL;
using namespace gem;
class Context::PIMPL {
class Context::PIMPL
{
public:
PIMPL(void) :
#ifdef GEM_MULTICONTEXT
......@@ -71,12 +72,19 @@ public:
glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, maxStackDepth+GemMan::STACKPROJECTION);
}
~PIMPL(void) {
~PIMPL(void)
{
freeID(contextid);
#ifdef GEM_MULTICONTEXT
if(context )delete context; context=NULL;
if(context ) {
delete context;
}
context=NULL;
# ifdef GemGlewXContext
if(xcontext)delete xcontext; xcontext=0;
if(xcontext) {
delete xcontext;
}
xcontext=0;
# endif /* GemGlewXContext */
#endif
}
......@@ -97,8 +105,9 @@ public:
{
unsigned int id=0;
#ifdef GEM_MULTICONTEXT
while(s_takenIDs.find(id) != s_takenIDs.end())
while(s_takenIDs.find(id) != s_takenIDs.end()) {
id++;
}
#endif /* GEM_MULTICONTEXT */
s_takenIDs.insert(id);
return id;
......@@ -143,8 +152,9 @@ Context::Context(void)
}
} else {
GLint colorstack = 0;
if(GLEW_ARB_imaging)
if(GLEW_ARB_imaging) {
glGetIntegerv(GL_MAX_COLOR_MATRIX_STACK_DEPTH, &colorstack);
}
m_pimpl->maxStackDepth[GemMan::STACKCOLOR]=colorstack;
......@@ -154,12 +164,14 @@ Context::Context(void)
pop();
if(!errstring.empty()) {
delete m_pimpl; m_pimpl=NULL;
delete m_pimpl;
m_pimpl=NULL;
throw(GemException(errstring));
}
/* update the stack variables (late initialization) */
push(); pop();
push();
pop();
GemMan::m_windowState++;
}
......@@ -171,11 +183,15 @@ Context::Context(const Context&c)
pop();
}
Context&Context::operator=(const Context&c) {
if(&c == this || c.m_pimpl == m_pimpl)
Context&Context::operator=(const Context&c)
{
if(&c == this || c.m_pimpl == m_pimpl) {
return (*this);
}
if(m_pimpl)delete m_pimpl;
if(m_pimpl) {
delete m_pimpl;
}
m_pimpl=new PIMPL(*c.m_pimpl);
push();
pop();
......@@ -184,12 +200,17 @@ Context&Context::operator=(const Context&c) {
}
Context::~Context(void) {
if(m_pimpl)delete m_pimpl; m_pimpl=NULL;
Context::~Context(void)
{
if(m_pimpl) {
delete m_pimpl;
}
m_pimpl=NULL;
GemMan::m_windowState--;
}
bool Context::push(void) {
bool Context::push(void)
{
GemMan::maxStackDepth[GemMan::STACKMODELVIEW]= m_pimpl->maxStackDepth[GemMan::STACKMODELVIEW];