Skip to content

Commit f26a307

Browse files
committed
objfun: Add local header.
This follows pattern already used for objtuple, etc.: objfun.h's content is not public - each and every piece of code should not have access to it. It's not private either - with out architecture and implementation language (C) it doesn't make sense to keep implementation of each object strictly private and maintain cumbersome accessors. It's "local" - intended to be used by a small set of "friend" (in C++ terms) objects.
1 parent 71d3112 commit f26a307

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

py/objfun.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "qstr.h"
1010
#include "obj.h"
1111
#include "objtuple.h"
12+
#include "objfun.h"
1213
#include "runtime0.h"
1314
#include "runtime.h"
1415
#include "bc.h"
@@ -150,18 +151,6 @@ mp_obj_t mp_make_function_var_between(int n_args_min, int n_args_max, mp_fun_var
150151
/******************************************************************************/
151152
/* byte code functions */
152153

153-
typedef struct _mp_obj_fun_bc_t {
154-
mp_obj_base_t base;
155-
mp_obj_dict_t *globals; // the context within which this function was defined
156-
machine_uint_t n_args : 15; // number of arguments this function takes
157-
machine_uint_t n_def_args : 15; // number of default arguments
158-
machine_uint_t takes_var_args : 1; // set if this function takes variable args
159-
machine_uint_t takes_kw_args : 1; // set if this function takes keyword args
160-
const byte *bytecode; // bytecode for the function
161-
qstr *args; // argument names (needed to resolve positional args passed as keywords)
162-
mp_obj_t extra_args[]; // values of default args (if any), plus a slot at the end for var args and/or kw args (if it takes them)
163-
} mp_obj_fun_bc_t;
164-
165154
#if DEBUG_PRINT
166155
STATIC void dump_args(const mp_obj_t *a, int sz) {
167156
DEBUG_printf("%p: ", a);

py/objfun.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
typedef struct _mp_obj_fun_bc_t {
2+
mp_obj_base_t base;
3+
mp_obj_dict_t *globals; // the context within which this function was defined
4+
machine_uint_t n_args : 15; // number of arguments this function takes
5+
machine_uint_t n_def_args : 15; // number of default arguments
6+
machine_uint_t takes_var_args : 1; // set if this function takes variable args
7+
machine_uint_t takes_kw_args : 1; // set if this function takes keyword args
8+
const byte *bytecode; // bytecode for the function
9+
qstr *args; // argument names (needed to resolve positional args passed as keywords)
10+
// values of default args (if any), plus a slot at the end for var args and/or kw args (if it takes them)
11+
mp_obj_t extra_args[];
12+
} mp_obj_fun_bc_t;

0 commit comments

Comments
 (0)