Skip to content

Commit af05799

Browse files
committed
RAYLIB: cleanup/wip
1 parent 97d0eaa commit af05799

File tree

9 files changed

+628
-539
lines changed

9 files changed

+628
-539
lines changed

clipboard/main.cpp

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

1515
clipboard_c *clipboard;
1616

17-
int sblib_init(void) {
17+
int sblib_init(const char *sourceFile) {
1818
clipboard = clipboard_new(nullptr);
1919
return clipboard != nullptr;
2020
}

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,15 @@ AC_PROG_LIBTOOL
8888
AC_PROG_CXX
8989
LT_PREREQ([2.2])
9090

91-
BUILD_SUBDIRS="imgui nuklear glfw clipboard websocket raylib"
91+
BUILD_SUBDIRS="debug imgui nuklear glfw clipboard websocket raylib"
9292
AC_SUBST(BUILD_SUBDIRS)
9393
checkDebugMode
9494

9595
libdir=${libdir}/smallbasic
9696

9797
AC_CONFIG_FILES([
9898
Makefile
99+
debug/Makefile
99100
nuklear/Makefile
100101
imgui/Makefile
101102
glfw/Makefile

debug/Makefile.am

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SmallBASIC
2+
# Copyright(C) 2001-2020 Chris Warren-Smith.
3+
#
4+
# This program is distributed under the terms of the GPL v2.0 or later
5+
# Download the GNU Public License (GPL) from www.gnu.org
6+
#
7+
8+
AM_CXXFLAGS=-fno-rtti -std=c++14
9+
AM_CPPFLAGS = -I../include -Wall
10+
lib_LTLIBRARIES = libdebug.la
11+
libdebug_la_SOURCES = main.cpp
12+
libdebug_la_LDFLAGS = -module -rpath '$(libdir)'
13+

debug/main.cpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// This file is part of SmallBASIC
2+
//
3+
// This program is distributed under the terms of the GPL v2.0 or later
4+
// Download the GNU Public License (GPL) from www.gnu.org
5+
//
6+
// Copyright(C) 2020 Chris Warren-Smith
7+
8+
#include "config.h"
9+
10+
#include <sys/stat.h>
11+
#include <cstring>
12+
#include <cstdlib>
13+
14+
#include "include/var.h"
15+
#include "include/module.h"
16+
#include "include/param.h"
17+
18+
char *programSource = nullptr;
19+
uint32_t modifiedTime;
20+
21+
uint32_t get_modified_time() {
22+
uint32_t result = 0;
23+
if (programSource != nullptr) {
24+
struct stat st_file;
25+
if (!stat(programSource, &st_file)) {
26+
result = st_file.st_mtime;
27+
}
28+
}
29+
return result;
30+
}
31+
32+
int cmd_issourcemodified(int argc, slib_par_t *params, var_t *retval) {
33+
v_setint(retval, modifiedTime < get_modified_time());
34+
return 1;
35+
}
36+
37+
FUNC_SIG lib_func[] = {
38+
{0, 0, "ISSOURCEMODIFIED", cmd_issourcemodified},
39+
};
40+
41+
int sblib_func_count() {
42+
return (sizeof(lib_func) / sizeof(lib_func[0]));
43+
}
44+
45+
int sblib_func_getname(int index, char *proc_name) {
46+
int result;
47+
if (index < sblib_func_count()) {
48+
strcpy(proc_name, lib_func[index]._name);
49+
result = 1;
50+
} else {
51+
result = 0;
52+
}
53+
return result;
54+
}
55+
56+
int sblib_func_exec(int index, int argc, slib_par_t *params, var_t *retval) {
57+
int result;
58+
if (index < sblib_func_count()) {
59+
result = lib_func[index]._command(argc, params, retval);
60+
} else {
61+
result = 0;
62+
}
63+
return result;
64+
}
65+
66+
int sblib_init(const char *sourceFile) {
67+
programSource = strdup(sourceFile);
68+
modifiedTime = get_modified_time();
69+
return 1;
70+
}
71+
72+
void sblib_close(void) {
73+
free(programSource);
74+
}

include/module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ typedef struct {
3131
*
3232
* @return non-zero on success
3333
*/
34-
int sblib_init(void);
34+
int sblib_init(const char *sourceFile);
3535

3636
/**
3737
* @ingroup modlib

include/param.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include "var.h"
1111
#include "module.h"
1212

13-
#define MAX_ARGS 8
14-
1513
typedef struct API {
1614
const char *name;
1715
int (*command)(int, slib_par_t *, var_t *retval);
@@ -22,7 +20,6 @@ typedef struct FUNC_SIG {
2220
int _max;
2321
const char *_name;
2422
int (*_command)(int, slib_par_t *, var_t *retval);
25-
int _format[MAX_ARGS];
2623
} FUNC_SIG;
2724

2825
void error(var_p_t var, const char *field, int nMin, int nMax);

nuklear/main.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,10 +833,6 @@ API lib_func[] = {
833833
{"WINDOWGETBOUNDS", cmd_windowgetbounds}
834834
};
835835

836-
int sblib_init(void) {
837-
return 1;
838-
}
839-
840836
void sblib_devinit(const char *prog, int width, int height) {
841837
_bg_color = nk_black;
842838
_fg_color = nk_white;

0 commit comments

Comments
 (0)