Skip to content

Commit 6676809

Browse files
committed
Draft methods for Context object
1 parent 4d2486e commit 6676809

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

stdlib/src/contextvars.rs

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ pub(crate) use _contextvars::make_module;
22

33
#[pymodule]
44
mod _contextvars {
5-
use rustpython_vm::builtins::{PyStrRef, PyTypeRef};
6-
use rustpython_vm::function::OptionalArg;
5+
use rustpython_vm::builtins::{PyFunction, PyStrRef, PyTypeRef};
6+
use rustpython_vm::function::{ArgCallable, FuncArgs, OptionalArg};
77
use rustpython_vm::{PyObjectRef, PyRef, PyResult, PyValue, VirtualMachine};
88

99
#[pyattr]
@@ -12,7 +12,66 @@ mod _contextvars {
1212
struct Context {}
1313

1414
#[pyimpl]
15-
impl Context {}
15+
impl Context {
16+
#[pymethod(magic)]
17+
fn init(&self, _vm: &VirtualMachine) -> PyResult<()> {
18+
unimplemented!("Context.__init__ is currently under construction")
19+
}
20+
21+
#[pymethod]
22+
fn run(
23+
&self,
24+
_callable: ArgCallable,
25+
_args: FuncArgs,
26+
_vm: &VirtualMachine,
27+
) -> PyResult<PyFunction> {
28+
unimplemented!("Context.run is currently under construction")
29+
}
30+
31+
#[pymethod]
32+
fn copy(&self, _vm: &VirtualMachine) -> PyResult<Context> {
33+
unimplemented!("Context.copy is currently under construction")
34+
}
35+
36+
#[pymethod(magic)]
37+
fn getitem(&self, _var: PyObjectRef) -> PyResult<PyObjectRef> {
38+
unimplemented!("Context.__getitem__ is currently under construction")
39+
}
40+
41+
#[pymethod(magic)]
42+
fn contains(&self, _var: PyObjectRef) -> PyResult<bool> {
43+
unimplemented!("Context.__contains__ is currently under construction")
44+
}
45+
46+
#[pymethod(magic)]
47+
fn len(&self) -> usize {
48+
unimplemented!("Context.__len__ is currently under construction")
49+
}
50+
51+
#[pymethod(magic)]
52+
fn iter(&self) -> PyResult {
53+
unimplemented!("Context.__iter__ is currently under construction")
54+
}
55+
56+
#[pymethod]
57+
fn get(
58+
&self,
59+
_key: PyObjectRef,
60+
_default: OptionalArg<PyObjectRef>,
61+
) -> PyResult<PyObjectRef> {
62+
unimplemented!("Context.get is currently under construction")
63+
}
64+
65+
#[pymethod]
66+
fn keys(_zelf: PyRef<Self>, _vm: &VirtualMachine) -> Vec<PyObjectRef> {
67+
unimplemented!("Context.keys is currently under construction")
68+
}
69+
70+
#[pymethod]
71+
fn values(_zelf: PyRef<Self>, _vm: &VirtualMachine) -> Vec<PyObjectRef> {
72+
unimplemented!("Context.values is currently under construction")
73+
}
74+
}
1675

1776
#[pyattr]
1877
#[pyclass(name)]

0 commit comments

Comments
 (0)