Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
45b43c21
Commit
45b43c21
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
Oops: add objint.c
parent
8b2688f8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/objint.c
+48
-0
48 additions, 0 deletions
py/objint.c
with
48 additions
and
0 deletions
py/objint.c
0 → 100644
+
48
−
0
View file @
45b43c21
#include
<stdlib.h>
#include
<stdint.h>
#include
<string.h>
#include
<assert.h>
#include
"nlr.h"
#include
"misc.h"
#include
"mpconfig.h"
#include
"mpqstr.h"
#include
"obj.h"
typedef
struct
_mp_obj_int_t
{
mp_obj_base_t
base
;
}
mp_obj_int_t
;
static
mp_obj_t
int_make_new
(
mp_obj_t
type_in
,
int
n_args
,
const
mp_obj_t
*
args
)
{
switch
(
n_args
)
{
case
0
:
return
MP_OBJ_NEW_SMALL_INT
(
0
);
case
1
:
// TODO allow string as arg and parse it
return
MP_OBJ_NEW_SMALL_INT
(
mp_obj_get_int
(
args
[
0
]));
//case 2:
// TODO, parse with given base
default:
nlr_jump
(
mp_obj_new_exception_msg_1_arg
(
MP_QSTR_TypeError
,
"int takes at most 2 arguments, %d given"
,
(
void
*
)(
machine_int_t
)
n_args
));
}
}
const
mp_obj_type_t
int_type
=
{
{
&
mp_const_type
},
"int"
,
NULL
,
int_make_new
,
// make_new
NULL
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
{
{
NULL
,
NULL
},
},
// method list
};
mp_obj_t
mp_obj_new_int
(
machine_int_t
value
)
{
return
MP_OBJ_NEW_SMALL_INT
(
value
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment