blueloveTH 1 год назад
Родитель
Сommit
13b1fbe17a
3 измененных файлов с 3 добавлено и 34 удалено
  1. 1 27
      include/pocketpy/objects/base.h
  2. 2 0
      src/objects/dict.c
  3. 0 7
      src/objects/object.c

+ 1 - 27
include/pocketpy/objects/base.h

@@ -28,15 +28,7 @@ typedef struct PyVar{
     };
 } PyVar;
 
-
-#define PyVar__as(T, self)  _Generic((T), \
-    int64_t: self->_i64, \
-    double: self->_f64, \
-    PyObject*: self->_obj, \
-    void*: self->_ptr, \
-)
-
-static_assert(sizeof(PyVar) == 16, "sizeof(PyVar) != 16");
+static_assert(sizeof(PyVar) <= 16, "!sizeof(PyVar) <= 16");
 
 /* predefined vars */
 static const py_Type tp_object = {1}, tp_type = {2};
@@ -52,24 +44,6 @@ static const py_Type tp_ellipsis = {26};
 static const py_Type tp_op_call = {27}, tp_op_yield = {28};
 static const py_Type tp_syntax_error = {29}, tp_stop_iteration = {30};
 
-PK_INLINE bool PyVar__is_null(const PyVar* self) { return self->type == 0; }
-PK_INLINE int64_t PyVar__hash(const PyVar* self) { return self->extra + self->_i64; }
-
-PK_INLINE void PyVar__ctor(PyVar* self, py_Type type, PyObject* obj){
-    self->type = type;
-    self->is_ptr = true;
-    self->_obj = obj;
-}
-
-void PyVar__ctor3(PyVar* self, PyObject* existing);
-
-PK_INLINE bool PyVar__IS_OP(const PyVar* a, const PyVar* b){
-    return a->is_ptr && b->is_ptr && a->_obj == b->_obj;
-}
-
-#define pkpy_Var__is_null(self) ((self)->type == 0)
-#define pkpy_Var__set_null(self) do { (self)->type = 0; } while(0)
-
 extern PyVar PY_NULL, PY_OP_CALL, PY_OP_YIELD;
 
 #ifdef __cplusplus

+ 2 - 0
src/objects/dict.c

@@ -9,6 +9,8 @@
 #define DICT_HASH_NEXT(h) ((h) * 5 + 1)
 #define DICT_HASH_TRANS(h) ((int)((h) & 0xffffffff)) // used for tansform value from __hash__
 #define PK_DICT_COMPACT_MODE 1
+#define pkpy_Var__is_null(self) ((self)->type == 0)
+#define pkpy_Var__set_null(self) do { (self)->type = 0; } while(0)
 
 struct pkpy_DictEntry {
     PyVar key;

+ 0 - 7
src/objects/object.c

@@ -2,13 +2,6 @@
 #include "pocketpy/pocketpy.h"
 #include <assert.h>
 
-void PyVar__ctor3(PyVar* self, PyObject* existing){
-    assert(existing);
-    self->type = existing->type;
-    self->is_ptr = true;
-    self->_obj = existing;
-}
-
 void* PyObject__value(PyObject* self){
     return (char*)self + PK_OBJ_HEADER_SIZE(self->slots);
 }