Comments (4)
There is a byte array field in the mb_value_t
struct, which you can store some bytes in. For example passing a struct (sizeof(64) bytes) through MY-BASIC:
typedef struct Tag {
char c0[64];
} Tag;
mb_static_assert(sizeof(mb_val_bytes_t) >= sizeof(Tag));
static int test0(struct mb_interpreter_t* s, void** l) {
int result = MB_FUNC_OK;
mb_value_t val;
mb_assert(s && l);
mb_check(mb_attempt_open_bracket(s, l));
mb_check(mb_attempt_close_bracket(s, l));
Tag tag;
for (int i = 0; i < sizeof(tag.c0) - 1; ++i)
tag.c0[i] = '*';
tag.c0[sizeof(tag.c0) - 1] = '\0';
val.type = MB_DT_USERTYPE;
memset(&val.value.bytes, 0, sizeof(mb_val_bytes_t));
memcpy(&val.value.bytes, &tag, sizeof(Tag));
mb_check(mb_push_value(s, l, val));
return result;
}
static int test1(struct mb_interpreter_t* s, void** l) {
int result = MB_FUNC_OK;
mb_value_t val;
mb_assert(s && l);
mb_check(mb_attempt_open_bracket(s, l));
mb_make_nil(val);
mb_check(mb_pop_value(s, l, &val));
mb_check(mb_attempt_close_bracket(s, l));
Tag tag;
memcpy(&tag, &val.value.bytes, sizeof(Tag));
printf(tag.c0);
return result;
}
Test it with:
test1(test0())
By default, the byte array typed mb_val_bytes_t
is defined as large as maximum of sizes of void*
, unsigned long
, int_t
, real_t
, in my_basic.h
. Make sure you've redefined it large enough to store your struct:
typedef unsigned char mb_val_bytes_t[64];
from my_basic.
I've documented this feature in the wiki.
from my_basic.
I will try this! Thanks a lot ๐
I have to say, that the MY-BASIC documentation is almost too good! ๐ฅ
from my_basic.
I just finished binding my SpriteSheets to MY-BASIC - it works wonderfully.
For me, this issue has been resolved.
Thanks a lot! :)
from my_basic.
Related Issues (20)
- Very slow FOR HOT 1
- Spaces on certain keywords? HOT 2
- Type results depends on quotes used HOT 2
- Skipping Iterator variable option HOT 1
- Class member variable default value issue
- Unicode Printing Issue HOT 5
- REM and ENDREM as comment blocks HOT 2
- Crash when setting larger array sizes
- Support functions with and without brackets
- mb_debug_count_stack_frames - undeclared 'l' HOT 1
- Memory leak ? HOT 3
- (Question) Preferred way to use print/input redirect with socket I/0 HOT 1
- Compile error for ESP32S3 in platformio
- NewBee HOT 1
- 2 program chunks not giving the same result HOT 1
- FOR Loop / INT goes wild
- Memory Leaks? HOT 1
- Documentation?
- Complex Data Types?
- How to achieve one-step debugging๏ผ
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from my_basic.