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
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
fc710169
Commit
fc710169
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/obj: Clean up and add comments describing mp_obj_type_t struct.
parent
81d302b8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/obj.h
+32
-23
32 additions, 23 deletions
py/obj.h
with
32 additions
and
23 deletions
py/obj.h
+
32
−
23
View file @
fc710169
...
...
@@ -470,16 +470,27 @@ typedef struct _mp_stream_p_t {
}
mp_stream_p_t
;
struct
_mp_obj_type_t
{
// A type is an object so must start with this entry, which points to mp_type_type.
mp_obj_base_t
base
;
// The name of this type.
qstr
name
;
// Corresponds to __repr__ and __str__ special methods.
mp_print_fun_t
print
;
mp_make_new_fun_t
make_new
;
// to make an instance of the type
// Corresponds to __new__ and __init__ special methods, to make an instance of the type.
mp_make_new_fun_t
make_new
;
// Corresponds to __call__ special method, ie T(...).
mp_call_fun_t
call
;
mp_unary_op_fun_t
unary_op
;
// can return MP_OBJ_NULL if op not supported
mp_binary_op_fun_t
binary_op
;
// can return MP_OBJ_NULL if op not supported
// implements load, store and delete attribute
// Implements unary and binary operations.
// Can return MP_OBJ_NULL if the operation is not supported.
mp_unary_op_fun_t
unary_op
;
mp_binary_op_fun_t
binary_op
;
// Implements load, store and delete attribute.
//
// dest[0] = MP_OBJ_NULL means load
// return: for fail, do nothing
...
...
@@ -492,35 +503,33 @@ struct _mp_obj_type_t {
// for success set dest[0] = MP_OBJ_NULL
mp_attr_fun_t
attr
;
mp_subscr_fun_t
subscr
;
// implements load, store, delete subscripting
// value=MP_OBJ_NULL means delete, value=MP_OBJ_SENTINEL means load, else store
// can return MP_OBJ_NULL if op not supported
// Implements load, store and delete subscripting:
// - value = MP_OBJ_SENTINEL means load
// - value = MP_OBJ_NULL means delete
// - all other values mean store the value
// Can return MP_OBJ_NULL if operation not supported.
mp_subscr_fun_t
subscr
;
//
c
orresponds to __iter__ special method
//
c
an use given mp_obj_iter_buf_t to store iterator
// otherwise can return a pointer to an object on the heap
//
C
orresponds to __iter__ special method
.
//
C
an use
the
given mp_obj_iter_buf_t to store iterator
object,
// otherwise can return a pointer to an object on the heap
.
mp_getiter_fun_t
getiter
;
mp_fun_1_t
iternext
;
// may return MP_OBJ_STOP_ITERATION as an optimisation instead of raising StopIteration() (with no args)
// Corresponds to __next__ special method. May return MP_OBJ_STOP_ITERATION
// as an optimisation instead of raising StopIteration() with no args.
mp_fun_1_t
iternext
;
// Implements the buffer protocol if supported by this type.
mp_buffer_p_t
buffer_p
;
// One of disjoint protocols (interfaces), like mp_stream_p_t, etc.
const
void
*
protocol
;
//
these are for dynamically created types (classes)
//
A tuple containing all the base types of this type.
struct
_mp_obj_tuple_t
*
bases_tuple
;
struct
_mp_obj_dict_t
*
locals_dict
;
/*
What we might need to add here:
len str tuple list map
abs float complex
hash bool int none str
equal int str
unpack seq list tuple
*/
// A dict mapping qstrs to objects local methods/constants/etc.
struct
_mp_obj_dict_t
*
locals_dict
;
};
// Constant types, globally accessible
...
...
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