mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Attempt to reduce the size of the pyobject.rs files by splitting out builtin types.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use crate::obj::objstr::PyStringRef;
|
||||
use crate::py_serde;
|
||||
use crate::pyobject::{create_type, ItemProtocol, PyObjectRef, PyResult};
|
||||
use crate::pyobject::{ItemProtocol, PyObjectRef, PyResult};
|
||||
use crate::types::create_type;
|
||||
use crate::VirtualMachine;
|
||||
use serde_json;
|
||||
|
||||
@@ -39,7 +40,7 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
|
||||
// TODO: Make this a proper type with a constructor
|
||||
let json_decode_error = create_type(
|
||||
"JSONDecodeError",
|
||||
&ctx.type_type,
|
||||
&ctx.types.type_type,
|
||||
&ctx.exceptions.exception_type,
|
||||
);
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ fn math_trunc(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
|
||||
fn math_ceil(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(vm, args, required = [(value, None)]);
|
||||
if objtype::isinstance(value, &vm.ctx.float_type) {
|
||||
if objtype::isinstance(value, &vm.ctx.float_type()) {
|
||||
let v = objfloat::get_value(value);
|
||||
Ok(vm.ctx.new_float(v.ceil()))
|
||||
} else {
|
||||
@@ -201,7 +201,7 @@ fn math_ceil(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
|
||||
fn math_floor(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
|
||||
arg_check!(vm, args, required = [(value, None)]);
|
||||
if objtype::isinstance(value, &vm.ctx.float_type) {
|
||||
if objtype::isinstance(value, &vm.ctx.float_type()) {
|
||||
let v = objfloat::get_value(value);
|
||||
Ok(vm.ctx.new_float(v.floor()))
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::function::OptionalArg;
|
||||
use crate::obj::{objbytes::PyBytesRef, objint::PyIntRef};
|
||||
use crate::pyobject::{create_type, ItemProtocol, PyObjectRef, PyResult};
|
||||
use crate::pyobject::{ItemProtocol, PyObjectRef, PyResult};
|
||||
use crate::types::create_type;
|
||||
use crate::vm::VirtualMachine;
|
||||
|
||||
use adler32::RollingAdler32 as Adler32;
|
||||
@@ -18,7 +19,11 @@ const DEF_BUF_SIZE: usize = 16 * 1024;
|
||||
pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
|
||||
let ctx = &vm.ctx;
|
||||
|
||||
let zlib_error = create_type("error", &ctx.type_type, &ctx.exceptions.exception_type);
|
||||
let zlib_error = create_type(
|
||||
"error",
|
||||
&ctx.types.type_type,
|
||||
&ctx.exceptions.exception_type,
|
||||
);
|
||||
|
||||
py_module!(vm, "zlib", {
|
||||
"crc32" => ctx.new_rustfunc(zlib_crc32),
|
||||
|
||||
Reference in New Issue
Block a user