Lines Matching refs:ctx

55 token_new(PyContext *ctx, PyContextVar *var, PyObject *val);
95 PyContext *ctx = (PyContext *)octx;
96 return (PyObject *)context_new_from_vars(ctx->ctx_vars);
103 PyContext *ctx = context_get();
104 if (ctx == NULL) {
108 return (PyObject *)context_new_from_vars(ctx->ctx_vars);
116 PyContext *ctx = (PyContext *)octx;
118 if (ctx->ctx_entered) {
120 "cannot enter context: %R is already entered", ctx);
124 ctx->ctx_prev = (PyContext *)ts->context; /* borrow */
125 ctx->ctx_entered = 1;
127 Py_INCREF(ctx);
128 ts->context = (PyObject *)ctx;
148 PyContext *ctx = (PyContext *)octx;
150 if (!ctx->ctx_entered) {
152 "cannot exit context: %R has not been entered", ctx);
156 if (ts->context != (PyObject *)ctx) {
164 Py_SETREF(ts->context, (PyObject *)ctx->ctx_prev);
167 ctx->ctx_prev = NULL;
168 ctx->ctx_entered = 0;
270 PyContext *ctx = context_get();
271 if (ctx == NULL) {
276 int found = _PyHamt_Find(ctx->ctx_vars, (PyObject *)var, &old_val);
282 PyContextToken *tok = token_new(ctx, var, old_val);
314 PyContext *ctx = context_get();
315 if (ctx != tok->tok_ctx) {
343 PyContext *ctx;
352 ctx = state->freelist;
353 state->freelist = (PyContext *)ctx->ctx_weakreflist;
355 ctx->ctx_weakreflist = NULL;
356 _Py_NewReference((PyObject *)ctx);
361 ctx = PyObject_GC_New(PyContext, &PyContext_Type);
362 if (ctx == NULL) {
367 ctx->ctx_vars = NULL;
368 ctx->ctx_prev = NULL;
369 ctx->ctx_entered = 0;
370 ctx->ctx_weakreflist = NULL;
372 return ctx;
379 PyContext *ctx = _context_alloc();
380 if (ctx == NULL) {
384 ctx->ctx_vars = _PyHamt_New();
385 if (ctx->ctx_vars == NULL) {
386 Py_DECREF(ctx);
390 _PyObject_GC_TRACK(ctx);
391 return ctx;
398 PyContext *ctx = _context_alloc();
399 if (ctx == NULL) {
404 ctx->ctx_vars = vars;
406 _PyObject_GC_TRACK(ctx);
407 return ctx;
741 PyContext *ctx = context_get();
742 if (ctx == NULL) {
747 ctx->ctx_vars, (PyObject *)var, val);
752 Py_SETREF(ctx->ctx_vars, new_vars);
765 PyContext *ctx = context_get();
766 if (ctx == NULL) {
770 PyHamtObject *vars = ctx->ctx_vars;
782 Py_SETREF(ctx->ctx_vars, new_vars);
1224 token_new(PyContext *ctx, PyContextVar *var, PyObject *val)
1231 Py_INCREF(ctx);
1232 tok->tok_ctx = ctx;
1303 PyContext *ctx = state->freelist;
1304 state->freelist = (PyContext *)ctx->ctx_weakreflist;
1305 ctx->ctx_weakreflist = NULL;
1306 PyObject_GC_Del(ctx);