mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
some fix
This commit is contained in:
parent
96d0c432c7
commit
69183e2d79
@ -1,33 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct c11_userdata{
|
|
||||||
void* _0;
|
|
||||||
void* _1;
|
|
||||||
} c11_userdata;
|
|
||||||
|
|
||||||
void c11_userdata__ctor(c11_userdata* self, void* ptr, int size);
|
|
||||||
#define c11_userdata__as(T, self) (*( (T*)(self) ))
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace pkpy{
|
|
||||||
struct any: c11_userdata{
|
|
||||||
template<typename T>
|
|
||||||
any(T value){
|
|
||||||
c11_userdata__ctor(this, &value, sizeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
any(){ }
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T as(){
|
|
||||||
return c11_userdata__as(T, this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace pkpy
|
|
||||||
#endif
|
|
@ -40,6 +40,20 @@ extern const char* kPlatformStrings[];
|
|||||||
#define PK_NARGS(...) PK_NARGS_SEQ(__VA_ARGS__, 4, 3, 2, 1, 0)
|
#define PK_NARGS(...) PK_NARGS_SEQ(__VA_ARGS__, 4, 3, 2, 1, 0)
|
||||||
#define PK_NPTRS(...) PK_NARGS_SEQ(__VA_ARGS__, int****, int***, int**, int*, int)
|
#define PK_NPTRS(...) PK_NARGS_SEQ(__VA_ARGS__, int****, int***, int**, int*, int)
|
||||||
|
|
||||||
|
// ref counting
|
||||||
|
typedef struct RefCounted {
|
||||||
|
int count;
|
||||||
|
void (*dtor)(void*);
|
||||||
|
} RefCounted;
|
||||||
|
|
||||||
|
#define PK_INCREF(obj) (obj)->rc.count++
|
||||||
|
#define PK_DECREF(obj) do { \
|
||||||
|
if(--(obj)->rc.count == 0) { \
|
||||||
|
(obj)->rc.dtor(obj); \
|
||||||
|
free(obj); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -7,7 +7,6 @@
|
|||||||
#include "pocketpy/common/smallmap.h"
|
#include "pocketpy/common/smallmap.h"
|
||||||
#include "pocketpy/objects/base.h"
|
#include "pocketpy/objects/base.h"
|
||||||
#include "pocketpy/objects/sourcedata.h"
|
#include "pocketpy/objects/sourcedata.h"
|
||||||
#include "pocketpy/common/refcount.h"
|
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "pocketpy/common/str.h"
|
#include "pocketpy/common/str.h"
|
||||||
#include "pocketpy/common/vector.h"
|
#include "pocketpy/common/vector.h"
|
||||||
#include "pocketpy/common/refcount.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
#include "pocketpy/common/any.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void c11_userdata__ctor(c11_userdata* self, void* ptr, int size){
|
|
||||||
memcpy(self, ptr, size);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user