mirror of
				https://github.com/pocketpy/pocketpy
				synced 2025-10-31 08:50:17 +00:00 
			
		
		
		
	Compare commits
	
		
			No commits in common. "9162e84ae60937d3dbace2cadbda6021036ba3e8" and "b7950d4a1151ca7b4fa4960d48b477552cc301ad" have entirely different histories.
		
	
	
		
			9162e84ae6
			...
			b7950d4a11
		
	
		
| @ -39,6 +39,8 @@ typedef py_TValue* py_TmpRef; | |||||||
| /// @return true if the function is successful.
 | /// @return true if the function is successful.
 | ||||||
| typedef bool (*py_CFunction)(int argc, py_StackRef argv) PY_RAISE; | typedef bool (*py_CFunction)(int argc, py_StackRef argv) PY_RAISE; | ||||||
| 
 | 
 | ||||||
|  | enum py_BindType { bt_function, bt_staticmethod, bt_classmethod }; | ||||||
|  | 
 | ||||||
| enum py_CompileMode { EXEC_MODE, EVAL_MODE, REPL_MODE, CELL_MODE }; | enum py_CompileMode { EXEC_MODE, EVAL_MODE, REPL_MODE, CELL_MODE }; | ||||||
| 
 | 
 | ||||||
| extern py_GlobalRef py_True; | extern py_GlobalRef py_True; | ||||||
| @ -90,6 +92,7 @@ void py_newnativefunc(py_Ref out, py_CFunction); | |||||||
| py_Name py_newfunction(py_Ref out, | py_Name py_newfunction(py_Ref out, | ||||||
|                     const char* sig, |                     const char* sig, | ||||||
|                     py_CFunction f, |                     py_CFunction f, | ||||||
|  |                     enum py_BindType bt, | ||||||
|                     const char* docstring, |                     const char* docstring, | ||||||
|                     int slots); |                     int slots); | ||||||
| 
 | 
 | ||||||
| @ -154,7 +157,7 @@ py_GlobalRef py_tpobject(py_Type type); | |||||||
| /// Get the type name.
 | /// Get the type name.
 | ||||||
| const char* py_tpname(py_Type type); | const char* py_tpname(py_Type type); | ||||||
| /// Call a type to create a new instance.
 | /// Call a type to create a new instance.
 | ||||||
| bool py_tpcall(py_Type type, int argc, py_Ref argv) PY_RAISE; | bool py_tpcall(py_Type type, int argc, py_Ref argv); | ||||||
| /// Find the magic method from the given type only.
 | /// Find the magic method from the given type only.
 | ||||||
| py_GlobalRef py_tpmagic(py_Type type, py_Name name); | py_GlobalRef py_tpmagic(py_Type type, py_Name name); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -62,13 +62,14 @@ void py_bindfunc(py_Ref obj, const char* name, py_CFunction f) { | |||||||
| 
 | 
 | ||||||
| void py_bind(py_Ref obj, const char* sig, py_CFunction f) { | void py_bind(py_Ref obj, const char* sig, py_CFunction f) { | ||||||
|     py_TValue tmp; |     py_TValue tmp; | ||||||
|     py_Name name = py_newfunction(&tmp, sig, f, NULL, 0); |     py_Name name = py_newfunction(&tmp, sig, f, bt_function, NULL, 0); | ||||||
|     py_setdict(obj, name, &tmp); |     py_setdict(obj, name, &tmp); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| py_Name py_newfunction(py_Ref out, | py_Name py_newfunction(py_Ref out, | ||||||
|                        const char* sig, |                        const char* sig, | ||||||
|                        py_CFunction f, |                        py_CFunction f, | ||||||
|  |                        enum py_BindType bt, | ||||||
|                        const char* docstring, |                        const char* docstring, | ||||||
|                        int slots) { |                        int slots) { | ||||||
|     char buffer[256]; |     char buffer[256]; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user