Skip to content

Commit

Permalink
Add h_BoolType and h_FloatType
Browse files Browse the repository at this point in the history
  • Loading branch information
fangerer committed Oct 15, 2021
1 parent eb3a322 commit 6d61a4f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions hpy/debug/src/autogen_debug_ctx_init.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions hpy/devel/include/hpy/cpython/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ struct _HPyContext_s {
/* Types */
HPy h_BaseObjectType;
HPy h_TypeType;
HPy h_BoolType;
HPy h_LongType;
HPy h_FloatType;
HPy h_UnicodeType;
HPy h_TupleType;
HPy h_ListType;
Expand Down Expand Up @@ -183,7 +185,9 @@ HPyAPI_FUNC HPyContext * _HPyGetContext(void) {
/* Types */
ctx->h_BaseObjectType = _py2h((PyObject *)&PyBaseObject_Type);
ctx->h_TypeType = _py2h((PyObject *)&PyType_Type);
ctx->h_BoolType = _py2h((PyObject *)&PyBool_Type);
ctx->h_LongType = _py2h((PyObject *)&PyLong_Type);
ctx->h_FloatType = _py2h((PyObject *)&PyFloat_Type);
ctx->h_UnicodeType = _py2h((PyObject *)&PyUnicode_Type);
ctx->h_TupleType = _py2h((PyObject *)&PyTuple_Type);
ctx->h_ListType = _py2h((PyObject *)&PyList_Type);
Expand Down
2 changes: 2 additions & 0 deletions hpy/devel/include/hpy/universal/autogen_ctx.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions hpy/tools/autogen/public_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ HPy h_ResourceWarning;
/* Types */
HPy h_BaseObjectType; /* built-in 'object' */
HPy h_TypeType; /* built-in 'type' */
HPy h_BoolType; /* built-in 'bool' */
HPy h_LongType; /* built-in 'int' */
HPy h_FloatType; /* built-in 'float' */
HPy h_UnicodeType; /* built-in 'str' */
HPy h_TupleType; /* built-in 'tuple' */
HPy h_ListType; /* built-in 'list' */
Expand Down
2 changes: 2 additions & 0 deletions hpy/universal/src/hpymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ static void init_universal_ctx(HPyContext *ctx)
/* Types */
ctx->h_BaseObjectType = _py2h((PyObject *)&PyBaseObject_Type);
ctx->h_TypeType = _py2h((PyObject *)&PyType_Type);
ctx->h_BoolType = _py2h((PyObject *)&PyBool_Type);
ctx->h_LongType = _py2h((PyObject *)&PyLong_Type);
ctx->h_FloatType = _py2h((PyObject *)&PyFloat_Type);
ctx->h_UnicodeType = _py2h((PyObject *)&PyUnicode_Type);
ctx->h_TupleType = _py2h((PyObject *)&PyTuple_Type);
ctx->h_ListType = _py2h((PyObject *)&PyList_Type);
Expand Down
16 changes: 9 additions & 7 deletions test/test_00_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,14 @@ def test_builtin_handles(self):
case 7: h = ctx->h_SystemError; break;
case 8: h = ctx->h_BaseObjectType; break;
case 9: h = ctx->h_TypeType; break;
case 10: h = ctx->h_LongType; break;
case 11: h = ctx->h_UnicodeType; break;
case 12: h = ctx->h_TupleType; break;
case 13: h = ctx->h_ListType; break;
case 14: h = ctx->h_NotImplemented; break;
case 15: h = ctx->h_Ellipsis; break;
case 10: h = ctx->h_BoolType; break;
case 11: h = ctx->h_LongType; break;
case 12: h = ctx->h_FloatType; break;
case 13: h = ctx->h_UnicodeType; break;
case 14: h = ctx->h_TupleType; break;
case 15: h = ctx->h_ListType; break;
case 16: h = ctx->h_NotImplemented; break;
case 17: h = ctx->h_Ellipsis; break;
default:
HPyErr_SetString(ctx, ctx->h_ValueError, "invalid choice");
return HPy_NULL;
Expand All @@ -213,7 +215,7 @@ def test_builtin_handles(self):
""")
builtin_objs = (
'<NULL>', None, False, True, ValueError, TypeError, IndexError,
SystemError, object, type, int, str, tuple, list, NotImplemented, Ellipsis,
SystemError, object, type, bool, int, float, str, tuple, list, NotImplemented, Ellipsis,
)
for i, obj in enumerate(builtin_objs):
if i == 0:
Expand Down

0 comments on commit 6d61a4f

Please sign in to comment.