forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjellipsis.rs
More file actions
22 lines (19 loc) · 716 Bytes
/
objellipsis.rs
File metadata and controls
22 lines (19 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::pyobject::{PyContext, PyFuncArgs, PyResult, TypeProtocol};
use crate::vm::VirtualMachine;
pub fn init(context: &PyContext) {
let ellipsis_type = &context.ellipsis_type;
context.set_attr(ellipsis_type, "__new__", context.new_rustfunc(ellipsis_new));
context.set_attr(
ellipsis_type,
"__repr__",
context.new_rustfunc(ellipsis_repr),
);
}
fn ellipsis_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(vm, args, required = [(_cls, None)]);
Ok(vm.ctx.ellipsis())
}
fn ellipsis_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(vm, args, required = [(_cls, None)]);
Ok(vm.new_str("Ellipsis".to_string()))
}