Reintroduce C++ support and add usage tests for C++ #4

Merged
abdelrahman merged 7 commits from cpp_support into main 2025-08-10 22:33:41 +00:00
5 changed files with 40 additions and 0 deletions
Showing only changes of commit 92a231d3ce - Show all commits

View File

@ -11,10 +11,18 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#define CMD_NO_EXIT(ERR) ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR}) #define CMD_NO_EXIT(ERR) ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR})
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd); CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd);
external CMDError get_output_status(FILE *fp, i32 *status_out); external CMDError get_output_status(FILE *fp, i32 *status_out);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !COMMANDER_H #endif // !COMMANDER_H

View File

@ -7,6 +7,10 @@
#include "../../../../common/platform/platform.h" #include "../../../../common/platform/platform.h"
#include <stdbool.h> #include <stdbool.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
typedef enum { typedef enum {
SHELL_OUTPUT_DISCARD, SHELL_OUTPUT_DISCARD,
SHELL_OUTPUT_PRINT, SHELL_OUTPUT_PRINT,
@ -34,4 +38,8 @@ struct commander_result {
#endif // !WAPP_PLATFORM_WINDOWS #endif // !WAPP_PLATFORM_WINDOWS
}; };
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !COMMANDER_OUTPUT_H #endif // !COMMANDER_OUTPUT_H

View File

@ -8,9 +8,17 @@
#include "../../../../common/platform/platform.h" #include "../../../../common/platform/platform.h"
#include "../../../../primitives/strings/str8/str8.h" #include "../../../../primitives/strings/str8/str8.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour); void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour);
void wapp_shell_termcolour_clear_colour(void); void wapp_shell_termcolour_clear_colour(void);
external void print_coloured_text(Str8RO *text, TerminalColour colour); external void print_coloured_text(Str8RO *text, TerminalColour colour);
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !TERM_COLOUR_H #endif // !TERM_COLOUR_H

View File

@ -5,6 +5,10 @@
#include "../../../../common/platform/platform.h" #include "../../../../common/platform/platform.h"
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
typedef enum { typedef enum {
WAPP_TERM_COLOUR_FG_BLACK, WAPP_TERM_COLOUR_FG_BLACK,
WAPP_TERM_COLOUR_FG_RED, WAPP_TERM_COLOUR_FG_RED,
@ -27,4 +31,8 @@ typedef enum {
COUNT_TERM_COLOUR, COUNT_TERM_COLOUR,
} TerminalColour; } TerminalColour;
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !TERMINAL_COLOURS_H #endif // !TERMINAL_COLOURS_H

View File

@ -6,6 +6,10 @@
#include "../../../../common/platform/platform.h" #include "../../../../common/platform/platform.h"
#include <stdio.h> #include <stdio.h>
#ifdef WAPP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#ifdef WAPP_PLATFORM_WINDOWS #ifdef WAPP_PLATFORM_WINDOWS
#define wapp_shell_utils_popen _popen #define wapp_shell_utils_popen _popen
#define wapp_shell_utils_pclose _pclose #define wapp_shell_utils_pclose _pclose
@ -14,4 +18,8 @@
#define wapp_shell_utils_pclose pclose #define wapp_shell_utils_pclose pclose
#endif /* ifdef WAPP_PLATFORM_WINDOWS */ #endif /* ifdef WAPP_PLATFORM_WINDOWS */
#ifdef WAPP_PLATFORM_CPP
END_C_LINKAGE
#endif // !WAPP_PLATFORM_CPP
#endif // !SHELL_UTILS_H #endif // !SHELL_UTILS_H