More compatibility with exotic compilers (yes, I actually tried to port Panda to clang)

This commit is contained in:
rdb 2010-04-07 16:59:46 +00:00
parent 6418e6f221
commit 102b46878e
10 changed files with 104 additions and 54 deletions

View File

@ -95,6 +95,8 @@
#define _WIN32_WINNT 0x0502
#ifdef HAVE_PYTHON
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
#include "pyconfig.h"
#endif

View File

@ -42,7 +42,7 @@ Filename(const char *filename) {
////////////////////////////////////////////////////////////////////
INLINE Filename::
Filename(const Filename &copy) :
_filename(copy._filename),
_filename(copy._filename.c_str()),
_dirname_end(copy._dirname_end),
_basename_start(copy._basename_start),
_basename_end(copy._basename_end),
@ -269,7 +269,7 @@ operator + (const string &other) const {
////////////////////////////////////////////////////////////////////
INLINE string Filename::
get_fullpath() const {
return _filename;
return _filename.c_str();
}
////////////////////////////////////////////////////////////////////

View File

@ -1198,7 +1198,7 @@ to_os_specific() const {
return convert_pathname(standard.get_fullpath());
}
#else // WIN32
return standard;
return standard.c_str();
#endif // WIN32
}
@ -2432,7 +2432,7 @@ touch() const {
////////////////////////////////////////////////////////////////////
bool Filename::
chdir() const {
Filename os_specific = to_os_specific();
string os_specific = to_os_specific();
return (::chdir(os_specific.c_str()) >= 0);
}

View File

@ -590,6 +590,9 @@ do_remove(AsyncTask *task) {
removed = true;
cleanup_task(task, false, false);
}
default:
break;
}
return removed;

View File

@ -104,7 +104,7 @@ p() const {
template<class T>
INLINE PointerTo<T> &PointerTo<T>::
operator = (To *ptr) {
reassign(ptr);
this->reassign(ptr);
return *this;
}
@ -116,7 +116,7 @@ operator = (To *ptr) {
template<class T>
INLINE PointerTo<T> &PointerTo<T>::
operator = (const PointerTo<T> &copy) {
reassign((const PointerToBase<T> &)copy);
this->reassign((const PointerToBase<T> &)copy);
return *this;
}
@ -226,7 +226,7 @@ p() const {
template<class T>
INLINE ConstPointerTo<T> &ConstPointerTo<T>::
operator = (const To *ptr) {
reassign((To *)ptr);
this->reassign((To *)ptr);
return *this;
}
@ -238,7 +238,7 @@ operator = (const To *ptr) {
template<class T>
INLINE ConstPointerTo<T> &ConstPointerTo<T>::
operator = (const PointerTo<T> &copy) {
reassign((const PointerToBase<T> &)copy);
this->reassign((const PointerToBase<T> &)copy);
return *this;
}
@ -250,6 +250,6 @@ operator = (const PointerTo<T> &copy) {
template<class T>
INLINE ConstPointerTo<T> &ConstPointerTo<T>::
operator = (const ConstPointerTo<T> &copy) {
reassign((const PointerToBase<T> &)copy);
this->reassign((const PointerToBase<T> &)copy);
return *this;
}

View File

@ -249,7 +249,7 @@ template<class Element>
INLINE void PointerToArray<Element>::
reserve(TYPENAME PointerToArray<Element>::size_type n) {
if ((this->_void_ptr) == NULL) {
reassign(new ReferenceCountedVector<Element>(_type_handle));
((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
}
((To *)(this->_void_ptr))->reserve(n);
}
@ -263,7 +263,7 @@ template<class Element>
INLINE void PointerToArray<Element>::
resize(TYPENAME PointerToArray<Element>::size_type n) {
if ((this->_void_ptr) == NULL) {
reassign(new ReferenceCountedVector<Element>(_type_handle));
((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
}
((To *)(this->_void_ptr))->resize(n);
}
@ -323,7 +323,7 @@ template<class Element>
INLINE TYPENAME PointerToArray<Element>::iterator PointerToArray<Element>::
insert(iterator position, const Element &x) {
if ((this->_void_ptr) == NULL) {
reassign(new ReferenceCountedVector<Element>(_type_handle));
((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
position = end();
}
nassertr(position >= ((To *)(this->_void_ptr))->begin() &&
@ -340,7 +340,7 @@ template<class Element>
INLINE void PointerToArray<Element>::
insert(iterator position, size_type n, const Element &x) {
if ((this->_void_ptr) == NULL) {
reassign(new ReferenceCountedVector<Element>(_type_handle));
((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
position = end();
}
nassertv(position >= ((To *)(this->_void_ptr))->begin() &&
@ -416,7 +416,7 @@ template<class Element>
INLINE void PointerToArray<Element>::
push_back(const Element &x) {
if ((this->_void_ptr) == NULL) {
reassign(new ReferenceCountedVector<Element>(_type_handle));
((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>(_type_handle));
}
((To *)(this->_void_ptr))->push_back(x);
}
@ -676,7 +676,7 @@ get_void_ptr() const {
template<class Element>
INLINE void PointerToArray<Element>::
set_void_ptr(void *p) {
reassign((To *)p);
((PointerToArray<Element> *)this)->reassign((To *)p);
}
////////////////////////////////////////////////////////////////////
@ -735,7 +735,7 @@ node_unref() const {
template<class Element>
INLINE PointerToArray<Element> &PointerToArray<Element>::
operator = (ReferenceCountedVector<Element> *ptr) {
reassign(ptr);
((PointerToArray<Element> *)this)->reassign(ptr);
return *this;
}
@ -748,7 +748,7 @@ template<class Element>
INLINE PointerToArray<Element> &PointerToArray<Element>::
operator = (const PointerToArray<Element> &copy) {
_type_handle = copy._type_handle;
reassign(copy);
((PointerToArray<Element> *)this)->reassign(copy);
return *this;
}
@ -762,7 +762,7 @@ operator = (const PointerToArray<Element> &copy) {
template<class Element>
INLINE void PointerToArray<Element>::
clear() {
reassign((ReferenceCountedVector<Element> *)NULL);
((PointerToArray<Element> *)this)->reassign((ReferenceCountedVector<Element> *)NULL);
}
@ -1167,7 +1167,7 @@ node_unref() const {
template<class Element>
INLINE ConstPointerToArray<Element> &ConstPointerToArray<Element>::
operator = (ReferenceCountedVector<Element> *ptr) {
reassign(ptr);
((ConstPointerToArray<Element> *)this)->reassign(ptr);
return *this;
}
@ -1180,7 +1180,7 @@ template<class Element>
INLINE ConstPointerToArray<Element> &ConstPointerToArray<Element>::
operator = (const PointerToArray<Element> &copy) {
_type_handle = copy._type_handle;
reassign(copy);
((ConstPointerToArray<Element> *)this)->reassign(copy);
return *this;
}
@ -1193,7 +1193,7 @@ template<class Element>
INLINE ConstPointerToArray<Element> &ConstPointerToArray<Element>::
operator = (const ConstPointerToArray<Element> &copy) {
_type_handle = copy._type_handle;
reassign(copy);
((ConstPointerToArray<Element> *)this)->reassign(copy);
return *this;
}
@ -1207,7 +1207,7 @@ operator = (const ConstPointerToArray<Element> &copy) {
template<class Element>
INLINE void ConstPointerToArray<Element>::
clear() {
reassign((ReferenceCountedVector<Element> *)NULL);
((ConstPointerToArray<Element> *)this)->reassign((ReferenceCountedVector<Element> *)NULL);
}
#endif // CPPPARSER

View File

@ -122,7 +122,7 @@ get_orig() const {
template<class T>
INLINE WeakPointerTo<T> &WeakPointerTo<T>::
operator = (To *ptr) {
reassign(ptr);
((WeakPointerTo<T> *)this)->reassign(ptr);
return *this;
}
@ -134,7 +134,7 @@ operator = (To *ptr) {
template<class T>
INLINE WeakPointerTo<T> &WeakPointerTo<T>::
operator = (const PointerTo<T> &copy) {
reassign((const PointerToBase<T> &)copy);
((WeakPointerTo<T> *)this)->reassign((const PointerToBase<T> &)copy);
return *this;
}
@ -146,7 +146,7 @@ operator = (const PointerTo<T> &copy) {
template<class T>
INLINE WeakPointerTo<T> &WeakPointerTo<T>::
operator = (const WeakPointerTo<T> &copy) {
reassign((const PointerToBase<T> &)copy);
((WeakPointerTo<T> *)this)->reassign((const PointerToBase<T> &)copy);
return *this;
}
@ -286,7 +286,7 @@ get_orig() const {
template<class T>
INLINE WeakConstPointerTo<T> &WeakConstPointerTo<T>::
operator = (const To *ptr) {
reassign((To *)ptr);
((WeakConstPointerTo<T> *)this)->reassign((To *)ptr);
return *this;
}
@ -298,7 +298,7 @@ operator = (const To *ptr) {
template<class T>
INLINE WeakConstPointerTo<T> &WeakConstPointerTo<T>::
operator = (const PointerTo<T> &copy) {
reassign((const PointerToBase<T> &)copy);
((WeakConstPointerTo<T> *)this)->reassign((const PointerToBase<T> &)copy);
return *this;
}
@ -310,7 +310,7 @@ operator = (const PointerTo<T> &copy) {
template<class T>
INLINE WeakConstPointerTo<T> &WeakConstPointerTo<T>::
operator = (const ConstPointerTo<T> &copy) {
reassign((const PointerToBase<T> &)copy);
((WeakConstPointerTo<T> *)this)->reassign((const PointerToBase<T> &)copy);
return *this;
}
@ -322,7 +322,7 @@ operator = (const ConstPointerTo<T> &copy) {
template<class T>
INLINE WeakConstPointerTo<T> &WeakConstPointerTo<T>::
operator = (const WeakPointerTo<T> &copy) {
reassign((const PointerToBase<T> &)copy);
((WeakConstPointerTo<T> *)this)->reassign((const PointerToBase<T> &)copy);
return *this;
}
@ -334,6 +334,6 @@ operator = (const WeakPointerTo<T> &copy) {
template<class T>
INLINE WeakConstPointerTo<T> &WeakConstPointerTo<T>::
operator = (const WeakConstPointerTo<T> &copy) {
reassign((const PointerToBase<T> &)copy);
((WeakConstPointerTo<T> *)this)->assign((const PointerToBase<T> &)copy);
return *this;
}

View File

@ -203,14 +203,13 @@ cp_errchk_parameter_float(ShaderArgInfo &p, int lo, int hi)
// Description:
////////////////////////////////////////////////////////////////////
bool Shader::
cp_errchk_parameter_ptr(ShaderArgInfo &p)
{
switch(p._class) {
cp_errchk_parameter_ptr(ShaderArgInfo &p) {
switch (p._class) {
case SAC_scalar: return true;
case SAC_vector: return true;
case SAC_matrix: return true;
case SAC_array:
switch(p._subclass){
switch (p._subclass){
case SAC_scalar: return true;
case SAC_vector: return true;
case SAC_matrix: return true;
@ -491,7 +490,7 @@ void Shader::recurse_parameters(CGparameter parameter,
CGenum vbl = cgGetParameterVariability(parameter);
if ((vbl==CG_VARYING)||(vbl==CG_UNIFORM)){
switch(cgGetParameterType(parameter)) {
switch (cgGetParameterType(parameter)) {
case CG_STRUCT:
recurse_parameters(
cgGetFirstStructParameter(parameter),type,success); break;
@ -1133,7 +1132,7 @@ compile_parameter(const ShaderArgId &arg_id,
ShaderTexSpec bind;
bind._id = arg_id;
bind._name = kinputname;
bind._desired_type=Texture::TT_1d_texture;
bind._desired_type = Texture::TT_1d_texture;
_tex_spec.push_back(bind);
return true;
}
@ -1141,7 +1140,7 @@ compile_parameter(const ShaderArgId &arg_id,
ShaderTexSpec bind;
bind._id = arg_id;
bind._name = kinputname;
bind._desired_type=Texture::TT_2d_texture;
bind._desired_type = Texture::TT_2d_texture;
_tex_spec.push_back(bind);
return true;
}
@ -1149,7 +1148,7 @@ compile_parameter(const ShaderArgId &arg_id,
ShaderTexSpec bind;
bind._id = arg_id;
bind._name = kinputname;
bind._desired_type=Texture::TT_3d_texture;
bind._desired_type = Texture::TT_3d_texture;
_tex_spec.push_back(bind);
return true;
}
@ -1200,7 +1199,7 @@ cg_parameter_type(CGparameter p) {
switch (cgGetParameterClass(p)) {
case CG_PARAMETERCLASS_SCALAR: return SAT_scalar;
case CG_PARAMETERCLASS_VECTOR:
switch(cgGetParameterColumns(p)){
switch (cgGetParameterColumns(p)){
case 1: return SAT_vec1;
case 2: return SAT_vec2;
case 3: return SAT_vec3;
@ -1208,9 +1207,9 @@ cg_parameter_type(CGparameter p) {
default: return SAT_unknown;
}
case CG_PARAMETERCLASS_MATRIX:
switch(cgGetParameterRows(p)){
switch (cgGetParameterRows(p)){
case 1:
switch(cgGetParameterColumns(p)){
switch (cgGetParameterColumns(p)){
case 1: return SAT_mat1x1;
case 2: return SAT_mat1x2;
case 3: return SAT_mat1x3;
@ -1218,7 +1217,7 @@ cg_parameter_type(CGparameter p) {
default: return SAT_unknown;
}
case 2:
switch(cgGetParameterColumns(p)){
switch (cgGetParameterColumns(p)){
case 1: return SAT_mat2x1;
case 2: return SAT_mat2x2;
case 3: return SAT_mat2x3;
@ -1226,7 +1225,7 @@ cg_parameter_type(CGparameter p) {
default: return SAT_unknown;
}
case 3:
switch(cgGetParameterColumns(p)){
switch (cgGetParameterColumns(p)){
case 1: return SAT_mat3x1;
case 2: return SAT_mat3x2;
case 3: return SAT_mat3x3;
@ -1234,7 +1233,7 @@ cg_parameter_type(CGparameter p) {
default: return SAT_unknown;
}
case 4:
switch(cgGetParameterColumns(p)){
switch (cgGetParameterColumns(p)){
case 1: return SAT_mat4x1;
case 2: return SAT_mat4x2;
case 3: return SAT_mat4x3;
@ -1244,7 +1243,7 @@ cg_parameter_type(CGparameter p) {
default: return SAT_unknown;
}
case CG_PARAMETERCLASS_SAMPLER:
switch(cgGetParameterType(p)){
switch (cgGetParameterType(p)){
case CG_SAMPLER1D: return Shader::SAT_sampler1d;
case CG_SAMPLER2D: return Shader::SAT_sampler2d;
case CG_SAMPLER3D: return Shader::SAT_sampler3d;
@ -1327,7 +1326,7 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, ShaderType typ
int active, ultimate;
switch(type) {
switch (type) {
case ST_vertex:
active = caps._active_vprofile;
ultimate = caps._ultimate_vprofile;
@ -1342,6 +1341,10 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, ShaderType typ
active = caps._active_gprofile;
ultimate = caps._ultimate_gprofile;
break;
case ST_none:
active = CG_PROFILE_UNKNOWN;
ultimate = CG_PROFILE_UNKNOWN;
};
cgGetError();
@ -1662,9 +1665,9 @@ cg_analyze_shader(const ShaderCaps &caps) {
////////////////////////////////////////////////////////////////////
CGprogram Shader::
cg_program_from_shadertype(ShaderType type) {
CGprogram prog = 0;
CGprogram prog;
switch(type) {
switch (type) {
case ST_vertex:
prog = _cg_vprogram;
break;
@ -1676,6 +1679,9 @@ cg_program_from_shadertype(ShaderType type) {
case ST_geometry:
prog = _cg_gprogram;
break;
default:
prog = 0;
};
return prog;

View File

@ -611,6 +611,9 @@ estimate_texture_memory() const {
case Texture::F_rgba32:
bpp = 16;
break;
default:
break;
}
size_t bytes = pixels * bpp;
@ -1377,6 +1380,9 @@ write(ostream &out, int indent_level) const {
case T_float:
out << " floats";
break;
default:
break;
}
out << ", ";
@ -1390,6 +1396,15 @@ write(ostream &out, int indent_level) const {
case F_depth_component:
out << "depth_component";
break;
case F_depth_component16:
out << "depth_component16";
break;
case F_depth_component24:
out << "depth_component24";
break;
case F_depth_component32:
out << "depth_component32";
break;
case F_rgba:
out << "rgba";
@ -3539,6 +3554,9 @@ do_compress_ram_image(Texture::CompressionMode compression,
case CM_dxt5:
squish_flags |= squish::kDxt5;
break;
default:
break;
}
if (squish_flags != 0) {
@ -3557,6 +3575,9 @@ do_compress_ram_image(Texture::CompressionMode compression,
case QL_best:
squish_flags |= squish::kColourIterativeClusterFit;
break;
default:
break;
}
if (do_squish(compression, squish_flags)) {
@ -3592,6 +3613,9 @@ do_uncompress_ram_image() {
case CM_dxt5:
squish_flags |= squish::kDxt5;
break;
default:
break;
}
if (squish_flags != 0) {
@ -3896,6 +3920,9 @@ do_set_format(Texture::Format format) {
case F_color_index:
case F_depth_stencil:
case F_depth_component:
case F_depth_component16:
case F_depth_component24:
case F_depth_component32:
case F_red:
case F_green:
case F_blue:
@ -3951,6 +3978,10 @@ do_set_component_type(Texture::ComponentType component_type) {
case T_float:
_component_width = 4;
break;
case T_unsigned_int_24_8:
//FIXME: I have no idea...
break;
}
}
@ -6356,6 +6387,8 @@ operator << (ostream &out, Texture::ComponentType ct) {
return out << "unsigned_short";
case Texture::T_float:
return out << "float";
case Texture::T_unsigned_int_24_8:
return out << "unsigned_int_24_8";
}
return out << "(**invalid Texture::ComponentType(" << (int)ct << ")**)";
@ -6372,6 +6405,12 @@ operator << (ostream &out, Texture::Format f) {
return out << "depth_stencil";
case Texture::F_depth_component:
return out << "depth_component";
case Texture::F_depth_component16:
return out << "depth_component16";
case Texture::F_depth_component24:
return out << "depth_component24";
case Texture::F_depth_component32:
return out << "depth_component32";
case Texture::F_color_index:
return out << "color_index";
case Texture::F_red:

View File

@ -86,7 +86,7 @@ TexturePeeker(Texture *tex) {
_get_component = Texture::get_unsigned_short;
break;
case Texture::T_float:
default:
// Not supported.
_image.clear();
return;
@ -95,10 +95,6 @@ TexturePeeker(Texture *tex) {
switch (_format) {
case Texture::F_depth_stencil:
case Texture::F_depth_component:
case Texture::F_color_index:
// Not supported.
_image.clear();
return;
case Texture::F_red:
_get_texel = get_texel_r;
@ -143,7 +139,11 @@ TexturePeeker(Texture *tex) {
case Texture::F_rgba32:
_get_texel = get_texel_rgba;
break;
}
default:
// Not supported.
_image.clear();
return;
}
}