Skip to content
Merged

12 27 #197

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2023-06-18 (12.27)
COMMON: Fix redim regression
PLUGINS: Added mechanism for cleaning up resources when the associated map falls out of scope

2023-05-12 (12.27)
CONSOLE: Fix image save
ANDROID: Fix download error when there are duplicate scratch.bas files

2023-03-26 (12.26)
ANDROID: Fix setenv error #187
ANDROID: update web UI dependencies
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
dnl Download the GNU Public License (GPL) from www.gnu.org
dnl

AC_INIT([smallbasic], [12.26])
AC_INIT([smallbasic], [12.27])
AC_CONFIG_SRCDIR([configure.ac])

AC_CANONICAL_TARGET
Expand Down
11 changes: 11 additions & 0 deletions samples/distro-examples/tests/array.bas
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,15 @@ p(asc("|")) = 1
p(asc("}")) = 1
p(asc("~")) = 1

'
' https://www.syntaxbomb.com/smallbasic/redim-why-to-keep-old-versons/
'
a = [0,1,2,3,4,5,6,7,8,9,10,11]
redim a(11) : if a != [0,1,2,3,4,5,6,7,8,9,10,11] then throw str(a)
redim a(1, 11) : if a != [0,1,2,3,4,5,6,7,8,9,10,11;0,0,0,0,0,0,0,0,0,0,0,0] then throw str(a)
redim a(2, 10) : if a != [0,1,2,3,4,5,6,7,8,9,10;11,0,0,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,0,0,0,0] then throw str(a)
redim a(1, 11) : if a != [0,1,2,3,4,5,6,7,8,9,10,11;0,0,0,0,0,0,0,0,0,0,0,0] then throw str(a)
redim a(10) : if a != [0,1,2,3,4,5,6,7,8,9,10] then throw str(a)
redim a(0 to 7): if a != [0,1,2,3,4,5,6,7] then throw str(a)
redim a(0 to 1): if a != [0,1] then throw str(a)

2 changes: 0 additions & 2 deletions src/common/blib.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ void cmd_dim(int preserve) {
}
if (!preserve || var_p->type != V_ARRAY) {
v_new_array(var_p, size);
} else if (v_maxdim(var_p) != dimensions) {
err_matdim();
} else {
// preserve previous array contents
v_resize_array(var_p, size);
Expand Down
2 changes: 2 additions & 0 deletions src/common/hashmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ void hashmap_create(var_p_t map, int size) {
map->type = V_MAP;
map->v.m.count = 0;
map->v.m.id = -1;
map->v.m.lib_id = -1;
map->v.m.cls_id = -1;
if (size == 0) {
map->v.m.size = MAP_SIZE;
} else {
Expand Down
15 changes: 15 additions & 0 deletions src/common/plugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef int (*sblib_exec_fn)(int, int, slib_par_t *, var_t *);
typedef int (*sblib_getname_fn) (int, char *);
typedef int (*sblib_count_fn) (void);
typedef int (*sblib_init_fn) (const char *);
typedef int (*sblib_free_fn) (int, int);
typedef void (*sblib_close_fn) (void);

typedef struct {
Expand All @@ -47,6 +48,7 @@ typedef struct {
void *_handle;
sblib_exec_fn _sblib_proc_exec;
sblib_exec_fn _sblib_func_exec;
sblib_free_fn _sblib_free;
ext_func_node_t *_func_list;
ext_proc_node_t *_proc_list;
uint32_t _id;
Expand Down Expand Up @@ -304,6 +306,7 @@ static void slib_import_routines(slib_t *lib, int comp) {

lib->_sblib_func_exec = slib_getoptptr(lib, "sblib_func_exec");
lib->_sblib_proc_exec = slib_getoptptr(lib, "sblib_proc_exec");
lib->_sblib_free = slib_getoptptr(lib, "sblib_free");
sblib_count_fn fcount = slib_getoptptr(lib, "sblib_proc_count");
sblib_getname_fn fgetname = slib_getoptptr(lib, "sblib_proc_getname");

Expand Down Expand Up @@ -471,6 +474,10 @@ static int slib_exec(slib_t *lib, var_t *ret, int index, int proc) {
free(ptable);
}

if (success && v_is_type(ret, V_MAP)) {
map_set_lib_id(ret, lib->_id);
}

return success;
}

Expand Down Expand Up @@ -598,6 +605,13 @@ int plugin_funcexec(int lib_id, int index, var_t *ret) {
return result;
}

void plugin_free(int lib_id, int cls_id, int id) {
slib_t *lib = get_lib(lib_id);
if (lib && lib->_sblib_free) {
lib->_sblib_free(cls_id, id);
}
}

void plugin_close() {
for (int i = 0; i < MAX_SLIBS; i++) {
if (plugins[i]) {
Expand Down Expand Up @@ -626,5 +640,6 @@ int plugin_get_kid(int lib_id, const char *keyword) { return -1; }
void *plugin_get_func(const char *name) { return 0; }
int plugin_procexec(int lib_id, int index) { return -1; }
int plugin_funcexec(int lib_id, int index, var_t *ret) { return -1; }
void plugin_free(int lib_id, int cls_id, int id) {}
void plugin_close() {}
#endif
5 changes: 5 additions & 0 deletions src/common/plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ int plugin_procexec(int lib_id, int index);
//
int plugin_funcexec(int lib_id, int index, var_t *ret);

//
// cleanup any resources held against the map data
//
void plugin_free(int lib_id, int cls_id, int id);

//
// closes the plugin system
//
Expand Down
3 changes: 3 additions & 0 deletions src/common/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ void v_move(var_t *dest, const var_t *src) {
break;
case V_ARRAY:
memcpy(&dest->v.a, &src->v.a, sizeof(src->v.a));
v_maxdim(dest) = v_maxdim(src);
break;
case V_PTR:
dest->v.ap.p = src->v.ap.p;
Expand All @@ -565,6 +566,8 @@ void v_move(var_t *dest, const var_t *src) {
dest->v.m.count = src->v.m.count;
dest->v.m.size = src->v.m.size;
dest->v.m.id = src->v.m.id;
dest->v.m.lib_id = src->v.m.lib_id;
dest->v.m.cls_id = src->v.m.cls_id;
break;
case V_REF:
dest->v.ref = src->v.ref;
Expand Down
Loading