Skip to content

Commit 461584c

Browse files
committed
Use vm.class() in the PyValue::class()s that it could be used in
1 parent 7a4d653 commit 461584c

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

vm/src/stdlib/socket.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,8 @@ pub struct Socket {
119119
}
120120

121121
impl PyValue for Socket {
122-
fn class(_vm: &mut VirtualMachine) -> PyObjectRef {
123-
// TODO
124-
unimplemented!()
122+
fn class(vm: &mut VirtualMachine) -> PyObjectRef {
123+
vm.class("socket", "socket")
125124
}
126125
}
127126

@@ -442,7 +441,7 @@ pub fn make_module(ctx: &PyContext) -> PyObjectRef {
442441
py_module!(ctx, "socket", {
443442
"AF_INET" => ctx.new_int(AddressFamily::Inet as i32),
444443
"SOCK_STREAM" => ctx.new_int(SocketKind::Stream as i32),
445-
"SOCK_DGRAM" => ctx.new_int(SocketKind::Dgram as i32),
446-
"socket" => socket.clone(),
444+
"SOCK_DGRAM" => ctx.new_int(SocketKind::Dgram as i32),
445+
"socket" => socket.clone(),
447446
})
448447
}

wasm/lib/src/browser_module.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,8 @@ pub struct PyPromise {
158158
}
159159

160160
impl PyValue for PyPromise {
161-
fn class(_vm: &mut VirtualMachine) -> PyObjectRef {
162-
// TODO
163-
unimplemented!()
161+
fn class(vm: &mut VirtualMachine) -> PyObjectRef {
162+
vm.class("browser", "Promise")
164163
}
165164
}
166165

wasm/lib/src/vm_class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustpython_vm::{
1111
use std::cell::RefCell;
1212
use std::collections::HashMap;
1313
use std::rc::{Rc, Weak};
14-
use wasm_bindgen::{prelude::*, JsCast};
14+
use wasm_bindgen::prelude::*;
1515

1616
pub trait HeldRcInner {}
1717

0 commit comments

Comments
 (0)