Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Commit

Permalink
Make ixlib compile on modern C++ compilers.
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Feb 10, 2008
1 parent a213e2b commit 84e96ee
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 112 deletions.
30 changes: 30 additions & 0 deletions .gitignore
@@ -0,0 +1,30 @@
*.lo
Makefile
Makefile.in
*~
*.o
.*.swp
configure
config.guess
config.log
config.status
config.sub
INSTALL
*.cache
.deps
stamp-h1
libtool
ltmain.sh
missing
ixlib_config.hpp*
ixlib-config
ixlib.lsm
install-sh
src/lex.*.cpp
depcomp
*.loT
aclocal.m4
lex.yy.c
.libs
*.la
test/javascript
4 changes: 2 additions & 2 deletions src/exbase.cpp
Expand Up @@ -36,8 +36,8 @@ char base_exception::RenderBuffer[EX_INFOMAX+1+100];



base_exception::base_exception(TErrorCode error,char const *info,char *module,
TIndex line,char *category)
base_exception::base_exception(TErrorCode error,char const *info,char const *module,
TIndex line,char const *category)
: Error(error),Module(module),Line(line),Category(category) {
HasInfo = (info!=NULL);
if (info) {
Expand Down
2 changes: 1 addition & 1 deletion src/exgen.cpp
Expand Up @@ -19,7 +19,7 @@ using namespace ixion;



static char *(PlainText[]) = {
static const char *(PlainText[]) = {
N_("Unable to evaluate expression"),
N_("Function not yet implemented"),
N_("General error"),
Expand Down
4 changes: 2 additions & 2 deletions src/exio.cpp
Expand Up @@ -19,7 +19,7 @@ using namespace ixion;


// Exception support ----------------------------------------------------------
static char *IOPlainText[] = {
static const char *IOPlainText[] = {
N_("Unmatched wildcard"),
N_("Parameter error: wildcard"),
N_("Path syntax error"),
Expand Down Expand Up @@ -50,7 +50,7 @@ static char *IOPlainText[] = {


// io_exception ---------------------------------------------------------------
char *io_exception::getText() const {
char const *io_exception::getText() const {
return _(IOPlainText[Error]);
}

Expand Down
8 changes: 4 additions & 4 deletions src/ixlib_exbase.hpp
Expand Up @@ -53,15 +53,15 @@ namespace ixion {

struct base_exception : public std::exception {
TErrorCode Error;
char *Module;
char const *Module;
TIndex Line;
char *Category;
char const *Category;
bool HasInfo;
char Info[EX_INFOMAX+1];
static char RenderBuffer[EX_INFOMAX+1+100];

base_exception(TErrorCode error,char const *info = NULL,char *module = NULL,
TIndex line = 0,char *category = NULL);
base_exception(TErrorCode error,char const *info = NULL,char const *module = NULL,
TIndex line = 0,char const *category = NULL);
char const *what() const throw ();
virtual const char *getText() const = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion src/ixlib_exgen.hpp
Expand Up @@ -53,7 +53,7 @@
namespace ixion {
// generic_exception ----------------------------------------------------------
struct generic_exception : public base_exception {
generic_exception(TErrorCode error,char const *info = NULL,char *module = NULL,
generic_exception(TErrorCode error,char const *info = NULL,char const *module = NULL,
TIndex line = 0)
: base_exception(error,info,module,line,"GEN") {
}
Expand Down
6 changes: 3 additions & 3 deletions src/ixlib_exio.hpp
Expand Up @@ -55,14 +55,14 @@
// io_exception ---------------------------------------------------------------
namespace ixion {
struct io_exception : public base_exception {
io_exception(TErrorCode error,char const *info = NULL,char *module = NULL,
io_exception(TErrorCode error,char const *info = NULL,char const *module = NULL,
TIndex line = 0)
: base_exception(error,info,module,line,"IO")
{ }
io_exception(char const *info = NULL,char *module = NULL,TIndex line = 0)
io_exception(char const *info = NULL,char const *module = NULL,TIndex line = 0)
: base_exception(getErrNoError(),info,module,line,"IO")
{ }
virtual char *getText() const;
virtual const char *getText() const;

private:
TErrorCode getErrNoError();
Expand Down
114 changes: 60 additions & 54 deletions src/ixlib_garbage.hpp
Expand Up @@ -103,6 +103,13 @@ namespace ixion {



template<class T_Managed>
reference_manager<T_Managed>
reference_manager_keeper<T_Managed>::Manager;





/**
An object that acts like a reference-counted pointer to an object.
Expand Down Expand Up @@ -130,24 +137,24 @@ namespace ixion {
// compiler generates one, which is *ahem* - fatal
ref(ref const &src)
: ref_base<T>(src) {
reference_manager_keeper<T_Managed>::Manager.addReference(Instance);
reference_manager_keeper<T_Managed>::Manager.addReference(this->Instance);
}
template<class T2>
ref(ref<T2,T_Managed> const &src)
: ref_base<T>(src.get()) {
reference_manager_keeper<T_Managed>::Manager.addReference(Instance);
reference_manager_keeper<T_Managed>::Manager.addReference(this->Instance);
}
template<class T2>
ref(no_free_ref<T2,T_Managed> const &src)
: ref_base<T>(src.get()) {
reference_manager_keeper<T_Managed>::Manager.addReference(Instance);
reference_manager_keeper<T_Managed>::Manager.addReference(this->Instance);
}
ref(T *instance = NULL)
: ref_base<T>(instance) {
reference_manager_keeper<T_Managed>::Manager.addReference(Instance);
reference_manager_keeper<T_Managed>::Manager.addReference(this->Instance);
}
~ref() {
reference_manager_keeper<T_Managed>::Manager.freeReference(Instance);
reference_manager_keeper<T_Managed>::Manager.freeReference(this->Instance);
}

ref &operator=(ref const &src) {
Expand All @@ -161,20 +168,20 @@ namespace ixion {

// methods
void release() {
reference_manager_keeper<T_Managed>::Manager.freeReference(Instance);
Instance = NULL;
reference_manager_keeper<T_Managed>::Manager.freeReference(this->Instance);
this->Instance = NULL;
}
void set(T *instance) {
if (instance == Instance) return;
if (instance == this->Instance) return;

reference_manager_keeper<T_Managed>::Manager.freeReference(Instance);
Instance = instance;
reference_manager_keeper<T_Managed>::Manager.addReference(Instance);
reference_manager_keeper<T_Managed>::Manager.freeReference(this->Instance);
this->Instance = instance;
reference_manager_keeper<T_Managed>::Manager.addReference(this->Instance);
}
T *releaseFromGCArena() {
T *oldinst = Instance;
reference_manager_keeper<T_Managed>::Manager.forgetReference(Instance);
Instance = NULL;
T *oldinst = this->Instance;
reference_manager_keeper<T_Managed>::Manager.forgetReference(this->Instance);
this->Instance = NULL;
return oldinst;
}
};
Expand Down Expand Up @@ -204,24 +211,24 @@ namespace ixion {
// compiler generates one, which is *ahem* - fatal
no_free_ref(no_free_ref const &src)
: ref_base<T>(src) {
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(Instance);
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(this->Instance);
}
template<class T2>
no_free_ref(ref<T2,T_Managed> const &src)
: ref_base<T>(src.get()) {
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(Instance);
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(this->Instance);
}
template<class T2>
no_free_ref(no_free_ref<T2,T_Managed> const &src)
: ref_base<T>(src.get()) {
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(Instance);
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(this->Instance);
}
no_free_ref(T *instance = NULL)
: ref_base<T>(instance) {
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(Instance);
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(this->Instance);
}
~no_free_ref() {
reference_manager_keeper<T_Managed>::Manager.removeNoFreeReference(Instance);
reference_manager_keeper<T_Managed>::Manager.removeNoFreeReference(this->Instance);
}

// assignment
Expand All @@ -236,20 +243,20 @@ namespace ixion {

// methods
void release() {
reference_manager_keeper<T_Managed>::Manager.removeNoFreeReference(Instance);
Instance = NULL;
reference_manager_keeper<T_Managed>::Manager.removeNoFreeReference(this->Instance);
this->Instance = NULL;
}
void set(T *instance) {
if (instance == Instance) return;
if (instance == this->Instance) return;

reference_manager_keeper<T_Managed>::Manager.removeNoFreeReference(Instance);
Instance = instance;
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(Instance);
reference_manager_keeper<T_Managed>::Manager.removeNoFreeReference(this->Instance);
this->Instance = instance;
reference_manager_keeper<T_Managed>::Manager.addNoFreeReference(this->Instance);
}
T *releaseFromGCArena() {
T *oldinst = Instance;
reference_manager_keeper<T_Managed>::Manager.forgetReference(Instance);
Instance = NULL;
T *oldinst = this->Instance;
reference_manager_keeper<T_Managed>::Manager.forgetReference(this->Instance);
this->Instance = NULL;
return oldinst;
}
};
Expand All @@ -269,14 +276,14 @@ namespace ixion {
public:
dynamic_ref(dynamic_ref const &src)
: ref_base<T>(src),Manager(src.Manager) {
Manager.addReference(Instance);
Manager.addReference(this->Instance);
}
dynamic_ref(reference_manager<T> &mgr,T *instance = NULL)
: ref_base<T>(instance),Manager(mgr) {
Manager.addReference(Instance);
Manager.addReference(this->Instance);
}
~dynamic_ref() {
Manager.freeReference(Instance);
Manager.freeReference(this->Instance);
}

// assignment
Expand All @@ -291,20 +298,20 @@ namespace ixion {

// methods
void release() {
Manager.freeReference(Instance);
Instance = NULL;
Manager.freeReference(this->Instance);
this->Instance = NULL;
}
void set(T *instance) {
if (instance == Instance) return;
if (instance == this->Instance) return;

Manager.freeReference(Instance);
Instance = instance;
Manager.addReference(Instance);
Manager.freeReference(this->Instance);
this->Instance = instance;
Manager.addReference(this->Instance);
}
T *releaseFromGCArena() {
T *oldinst = Instance;
Manager.forgetReference(Instance);
Instance = NULL;
T *oldinst = this->Instance;
Manager.forgetReference(this->Instance);
this->Instance = NULL;
return oldinst;
}
};
Expand Down Expand Up @@ -334,14 +341,14 @@ namespace ixion {
public:
no_free_dynamic_ref(no_free_dynamic_ref const &src)
: ref_base<T>(src),Manager(src.Manager) {
Manager.addNoFreeReference(Instance);
Manager.addNoFreeReference(this->Instance);
}
no_free_dynamic_ref(reference_manager<T> &mgr,T *instance = NULL)
: ref_base<T>(instance),Manager(mgr) {
Manager.addNoFreeReference(Instance);
Manager.addNoFreeReference(this->Instance);
}
~no_free_dynamic_ref() {
Manager.removeNoFreeReference(Instance);
Manager.removeNoFreeReference(this->Instance);
}

// assignment
Expand All @@ -356,20 +363,20 @@ namespace ixion {

// methods
void release() {
Manager.removeNoFreeReference(Instance);
Instance = NULL;
Manager.removeNoFreeReference(this->Instance);
this->Instance = NULL;
}
void set(T *instance) {
if (instance == Instance) return;
if (instance == this->Instance) return;

Manager.removeNoFreeReference(Instance);
Instance = instance;
Manager.addNoFreeReference(Instance);
Manager.removeNoFreeReference(this->Instance);
this->Instance = instance;
Manager.addNoFreeReference(this->Instance);
}
T *releaseFromGCArena() {
T *oldinst = Instance;
Manager.forgetReference(Instance);
Instance = NULL;
T *oldinst = this->Instance;
Manager.forgetReference(this->Instance);
this->Instance = NULL;
return oldinst;
}
};
Expand Down Expand Up @@ -485,8 +492,7 @@ namespace ixion {



#define IXLIB_GARBAGE_DECLARE_MANAGER(TYPE) \
ixion::reference_manager<TYPE> ixion::reference_manager_keeper<TYPE>::Manager;
#define IXLIB_GARBAGE_DECLARE_MANAGER(TYPE)
}


Expand Down
10 changes: 5 additions & 5 deletions src/ixlib_javascript.hpp
Expand Up @@ -104,25 +104,25 @@ namespace ixion {

// exceptions ---------------------------------------------------------------
struct no_location_javascript_exception : public base_exception {
no_location_javascript_exception(TErrorCode error,char const *info = NULL,char *module = NULL,
no_location_javascript_exception(TErrorCode error,char const *info = NULL,const char *module = NULL,
TIndex line = 0)
: base_exception(error,info,module,line,"JS") {
}
virtual char *getText() const;
virtual const char *getText() const;
};




struct javascript_exception : public base_exception {
javascript_exception(TErrorCode error,char const *info = NULL,char *module = NULL,
javascript_exception(TErrorCode error,char const *info = NULL,const char *module = NULL,
TIndex line = 0)
: base_exception(error,info,module,line,"JS") {
}
javascript_exception(TErrorCode error,javascript::code_location const &loc,char const *info = 0,char *module = NULL,
javascript_exception(TErrorCode error,javascript::code_location const &loc,char const *info = 0,char const *module = NULL,
TIndex line = 0);
javascript_exception(no_location_javascript_exception const &half_ex,javascript::code_location const &loc);
virtual char *getText() const;
virtual const char *getText() const;
};


Expand Down

0 comments on commit 84e96ee

Please sign in to comment.