Skip to content

Commit

Permalink
Solution for issue #185
Browse files Browse the repository at this point in the history
  • Loading branch information
omix committed Jan 12, 2024
1 parent 9bf9d62 commit a870a86
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 29 deletions.
29 changes: 21 additions & 8 deletions src/cpp/QtJambiGenerator/parser/rpp/pp-engine-bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ namespace rpp {
}
}

assert(*__first == ')');
assert(*__first == ')' || *__first == '\\');
++__first;
}

Expand Down Expand Up @@ -679,11 +679,16 @@ namespace rpp {
#else
QByteArrayView macroName(macro_name->begin(), macro_name->size());
#endif
if(macroName=="QT_CONFIG"){
if(definition=="0")
definition = "0";
else
definition = "1";
if(macroName.startsWith("QT_FEATURE_")){
definition = "1";
}else if(macroName.startsWith("QTJAMBI_FEATURE_")){
QByteArray feature("QT");
feature.append(macroName.mid(7));
pp_fast_string _macro_name(feature.constBegin(), feature.size());
if(rpp::pp_macro * macro = env.resolve(&_macro_name)){
env.unbind(macro->name);
macro_name = macro->name;
}
}else if(macroName.startsWith("QT_DEPRECATED_VERSION_X")){
definition = "Q_DECL_DEPRECATED_X(text)";
}else if(macroName.startsWith("QT_DEPRECATED_VERSION")){
Expand Down Expand Up @@ -842,6 +847,14 @@ namespace rpp {
}
}
}else{
if(rpp::pp_macro * macro = env.resolve(_M_current_text.c_str(), _M_current_text.size())){
if(macro->definition && !QLatin1String(macro->definition->begin(), macro->definition->size()).contains(QLatin1String(_M_current_text.c_str(), _M_current_text.size()))){
std::string previous_text(_M_current_text);
_M_current_text = std::string(macro->definition->begin(), macro->definition->end());
eval_expression(macro->definition->begin(), macro->definition->end(), result);
_M_current_text = previous_text;
}
}
break;
}
}
Expand Down Expand Up @@ -1288,9 +1301,9 @@ namespace rpp {
std::copy(__first, end_macro_name, __buffer);

pp_fast_string const __tmp(__buffer, __size);
bool success = env.unbind(&__tmp);
if((verbose & DEBUGLOG_UNDEF) != 0)
std::cout << "#undef " << std::string(__tmp.begin(), __tmp.end()) << std::endl;
env.unbind(&__tmp);
std::cout << "#undef " << std::string(__tmp.begin(), __tmp.end()) << (success ? "" : " failed!!!") << std::endl;

__first = end_macro_name;

Expand Down
13 changes: 8 additions & 5 deletions src/cpp/QtJambiGenerator/parser/rpp/pp-environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,27 @@ void rpp::pp_environment::bind(pp_fast_string const *__name, pp_macro const &__m
x__macro.assign(__macro.definition->begin(), __macro.definition->size());
else
x__macro = "<nul>";
std::cerr << "** DEFINE " << x__name.assign(__name->begin(), __name->size()) << " " << x__macro << " ** in " << current_file << std::endl;
std::cerr << "** DEFINE " << x__name.assign(__name->begin(), __name->size()) << " " << x__macro << " ** in " << qPrintable(current_file.absoluteFilePath()) << std::endl;
#endif
}

void rpp::pp_environment::unbind(pp_fast_string const *__name) {
bool rpp::pp_environment::unbind(pp_fast_string const *__name) {
bool result{false};
if (pp_macro *m = resolve(__name)){
m->hidden = true;
_M_featureRegistry(std::string(__name->begin()), m->definition ? std::string(m->definition->begin()) : std::string(), current_file, false);
result = true;
}
#ifdef DEBUG_DEFUNDEF
std::string x__name = std::string((const char *)__name);
std::cerr << "** UNDEF " << x__name.assign(__name->begin(), __name->size()) << " ** in " << current_file << std::endl;
std::cerr << "** UNDEF " << x__name.assign(__name->begin(), __name->size()) << " ** in " << qPrintable(current_file.absoluteFilePath()) << std::endl;
#endif
return result;
}

void rpp::pp_environment::unbind(char const *__s, std::size_t __size) {
bool rpp::pp_environment::unbind(char const *__s, std::size_t __size) {
rpp::pp_fast_string __tmp(__s, __size);
unbind(&__tmp);
return unbind(&__tmp);
}

rpp::pp_macro *rpp::pp_environment::resolve(pp_fast_string const *p_name) const {
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/QtJambiGenerator/parser/rpp/pp-environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ namespace rpp {

void bind(pp_fast_string const *__name, pp_macro const &__macro);

void unbind(pp_fast_string const *__name);
bool unbind(pp_fast_string const *__name);

void unbind(char const *__s, std::size_t __size);
bool unbind(char const *__s, std::size_t __size);

/**
* Find corresponding pp_macro from hash table.
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/QtJambiGenerator/parser/rpp/pp-macro-expander.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace rpp {
first = skip_blanks(++first, last);
lines += skip_blanks.lines;

if (first != last && *first == '#')
if (first != last && *first == '#' && !frame)
break;
} else if (*first == '#') {
first = skip_blanks(++first, last);
Expand Down
22 changes: 9 additions & 13 deletions src/cpp/QtJambiGenerator/targets/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define QT_KEYPAD_NAVIGATION

#define QT_NO_STL
#define Q_BYTE_ORDER Q_BYTE_ORDER
#define Q_BYTE_ORDER 1

//qtjambi preprocessor does not understand properly
#define GL_APIENTRY
Expand Down Expand Up @@ -583,19 +583,17 @@ typedef void (*GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,

#ifndef QTJAMBI_NO_OPENGL

#include <QtOpenGL/QtOpenGL>
#include <QtJambiOpenGL/hashes.h>

#undef QT_CONFIG
#define QT_CONFIG(A) 0
#endif

#ifdef QT_NO_OPENGL
#undef QT_NO_OPENGL
#define QT_NO_OPENGL_BRIDGE
#endif

#include <QtOpenGL/QOpenGLPixelTransferOptions>
#include <QtOpenGL/QtOpenGL>
#include <QtJambiOpenGL/hashes.h>
#include <QtOpenGL/qopenglfunctions_es2.h>

#define QTJAMBI_FEATURE_opengles2 -1

#include <QtOpenGL/qopenglfunctions_1_0.h>
#include <QtOpenGL/qopenglfunctions_1_1.h>
#include <QtOpenGL/qopenglfunctions_1_2.h>
Expand Down Expand Up @@ -623,10 +621,8 @@ typedef void (*GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,
#include <QtOpenGL/qopenglfunctions_4_5_compatibility.h>
#include <QtOpenGL/qopenglfunctions_4_5_core.h>

#undef QT_CONFIG
#define QT_CONFIG(feature) (1/QT_FEATURE_##feature == 1)

#include <QtOpenGL/qopenglfunctions_es2.h>
#undef QT_FEATURE_opengles2
#define QT_FEATURE_opengles2 1

#ifdef QT_NO_OPENGL_BRIDGE
#undef QT_NO_OPENGL_BRIDGE
Expand Down

0 comments on commit a870a86

Please sign in to comment.