blueloveTH 1 년 전
부모
커밋
16f1d3fcfb
2개의 변경된 파일15개의 추가작업 그리고 15개의 파일을 삭제
  1. 8 8
      include/pocketpy/pocketpy.h
  2. 7 7
      src/public/cast.c

+ 8 - 8
include/pocketpy/pocketpy.h

@@ -72,14 +72,14 @@ void py_pushnull();
 void py_push_notimplemented();
 void py_push_notimplemented();
 
 
 /************* Type Cast *************/
 /************* Type Cast *************/
-int64_t py_toint(py_Ref);
-double py_tofloat(py_Ref);
-bool py_castfloat(py_Ref, double* out);
-bool py_tobool(py_Ref);
-const char* py_tostr(py_Ref);
-const char* py_tostrn(py_Ref, int* out);
-
-void* py_touserdata(py_Ref);
+int64_t py_toint(const py_Ref);
+double py_tofloat(const py_Ref);
+bool py_castfloat(const py_Ref, double* out);
+bool py_tobool(const py_Ref);
+const char* py_tostr(const py_Ref);
+const char* py_tostrn(const py_Ref, int* out);
+
+void* py_touserdata(const py_Ref);
 
 
 #define py_isint(self) py_istype(self, tp_int)
 #define py_isint(self) py_istype(self, tp_int)
 #define py_isfloat(self) py_istype(self, tp_float)
 #define py_isfloat(self) py_istype(self, tp_float)

+ 7 - 7
src/public/cast.c

@@ -4,15 +4,15 @@
 #include "pocketpy/objects/object.h"
 #include "pocketpy/objects/object.h"
 #include "pocketpy/interpreter/vm.h"
 #include "pocketpy/interpreter/vm.h"
 
 
-int64_t py_toint(py_Ref self){
+int64_t py_toint(const py_Ref self){
     return self->_i64;
     return self->_i64;
 }
 }
 
 
-double py_tofloat(py_Ref self){
+double py_tofloat(const py_Ref self){
     return self->_f64;
     return self->_f64;
 }
 }
 
 
-bool py_castfloat(py_Ref self, double* out){
+bool py_castfloat(const py_Ref self, double* out){
     switch(self->type){
     switch(self->type){
         case tp_int:
         case tp_int:
             *out = (double)self->_i64;
             *out = (double)self->_i64;
@@ -28,22 +28,22 @@ bool py_castfloat(py_Ref self, double* out){
     }
     }
 }
 }
 
 
-bool py_tobool(py_Ref self){
+bool py_tobool(const py_Ref self){
     return self->extra;
     return self->extra;
 }
 }
 
 
-const char* py_tostr(py_Ref self){
+const char* py_tostr(const py_Ref self){
     py_Str* ud = PyObject__value(self->_obj);
     py_Str* ud = PyObject__value(self->_obj);
     return py_Str__data(ud);
     return py_Str__data(ud);
 }
 }
 
 
-const char* py_tostrn(py_Ref self, int* out){
+const char* py_tostrn(const py_Ref self, int* out){
     py_Str* ud = PyObject__value(self->_obj);
     py_Str* ud = PyObject__value(self->_obj);
     *out = ud->size;
     *out = ud->size;
     return py_Str__data(ud);
     return py_Str__data(ud);
 }
 }
 
 
-void* py_touserdata(py_Ref self){
+void* py_touserdata(const py_Ref self){
     assert(self && self->is_ptr);
     assert(self && self->is_ptr);
     return PyObject__value(self->_obj);
     return PyObject__value(self->_obj);
 }
 }