This commit is contained in:
blueloveTH 2024-03-02 04:22:53 +08:00
parent b99540854e
commit e82cad5b25
5 changed files with 7 additions and 14 deletions

View File

@ -46,14 +46,6 @@ struct VoidP{
static void _register(VM* vm, PyObject* mod, PyObject* type);
};
inline PyObject* py_var(VM* vm, void* p){
return VAR_T(VoidP, p);
}
inline PyObject* py_var(VM* vm, const void* p){
return VAR_T(VoidP, p);
}
#define POINTER_VAR(Tp, NAME) \
inline PyObject* py_var(VM* vm, Tp val){ \
const static std::pair<StrName, StrName> P("c", NAME); \

View File

@ -133,12 +133,6 @@ struct Mat3x3{
Vec2 _s() const;
};
inline PyObject* py_var(VM* vm, Vec2 obj){ return VAR_T(Vec2, obj); }
inline PyObject* py_var(VM* vm, Vec3 obj){ return VAR_T(Vec3, obj); }
inline PyObject* py_var(VM* vm, Vec4 obj){ return VAR_T(Vec4, obj); }
inline PyObject* py_var(VM* vm, const Mat3x3& obj){ return VAR_T(Mat3x3, obj); }
void add_module_linalg(VM* vm);
static_assert(sizeof(Py_<Mat3x3>) <= 64);

View File

@ -210,6 +210,7 @@ inline void gc_mark_namedict(NameDict& t){
StrName _type_name(VM* vm, Type type);
template<typename T> T to_void_p(VM*, PyObject*);
PyObject* from_void_p(VM*, void*);
#define VAR(x) py_var(vm, x)
#define CAST(T, x) py_cast<T>(vm, x)

View File

@ -504,6 +504,8 @@ PyObject* py_var(VM* vm, __T&& value){
}else if constexpr(is_floating_point_v<T>){
// float
return tag_float(static_cast<f64>(std::forward<__T>(value)));
}else if constexpr(std::is_pointer_v<T>){
return from_void_p(vm, (void*)value);
}else{
constexpr Type const_type = _find_type_in_const_cxx_typeid_map<T>();
if constexpr(const_type.index >= 0){

View File

@ -271,4 +271,8 @@ void add_module_c(VM* vm){
});
}
PyObject* from_void_p(VM* vm, void* p){
return VAR_T(VoidP, p);
}
} // namespace pkpy