Skip to content

Commit 440ae52

Browse files
committed
ecere (Emscripten): Separate EMSCRIPTEN_DEBUG definition
- _DEBUG is currently enabled in Emscripten config
1 parent 40cd3fe commit 440ae52

File tree

4 files changed

+43
-41
lines changed

4 files changed

+43
-41
lines changed

ecere/src/com/instance.ec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ namespace com;
88
#endif
99

1010
#if defined(__EMSCRIPTEN__)
11+
12+
#ifdef _DEBUG
13+
// #define EMSCRIPTEN_DEBUG
14+
#endif
15+
1116
#define DISABLE_MEMMGR
1217
#define _NOMUTEX
1318
#include <emscripten.h>
@@ -6808,7 +6813,7 @@ public dllexport Application __ecere_COM_Initialize(bool guiApp, int argc, char
68086813
{
68096814
Application app;
68106815

6811-
#if defined(__EMSCRIPTEN__) && defined(_DEBUG)
6816+
#ifdef EMSCRIPTEN_DEBUG
68126817
emscripten_log(EM_LOG_CONSOLE, "__ecere_COM_Initialize\n");
68136818
#endif
68146819

ecere/src/gfx/drivers/OpenGLDisplayDriver.ec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ asm(".symver log,log@GLIBC_2.2.5");
55
#if defined(__WIN32__) || defined(__unix__) || defined(__APPLE__)
66

77
#ifdef _DEBUG
8+
// #define EMSCRIPTEN_DEBUG
89
#define GLSTATS
910
#endif
1011

@@ -1144,7 +1145,7 @@ class OpenGLDisplayDriver : DisplayDriver
11441145
attribs.majorVersion = 2;
11451146
attribs.minorVersion = 0;
11461147
oglSystem.maxTextureSize = 16384;
1147-
#ifdef _DEBUG
1148+
#ifdef EMSCRIPTEN_DEBUG
11481149
printf("emscripten_webgl_create_context\n");
11491150
#endif
11501151
oglSystem.glc = emscripten_webgl_create_context("canvas", &attribs);
@@ -1157,7 +1158,7 @@ class OpenGLDisplayDriver : DisplayDriver
11571158
double dw = 0, dh = 0;
11581159
emscripten_get_element_css_size(target, &dw, &dh);
11591160
w = (int)dw, h = (int)dh;
1160-
#ifdef _DEBUG
1161+
#ifdef EMSCRIPTEN_DEBUG
11611162
printf("CreateDisplaySystem\n");
11621163
printf("getElementCssSize --displaydriver-- %4dx%-4d\n", w, h);
11631164
#endif

ecere/src/gui/GuiApplication.ec

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace gui;
44

55
#ifdef __EMSCRIPTEN__
6-
#include <emscripten.h>
7-
#include <html5.h>
6+
#ifdef _DEBUG
7+
// #define EMSCRIPTEN_DEBUG
88
#endif
99

10-
#ifdef __EMSCRIPTEN__
1110
#include <emscripten.h>
11+
#include <html5.h>
1212
#endif
1313

1414
#if (defined(__unix__) || defined(__APPLE__)) && !defined(__ANDROID__) && !defined(__EMSCRIPTEN__)
@@ -698,7 +698,7 @@ public:
698698
Window window;
699699

700700
#ifdef __EMSCRIPTEN__
701-
#ifdef _DEBUG
701+
#ifdef EMSCRIPTEN_DEBUG
702702
emscripten_log(EM_LOG_CONSOLE, "GuiApplication::Main\n");
703703
{
704704
bool found = false;
@@ -731,11 +731,10 @@ public:
731731

732732
emscripten_get_element_css_size(target, &dw, &dh);
733733
w = (int)dw, h = (int)dh;
734-
#ifdef _DEBUG
734+
#ifdef EMSCRIPTEN_DEBUG
735735
printf("getElementCssSize --guiapplication-- %4dx%-4d\n", w, h);
736736
{
737-
int w, h;
738-
w = h = 0;
737+
int w = 0, h = 0;
739738
emscripten_get_screen_size(&w, &h);
740739
printf("getScreenSize %4dx%-4d\n", w, h);
741740
}
@@ -750,7 +749,7 @@ public:
750749
}
751750
#endif
752751

753-
#if defined(__EMSCRIPTEN__) && defined(_DEBUG)
752+
#ifdef EMSCRIPTEN_DEBUG
754753
printf("before init\n");
755754

756755
/*
@@ -766,13 +765,8 @@ public:
766765
}
767766
*/
768767
// emscripten_run_script("document.getElementById(UTF8ToString('canvas')).getContext('2d').fillText('test', 32, 164);");
769-
770-
771-
772-
773-
774-
775768
#endif
769+
776770
if(Init())
777771
{
778772
if(desktop)
@@ -784,19 +778,17 @@ public:
784778
{
785779
if(window.autoCreate && !window.created)
786780
{
787-
#if defined(__EMSCRIPTEN__) && defined(_DEBUG)
788-
781+
#ifdef EMSCRIPTEN_DEBUG
789782
printf(" inside window.Create()\n");
790783
#endif
791784
if(window.Create())
792785
{
793-
#if defined(__EMSCRIPTEN__) && defined(_DEBUG)
794-
786+
#ifdef EMSCRIPTEN_DEBUG
795787
printf(" created\n");
796788
#endif
797789
break;
798790
}
799-
#if defined(__EMSCRIPTEN__) && defined(_DEBUG)
791+
#ifdef EMSCRIPTEN_DEBUG
800792
else
801793
printf(" failed?\n");
802794
#endif
@@ -807,7 +799,7 @@ public:
807799
}
808800

809801
#ifdef __EMSCRIPTEN__
810-
#ifdef _DEBUG
802+
#ifdef EMSCRIPTEN_DEBUG
811803
printf("emscripten_set_main_loop\n");
812804
#endif
813805
emscripten_set_main_loop(emscripten_main_loop_callback, 0 /*60*/, 1);
@@ -1796,7 +1788,7 @@ private void emscripten_main_loop_callback()
17961788
double dw = 0, dh = 0;
17971789
emscripten_get_element_css_size(target, &dw, &dh);
17981790
w = (int)dw, h = (int)dh;
1799-
#ifdef _DEBUG
1791+
#ifdef EMSCRIPTEN_DEBUG
18001792
printf("emscripten_main_loop_callback/init\n");
18011793
printf("getElementCssSize %4dx%-4d\n", w, h);
18021794
#endif

ecere/src/gui/drivers/EmscriptenInterface.ec

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public import "ecere"
1313

1414
#ifdef __EMSCRIPTEN__
1515

16+
#ifdef _DEBUG
17+
// #define EMSCRIPTEN_DEBUG
18+
#endif
19+
1620
#include <stdio.h>
1721

1822
// source file line number printf (sflnprintf)
@@ -236,7 +240,7 @@ static EM_BOOL touch_callback(int eventType, const EmscriptenTouchEvent *e, void
236240

237241
static EM_BOOL wheel_callback(int eventType, const EmscriptenWheelEvent *e, void *userData)
238242
{
239-
#ifdef _DEBUG
243+
#ifdef EMSCRIPTEN_DEBUG
240244
printf("wheel_callback\n");
241245
#endif
242246
Window window = guiApp.desktop;
@@ -268,7 +272,7 @@ EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *user
268272
Window window = guiApp.desktop;
269273
Key key = 0;
270274
bool result = 0;
271-
#ifdef _DEBUG
275+
#ifdef EMSCRIPTEN_DEBUG
272276
printf("key_callback\n");
273277
#endif
274278
switch(e->keyCode)
@@ -402,7 +406,7 @@ EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *user
402406
case 11: key = keyPadSlash; break;
403407

404408
default:
405-
#ifdef _DEBUG
409+
#ifdef EMSCRIPTEN_DEBUG
406410
printf("%s, key: \"%s\", code: \"%s\", location: %lu,%s%s%s%s repeat: %d, locale: \"%s\", char: \"%s\", charCode: %lu, keyCode: %lu, which: %lu\n",
407411
emscripten_event_type_to_string(eventType), e->key, e->code, e->location,
408412
e->ctrlKey ? " CTRL" : "", e->shiftKey ? " SHIFT" : "", e->altKey ? " ALT" : "", e->metaKey ? " META" : "",
@@ -492,7 +496,7 @@ EM_BOOL key_callback(int eventType, const EmscriptenKeyboardEvent *e, void *user
492496

493497
EM_BOOL pointerlockchange_callback(int eventType, const EmscriptenPointerlockChangeEvent *e, void *userData)
494498
{
495-
#ifdef _DEBUG
499+
#ifdef EMSCRIPTEN_DEBUG
496500
printf("pointerlockchange_callback\n");
497501
#endif
498502
if(!e->isActive)
@@ -510,7 +514,7 @@ EM_BOOL pointerlockchange_callback(int eventType, const EmscriptenPointerlockCha
510514
guiApp.acquiredWindow = w;
511515
guiApp.acquiredWindow.acquiredInput = true;
512516
}
513-
#ifdef _DEBUG
517+
#ifdef EMSCRIPTEN_DEBUG
514518
printf("%s, isActive: %d, pointerlock element nodeName: \"%s\", id: \"%s\"\n",
515519
emscripten_event_type_to_string(eventType), e->isActive, e->nodeName, e->id);
516520
#endif
@@ -536,7 +540,7 @@ EM_BOOL fullscreenchange_callback(int eventType, const EmscriptenFullscreenChang
536540

537541
int w = 0, h = 0;
538542
double dw = 0, dh = 0;
539-
#ifdef _DEBUG
543+
#ifdef EMSCRIPTEN_DEBUG
540544
printf("fullscreenchange_callback\n");
541545
#endif
542546
isFullScreen = (bool)e->isFullscreen;
@@ -565,7 +569,7 @@ EM_BOOL deviceorientation_callback(int eventType, const EmscriptenDeviceOrientat
565569
double gamma;
566570
EM_BOOL absolute;
567571
*/
568-
#ifdef _DEBUG
572+
#ifdef EMSCRIPTEN_DEBUG
569573
printf("%s, (%g, %g, %g)\n", emscripten_event_type_to_string(eventType), e->alpha, e->beta, e->gamma);
570574
#endif
571575
return 0;
@@ -585,7 +589,7 @@ EM_BOOL devicemotion_callback(int eventType, const EmscriptenDeviceMotionEvent *
585589
double rotationRateGamma;
586590
int supportedFields;
587591
*/
588-
#ifdef _DEBUG
592+
#ifdef EMSCRIPTEN_DEBUG
589593
printf("%s, accel: (%g, %g, %g), accelInclGravity: (%g, %g, %g), rotationRate: (%g, %g, %g), supportedFields: %s %s %s\n",
590594
emscripten_event_type_to_string(eventType),
591595
e->accelerationX, e->accelerationY, e->accelerationZ,
@@ -604,7 +608,7 @@ EM_BOOL orientationchange_callback(int eventType, const EmscriptenOrientationCha
604608
int orientationIndex;
605609
int orientationAngle;
606610
*/
607-
#ifdef _DEBUG
611+
#ifdef EMSCRIPTEN_DEBUG
608612
printf("%s, orientationAngle: %d, orientationIndex: %d\n", emscripten_event_type_to_string(eventType), e->orientationAngle, e->orientationIndex);
609613
#endif
610614
return 0;
@@ -616,15 +620,15 @@ EM_BOOL visibilitychange_callback(int eventType, const EmscriptenVisibilityChang
616620
EM_BOOL hidden;
617621
int visibilityState;
618622
*/
619-
#ifdef _DEBUG
623+
#ifdef EMSCRIPTEN_DEBUG
620624
printf("%s, hidden: %d, visibilityState: %d\n", emscripten_event_type_to_string(eventType), e->hidden, e->visibilityState);
621625
#endif
622626
return 0;
623627
}
624628

625629
EM_BOOL webglcontext_callback(int eventType, const void *reserved, void *userData)
626630
{
627-
#ifdef _DEBUG
631+
#ifdef EMSCRIPTEN_DEBUG
628632
printf("%s.\n", emscripten_event_type_to_string(eventType));
629633
#endif
630634
return 0;
@@ -693,15 +697,15 @@ static EM_BOOL uievent_callback(int eventType, const EmscriptenUiEvent *e, void
693697
{
694698
int w = 0, h = 0;
695699
double dw = 0, dh = 0;
696-
#ifdef _DEBUG
700+
#ifdef EMSCRIPTEN_DEBUG
697701
printf("uievent/resize\n");
698702
printf("documentBodyClient %4dx%-4d\n", e->documentBodyClientWidth, e->documentBodyClientHeight);
699703
printf("windowInner %4dx%-4d\n", e->windowInnerWidth, e->windowInnerHeight);
700704
printf("windowOuter %4dx%-4d\n", e->windowOuterWidth, e->windowOuterHeight);
701705
#endif
702706
emscripten_get_element_css_size(target, &dw, &dh);
703707
// w = (int)dw, h = (int)dh;
704-
#ifdef _DEBUG
708+
#ifdef EMSCRIPTEN_DEBUG
705709
printf("getElementCssSize --interface-- %4dx%-4d\n", w, h);
706710
#endif
707711
w = e->windowInnerWidth, h = e->windowInnerHeight;
@@ -713,13 +717,13 @@ static EM_BOOL uievent_callback(int eventType, const EmscriptenUiEvent *e, void
713717
guiApp.desktop.display.Resize(w, h);
714718
}
715719
//PrintLn("EMSCRIPTEN_EVENT_RESIZE: ", w, " x ", h);
716-
#ifdef _DEBUG
720+
#ifdef EMSCRIPTEN_DEBUG
717721
printf("scroll %4dx%-4d\n", e->scrollTop, e->scrollLeft);
718722
#endif
719723
break;
720724
}
721725
default:
722-
#ifdef _DEBUG
726+
#ifdef EMSCRIPTEN_DEBUG
723727
printf("%s, detail: %ld, document.body.client size: (%d,%d), window.inner size: (%d,%d), scrollPos: (%d, %d)\n",
724728
emscripten_event_type_to_string(eventType), e->detail, e->documentBodyClientWidth, e->documentBodyClientHeight,
725729
e->windowInnerWidth, e->windowInnerHeight, e->scrollTop, e->scrollLeft);
@@ -735,7 +739,7 @@ EM_BOOL focusevent_callback(int eventType, const EmscriptenFocusEvent *e, void *
735739
EM_UTF8 nodeName[EM_HTML5_LONG_STRING_LEN_BYTES];
736740
EM_UTF8 id[EM_HTML5_LONG_STRING_LEN_BYTES];
737741
*/
738-
#ifdef _DEBUG
742+
#ifdef EMSCRIPTEN_DEBUG
739743
printf("%s, nodeName: \"%s\", id: \"%s\"\n", emscripten_event_type_to_string(eventType), e->nodeName, e->id[0] == '\0' ? "(empty string)" : e->id);
740744
#endif
741745
return 0;
@@ -806,7 +810,7 @@ class EmscriptenInterface : Interface
806810

807811
// emscripten_log(EM_LOG_CONSOLE, "EmscriptenInterface::Initialize OK\n");
808812

809-
#ifdef _DEBUG
813+
#ifdef EMSCRIPTEN_DEBUG
810814
printf("AAA EmscriptenInterface::Initialize -- %dxOk\n", okCount);
811815
emscripten_run_script("Module.setStatus('Actually Running...');");
812816
printf("BBB EmscriptenInterface::Initialize -- is it working?\n");

0 commit comments

Comments
 (0)