mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
use enum for magic names
This commit is contained in:
parent
cf82c409df
commit
2d9a06a3fc
@ -326,9 +326,13 @@ bool py_checktype(const py_Ref self, py_Type type);
|
|||||||
/// %t: py_Type
|
/// %t: py_Type
|
||||||
/// %n: py_Name
|
/// %n: py_Name
|
||||||
|
|
||||||
#define MAGIC_METHOD(x) extern uint16_t x;
|
|
||||||
|
enum py_MagicMethods{
|
||||||
|
py_MagicMethods__NULL, // 0 is reserved
|
||||||
|
#define MAGIC_METHOD(x) x,
|
||||||
#include "pocketpy/xmacros/magics.h"
|
#include "pocketpy/xmacros/magics.h"
|
||||||
#undef MAGIC_METHOD
|
#undef MAGIC_METHOD
|
||||||
|
};
|
||||||
|
|
||||||
enum py_PredefinedTypes{
|
enum py_PredefinedTypes{
|
||||||
tp_object = 1, tp_type,
|
tp_object = 1, tp_type,
|
||||||
|
@ -20,7 +20,7 @@ void pk_StrName__initialize() {
|
|||||||
c11_vector__ctor(&_r_interned, sizeof(c11_sv));
|
c11_vector__ctor(&_r_interned, sizeof(c11_sv));
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
|
|
||||||
#define MAGIC_METHOD(x) x = pk_StrName__map(#x);
|
#define MAGIC_METHOD(x) assert(x == py_name(#x));
|
||||||
#include "pocketpy/xmacros/magics.h"
|
#include "pocketpy/xmacros/magics.h"
|
||||||
#undef MAGIC_METHOD
|
#undef MAGIC_METHOD
|
||||||
|
|
||||||
@ -94,10 +94,6 @@ bool py_ismagicname(py_Name name){
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
#define MAGIC_METHOD(x) uint16_t x;
|
|
||||||
#include "pocketpy/xmacros/magics.h"
|
|
||||||
#undef MAGIC_METHOD
|
|
||||||
|
|
||||||
uint16_t pk_id_add;
|
uint16_t pk_id_add;
|
||||||
uint16_t pk_id_set;
|
uint16_t pk_id_set;
|
||||||
uint16_t pk_id_long;
|
uint16_t pk_id_long;
|
||||||
|
@ -849,7 +849,7 @@ static void BinaryExpr__dtor(Expr* self_) {
|
|||||||
vtdelete(self->rhs);
|
vtdelete(self->rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Opcode cmp_token2name(TokenIndex token) {
|
static py_Name cmp_token2name(TokenIndex token) {
|
||||||
switch(token) {
|
switch(token) {
|
||||||
case TK_LT: return __lt__;
|
case TK_LT: return __lt__;
|
||||||
case TK_LE: return __le__;
|
case TK_LE: return __le__;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user