Skip to content

Commit 73ed935

Browse files
committed
move twr_register_callback to twr-crt.h
1 parent 15428ee commit 73ed935

File tree

5 files changed

+13
-27
lines changed

5 files changed

+13
-27
lines changed

examples/lib/testex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
#include <stdio.h>
33
#include <stdlib.h>
4-
#include "twr-library.h"
4+
#include "twr-crt.h"
55
#include "twr-ex.h"
66

77
// This example shows how to create a twrWasmLibrary

examples/lib/twr-library.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

examples/pong/entry-point.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "pong-menu.h"
2+
#include "twr-crt.h" // twr_register_callback
23

34
// #define CANVAS_WIDTH 600
45
// #define CANVAS_HEIGHT 600
@@ -10,9 +11,6 @@ static int ANIMATION_LOOP_EVENT_ID = -1;
1011
static int KEY_DOWN_EVENT_ID = -1;
1112
static int KEY_UP_EVENT_ID = -1;
1213
extern "C" {
13-
__attribute__((import_name("twr_register_callback")))
14-
int twr_register_callback(const char* func_name);
15-
1614
__attribute__((import_name("registerKeyUpEvent")))
1715
void register_key_up_event(int event_id);
1816

examples/tests-audio/tests-audio.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
#include <twr-audio.h>
2+
#include "twr-crt.h" // twr_register_callback
23
#include <stdlib.h>
34
#include <stdio.h>
45
#include <stdarg.h>
56
#include <math.h>
67

8+
79
__attribute__((import_name("clearIODiv")))
810
void clearIODiv();
911

10-
__attribute__((import_name("twr_register_callback")))
11-
int twr_register_callback(const char* func_name);
12-
1312
#define CHANNELS 2
1413
#define SAMPLE_RATE 48000
1514
#define SECONDS 3

source/twr-c/twr-crt.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ __attribute__((import_name("twrTimeEpoch"))) uint64_t twr_epoch_timems(void);
5757
__attribute__((import_name("twr_timer_single_shot"))) int twr_timer_single_shot(int milliSeconds, int eventID);
5858
__attribute__((import_name("twr_timer_repeat"))) int twr_timer_repeat(int milliSeconds, int eventID);
5959
__attribute__((import_name("twr_timer_cancel"))) void twr_timer_cancel(int timerID);
60-
void twr_tofixed(char* buffer, int buffer_size, double value, int dec_digits);
61-
void twr_toexponential(char* buffer, int buffer_size, double value, int dec_digits);
60+
61+
// does not use locale information; it always uses . (a dot) as the decimal separator.
62+
__attribute__((import_name("twrToFixed"))) double twr_tofixed(char* buffer, int buffer_size, double value, int dec_digits);
63+
64+
// does not use locale information; it always uses . (a dot) as the decimal separator.
65+
__attribute__((import_name("twrToExponential"))) void twr_toexponential(char* buffer, int buffer_size, double value, int dec_digits);
6266

6367
const char* twr_get_navlang(int *len);
6468

@@ -68,6 +72,9 @@ void twr_utf32_to_code_page(char*out, int utf32);
6872
int twr_code_page_to_utf32_streamed(unsigned char byte);
6973
void twr_localize_numeric_string(char* str, locale_t locale);
7074

75+
/* library functions */
76+
__attribute__((import_name("twr_register_callback"))) int twr_register_callback(const char* func_name);
77+
7178
/* internal utility function */
7279
void __nstrcopy(char *buffer, const int sizeInBytes, const char *outstring, const int sizeofoutstring, int n);
7380

0 commit comments

Comments
 (0)