mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Work around strange interrogate issues
This commit is contained in:
parent
b65ad853fe
commit
6a0c98d54e
@ -617,23 +617,39 @@ evaluate() const {
|
|||||||
// long as we can evaluate the second one *and* that comes out
|
// long as we can evaluate the second one *and* that comes out
|
||||||
// to be true.
|
// to be true.
|
||||||
if (_u._op._operator == OROR && r2._type == RT_integer &&
|
if (_u._op._operator == OROR && r2._type == RT_integer &&
|
||||||
r2.as_integer() != 0) {
|
r2.as_boolean()) {
|
||||||
return r2;
|
return r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ditto for the operator being && and the second one coming out
|
// Ditto for the operator being && and the second one coming out
|
||||||
// false.
|
// false.
|
||||||
if (_u._op._operator == ANDAND && r2._type == RT_integer &&
|
if (_u._op._operator == ANDAND && r2._type == RT_integer &&
|
||||||
r2.as_integer() == 0) {
|
!r2.as_boolean()) {
|
||||||
return r2;
|
return r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also for the operator being [] and the operand being a string.
|
||||||
|
if (_u._op._operator == '[' && r2._type == RT_integer &&
|
||||||
|
(_u._op._op1->_type == T_string ||
|
||||||
|
_u._op._op1->_type == T_u8string)) {
|
||||||
|
|
||||||
|
int index = r2.as_integer();
|
||||||
|
if (index == _u._op._op1->_str.size()) {
|
||||||
|
return Result(0);
|
||||||
|
} else if (index >= 0 && index < _u._op._op1->_str.size()) {
|
||||||
|
return Result(_u._op._op1->_str[index]);
|
||||||
|
} else {
|
||||||
|
cerr << "array index " << index << " out of bounds of string literal "
|
||||||
|
<< *_u._op._op1 << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return r1;
|
return r1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (_u._op._operator) {
|
switch (_u._op._operator) {
|
||||||
case UNARY_NOT:
|
case UNARY_NOT:
|
||||||
return Result(!r1.as_integer());
|
return Result(!r1.as_boolean());
|
||||||
|
|
||||||
case UNARY_NEGATE:
|
case UNARY_NEGATE:
|
||||||
return Result(~r1.as_integer());
|
return Result(~r1.as_integer());
|
||||||
@ -683,14 +699,14 @@ evaluate() const {
|
|||||||
return Result(r1.as_integer() & r2.as_integer());
|
return Result(r1.as_integer() & r2.as_integer());
|
||||||
|
|
||||||
case OROR:
|
case OROR:
|
||||||
if (r1.as_integer()) {
|
if (r1.as_boolean()) {
|
||||||
return r1;
|
return r1;
|
||||||
} else {
|
} else {
|
||||||
return r2;
|
return r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ANDAND:
|
case ANDAND:
|
||||||
if (r1.as_integer()) {
|
if (r1.as_boolean()) {
|
||||||
return r2;
|
return r2;
|
||||||
} else {
|
} else {
|
||||||
return r1;
|
return r1;
|
||||||
|
@ -904,7 +904,7 @@ expand_manifests(const string &input_expr, bool expand_undefined) {
|
|||||||
CPPExpression *CPPPreprocessor::
|
CPPExpression *CPPPreprocessor::
|
||||||
parse_expr(const string &input_expr, CPPScope *current_scope,
|
parse_expr(const string &input_expr, CPPScope *current_scope,
|
||||||
CPPScope *global_scope) {
|
CPPScope *global_scope) {
|
||||||
string expr = expand_manifests(input_expr, true);
|
string expr = expand_manifests(input_expr, false);
|
||||||
|
|
||||||
CPPExpressionParser ep(current_scope, global_scope);
|
CPPExpressionParser ep(current_scope, global_scope);
|
||||||
ep._verbose = 0;
|
ep._verbose = 0;
|
||||||
@ -1552,15 +1552,18 @@ handle_ifndef_directive(const string &args, const YYLTYPE &loc) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void CPPPreprocessor::
|
void CPPPreprocessor::
|
||||||
handle_if_directive(const string &args, const YYLTYPE &loc) {
|
handle_if_directive(const string &args, const YYLTYPE &loc) {
|
||||||
CPPExpression *expr = parse_expr(args, global_scope, global_scope);
|
// When expanding manifests, we should replace unknown macros
|
||||||
|
// with 0.
|
||||||
|
string expr = expand_manifests(args, true);
|
||||||
|
|
||||||
int expression_result = 0;
|
int expression_result = 0;
|
||||||
|
CPPExpressionParser ep(current_scope, global_scope);
|
||||||
if (expr != (CPPExpression *)NULL) {
|
ep._verbose = 0;
|
||||||
CPPExpression::Result result = expr->evaluate();
|
if (ep.parse_expr(expr, *this)) {
|
||||||
|
CPPExpression::Result result = ep._expr->evaluate();
|
||||||
if (result._type == CPPExpression::RT_error) {
|
if (result._type == CPPExpression::RT_error) {
|
||||||
ostringstream strm;
|
ostringstream strm;
|
||||||
strm << *expr;
|
strm << *ep._expr;
|
||||||
warning("Ignoring invalid expression " + strm.str(), loc);
|
warning("Ignoring invalid expression " + strm.str(), loc);
|
||||||
} else {
|
} else {
|
||||||
expression_result = result.as_integer();
|
expression_result = result.as_integer();
|
||||||
|
@ -1059,10 +1059,6 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst,
|
|||||||
(*vi).second->substitute_decl(subst, to_scope, global_scope)->as_instance();
|
(*vi).second->substitute_decl(subst, to_scope, global_scope)->as_instance();
|
||||||
to_scope->_variables.insert(Variables::value_type((*vi).first, inst));
|
to_scope->_variables.insert(Variables::value_type((*vi).first, inst));
|
||||||
if (inst != (*vi).second) {
|
if (inst != (*vi).second) {
|
||||||
// I don't know if this _native_scope assignment is right, but it
|
|
||||||
// fixes some issues with variables in instantiated template scopes
|
|
||||||
// being printed out with an uninstantiated template scope prefix. ~rdb
|
|
||||||
inst->_ident->_native_scope = to_scope;
|
|
||||||
anything_changed = true;
|
anything_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,6 +337,16 @@ operator [] (size_t n) const {
|
|||||||
return _filename[n];
|
return _filename[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Filename::substr
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE string Filename::
|
||||||
|
substr(size_t begin) const {
|
||||||
|
return _filename.substr(begin);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Filename::substr
|
// Function: Filename::substr
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -125,7 +125,8 @@ PUBLISHED:
|
|||||||
|
|
||||||
EXTENSION(PyObject *__repr__() const);
|
EXTENSION(PyObject *__repr__() const);
|
||||||
|
|
||||||
INLINE string substr(size_t begin, size_t end = string::npos) const;
|
INLINE string substr(size_t begin) const;
|
||||||
|
INLINE string substr(size_t begin, size_t end) const;
|
||||||
INLINE void operator += (const string &other);
|
INLINE void operator += (const string &other);
|
||||||
INLINE Filename operator + (const string &other) const;
|
INLINE Filename operator + (const string &other) const;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ template<class ctype>
|
|||||||
class basic_string {
|
class basic_string {
|
||||||
public:
|
public:
|
||||||
typedef typename size_t size_type;
|
typedef typename size_t size_type;
|
||||||
static const size_t npos;
|
static const size_t npos = -1;
|
||||||
|
|
||||||
basic_string();
|
basic_string();
|
||||||
basic_string(const basic_string ©);
|
basic_string(const basic_string ©);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user