diff --git a/3rd/box2d/src/box2d_Body.cpp b/3rd/box2d/src/box2d_Body.cpp index a6b9cb8a..782c1aee 100644 --- a/3rd/box2d/src/box2d_Body.cpp +++ b/3rd/box2d/src/box2d_Body.cpp @@ -20,27 +20,27 @@ void PyBody::_register(VM* vm, PyObject* mod, PyObject* type){ return obj; }); - PK_REGISTER_PROPERTY(PyBody, "type: int", _b2Body, GetType, SetType) - PK_REGISTER_PROPERTY(PyBody, "gravity_scale: float", _b2Body, GetGravityScale, SetGravityScale) - PK_REGISTER_PROPERTY(PyBody, "fixed_rotation: bool", _b2Body, IsFixedRotation, SetFixedRotation) - PK_REGISTER_PROPERTY(PyBody, "enabled: bool", _b2Body, IsEnabled, SetEnabled) - PK_REGISTER_PROPERTY(PyBody, "bullet: bool", _b2Body, IsBullet, SetBullet) + PY_PROPERTY(PyBody, "type: int", _b2Body, GetType, SetType) + PY_PROPERTY(PyBody, "gravity_scale: float", _b2Body, GetGravityScale, SetGravityScale) + PY_PROPERTY(PyBody, "fixed_rotation: bool", _b2Body, IsFixedRotation, SetFixedRotation) + PY_PROPERTY(PyBody, "enabled: bool", _b2Body, IsEnabled, SetEnabled) + PY_PROPERTY(PyBody, "bullet: bool", _b2Body, IsBullet, SetBullet) - PK_REGISTER_READONLY_PROPERTY(PyBody, "mass: float", _b2Body, GetMass) - PK_REGISTER_READONLY_PROPERTY(PyBody, "inertia: float", _b2Body, GetInertia) + PY_READONLY_PROPERTY(PyBody, "mass: float", _b2Body, GetMass) + PY_READONLY_PROPERTY(PyBody, "inertia: float", _b2Body, GetInertia) - PK_REGISTER_PROPERTY(PyBody, "position: vec2", _, get_position, set_position) - PK_REGISTER_PROPERTY(PyBody, "rotation: float", _, get_rotation, set_rotation) - PK_REGISTER_PROPERTY(PyBody, "velocity: vec2", _, get_velocity, set_velocity) - PK_REGISTER_PROPERTY(PyBody, "angular_velocity: float", _b2Body, GetAngularVelocity, SetAngularVelocity) - PK_REGISTER_PROPERTY(PyBody, "damping: float", _b2Body, GetLinearDamping, SetLinearDamping) - PK_REGISTER_PROPERTY(PyBody, "angular_damping: float", _b2Body, GetAngularDamping, SetAngularDamping) + PY_PROPERTY(PyBody, "position: vec2", _, get_position, set_position) + PY_PROPERTY(PyBody, "rotation: float", _, get_rotation, set_rotation) + PY_PROPERTY(PyBody, "velocity: vec2", _, get_velocity, set_velocity) + PY_PROPERTY(PyBody, "angular_velocity: float", _b2Body, GetAngularVelocity, SetAngularVelocity) + PY_PROPERTY(PyBody, "damping: float", _b2Body, GetLinearDamping, SetLinearDamping) + PY_PROPERTY(PyBody, "angular_damping: float", _b2Body, GetAngularDamping, SetAngularDamping) - PK_REGISTER_PROPERTY(PyBody, "density: float", _b2Fixture, GetDensity, SetDensity) - PK_REGISTER_PROPERTY(PyBody, "friction: float", _b2Fixture, GetFriction, SetFriction) - PK_REGISTER_PROPERTY(PyBody, "restitution: float", _b2Fixture, GetRestitution, SetRestitution) - PK_REGISTER_PROPERTY(PyBody, "restitution_threshold: float", _b2Fixture, GetRestitutionThreshold, SetRestitutionThreshold) - PK_REGISTER_PROPERTY(PyBody, "is_sensor: bool", _b2Fixture, IsSensor, SetSensor) + PY_PROPERTY(PyBody, "density: float", _b2Fixture, GetDensity, SetDensity) + PY_PROPERTY(PyBody, "friction: float", _b2Fixture, GetFriction, SetFriction) + PY_PROPERTY(PyBody, "restitution: float", _b2Fixture, GetRestitution, SetRestitution) + PY_PROPERTY(PyBody, "restitution_threshold: float", _b2Fixture, GetRestitutionThreshold, SetRestitutionThreshold) + PY_PROPERTY(PyBody, "is_sensor: bool", _b2Fixture, IsSensor, SetSensor) vm->bind(type, "set_box_shape(self, hx: float, hy: float)", [](VM* vm, ArgsView args){ diff --git a/include/pocketpy/bindings.h b/include/pocketpy/bindings.h index e357d7f5..1dd494f2 100644 --- a/include/pocketpy/bindings.h +++ b/include/pocketpy/bindings.h @@ -74,7 +74,7 @@ void _bind(VM* vm, PyObject* obj, const char* sig, Ret(T::*func)(Params...)){ vm->bind(obj, sig, proxy_wrapper, proxy); } /*****************************************************************/ -#define PK_REGISTER_FIELD(T, NAME, REF, EXPR) \ +#define PY_FIELD(T, NAME, REF, EXPR) \ vm->bind_property(type, NAME, \ [](VM* vm, ArgsView args){ \ T& self = _CAST(T&, args[0]); \ @@ -86,14 +86,14 @@ void _bind(VM* vm, PyObject* obj, const char* sig, Ret(T::*func)(Params...)){ return vm->None; \ }); -#define PK_REGISTER_READONLY_FIELD(T, NAME, REF, EXPR) \ +#define PY_READONLY_FIELD(T, NAME, REF, EXPR) \ vm->bind_property(type, NAME, \ [](VM* vm, ArgsView args){ \ T& self = _CAST(T&, args[0]); \ return VAR(self.REF().EXPR); \ }); -#define PK_REGISTER_PROPERTY(T, NAME, REF, FGET, FSET) \ +#define PY_PROPERTY(T, NAME, REF, FGET, FSET) \ vm->bind_property(type, NAME, \ [](VM* vm, ArgsView args){ \ T& self = _CAST(T&, args[0]); \ @@ -106,7 +106,7 @@ void _bind(VM* vm, PyObject* obj, const char* sig, Ret(T::*func)(Params...)){ return vm->None; \ }); -#define PK_REGISTER_READONLY_PROPERTY(T, NAME, REF, FGET) \ +#define PY_READONLY_PROPERTY(T, NAME, REF, FGET) \ vm->bind_property(type, NAME, \ [](VM* vm, ArgsView args){ \ T& self = _CAST(T&, args[0]); \ diff --git a/src/pocketpy.cpp b/src/pocketpy.cpp index 21f47947..c92cef1e 100644 --- a/src/pocketpy.cpp +++ b/src/pocketpy.cpp @@ -1445,15 +1445,15 @@ struct PyStructTime{ static void _register(VM* vm, PyObject* mod, PyObject* type){ vm->bind_notimplemented_constructor(type); - PK_REGISTER_READONLY_FIELD(PyStructTime, "tm_year", _, tm_year); - PK_REGISTER_READONLY_FIELD(PyStructTime, "tm_mon", _, tm_mon); - PK_REGISTER_READONLY_FIELD(PyStructTime, "tm_mday", _, tm_mday); - PK_REGISTER_READONLY_FIELD(PyStructTime, "tm_hour", _, tm_hour); - PK_REGISTER_READONLY_FIELD(PyStructTime, "tm_min", _, tm_min); - PK_REGISTER_READONLY_FIELD(PyStructTime, "tm_sec", _, tm_sec); - PK_REGISTER_READONLY_FIELD(PyStructTime, "tm_wday", _, tm_wday); - PK_REGISTER_READONLY_FIELD(PyStructTime, "tm_yday", _, tm_yday); - PK_REGISTER_READONLY_FIELD(PyStructTime, "tm_isdst", _, tm_isdst); + PY_READONLY_FIELD(PyStructTime, "tm_year", _, tm_year); + PY_READONLY_FIELD(PyStructTime, "tm_mon", _, tm_mon); + PY_READONLY_FIELD(PyStructTime, "tm_mday", _, tm_mday); + PY_READONLY_FIELD(PyStructTime, "tm_hour", _, tm_hour); + PY_READONLY_FIELD(PyStructTime, "tm_min", _, tm_min); + PY_READONLY_FIELD(PyStructTime, "tm_sec", _, tm_sec); + PY_READONLY_FIELD(PyStructTime, "tm_wday", _, tm_wday); + PY_READONLY_FIELD(PyStructTime, "tm_yday", _, tm_yday); + PY_READONLY_FIELD(PyStructTime, "tm_isdst", _, tm_isdst); } };