mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 07:48:37 -04:00
cppparser: Fix expansion of function macro used without parentheses
This commit is contained in:
parent
1213d95560
commit
e63ba11af2
@ -2233,6 +2233,14 @@ r_expand_manifests(string &expr, bool expand_undefined,
|
|||||||
if (expanded.count(manifest) == 0) {
|
if (expanded.count(manifest) == 0) {
|
||||||
vector_string args;
|
vector_string args;
|
||||||
if (manifest->_has_parameters) {
|
if (manifest->_has_parameters) {
|
||||||
|
// If it's not followed by a parenthesis, don't expand it.
|
||||||
|
while (p < expr.size() && isspace(expr[p])) {
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
if (p >= expr.size() || expr[p] != '(') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
extract_manifest_args_inline(manifest->_name, manifest->_num_parameters,
|
extract_manifest_args_inline(manifest->_name, manifest->_num_parameters,
|
||||||
manifest->_variadic_param, args, expr, p);
|
manifest->_variadic_param, args, expr, p);
|
||||||
}
|
}
|
||||||
@ -2502,23 +2510,6 @@ expand_has_include_function(string &expr, size_t q, size_t &p, YYLTYPE loc) {
|
|||||||
p = q + result.size();
|
p = q + result.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void CPPPreprocessor::
|
|
||||||
expand_manifest_inline(string &expr, size_t q, size_t &p,
|
|
||||||
const CPPManifest *manifest) {
|
|
||||||
vector_string args;
|
|
||||||
if (manifest->_has_parameters) {
|
|
||||||
extract_manifest_args_inline(manifest->_name, manifest->_num_parameters,
|
|
||||||
manifest->_variadic_param, args, expr, p);
|
|
||||||
}
|
|
||||||
string result = manifest->expand(args);
|
|
||||||
|
|
||||||
expr = expr.substr(0, q) + result + expr.substr(p);
|
|
||||||
p = q + result.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -160,8 +160,6 @@ private:
|
|||||||
int va_arg, vector_string &args);
|
int va_arg, vector_string &args);
|
||||||
void expand_defined_function(std::string &expr, size_t q, size_t &p);
|
void expand_defined_function(std::string &expr, size_t q, size_t &p);
|
||||||
void expand_has_include_function(std::string &expr, size_t q, size_t &p, YYLTYPE loc);
|
void expand_has_include_function(std::string &expr, size_t q, size_t &p, YYLTYPE loc);
|
||||||
void expand_manifest_inline(std::string &expr, size_t q, size_t &p,
|
|
||||||
const CPPManifest *manifest);
|
|
||||||
void extract_manifest_args_inline(const std::string &name, int num_args,
|
void extract_manifest_args_inline(const std::string &name, int num_args,
|
||||||
int va_arg, vector_string &args,
|
int va_arg, vector_string &args,
|
||||||
const std::string &expr, size_t &p);
|
const std::string &expr, size_t &p);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user