miqt_string: initial commit

This commit is contained in:
mappu 2024-09-12 18:48:06 +12:00
parent 4882ed676a
commit feb375e061
2 changed files with 25 additions and 0 deletions

11
qt/binding.cpp Normal file
View File

@ -0,0 +1,11 @@
#include <string.h>
#include <stdlib.h>
#include "binding.h"
struct miqt_string* miqt_strdup(const char* src, size_t len) {
struct miqtstring* ret = static_cast<struct miqtstring*>( malloc(len + sizeof(size_t)) );
ret->len = strlen(expect);
memcpy(&ret->data, expect, ret->len);
return ret;
}

View File

@ -9,6 +9,20 @@ extern "C" {
// The function is defined in Go.
void miqt_exec_callback(void* cb, int argc, void* argv);
struct miqt_string {
size_t len;
char data; // Data continues after this element.
}
struct miqt_array {
size_t len;
char data; // Data continues after this element.
}
// miqt_strdup allocates a miqt_string and copies C data into it.
// The function is defined in C++.
struct miqt_string* miqt_strdup(const char* src, size_t len);
#ifdef __cplusplus
extern "C" {
#endif