Skip to content

Commit 31b46c9

Browse files
committed
Make marshal a multi-file module.
1 parent f3b6c0a commit 31b46c9

File tree

3 files changed

+56
-52
lines changed

3 files changed

+56
-52
lines changed

src/marshal/common.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
#[derive(PartialEq)]
3+
#[derive(Debug)]
4+
pub struct Code {
5+
pub argcount: u32,
6+
pub kwonlyargcount: u32,
7+
pub nlocals: u32,
8+
pub stacksize: u32,
9+
pub flags: u32,
10+
pub code: Object,
11+
pub consts: Object,
12+
pub names: Object,
13+
pub varnames: Object,
14+
pub freevars: Object,
15+
pub cellvars: Object,
16+
pub filename: Object,
17+
pub name: Object,
18+
pub firstlineno: u32,
19+
pub lnotab: Object,
20+
}
21+
22+
#[derive(PartialEq)]
23+
#[derive(Debug)]
24+
pub enum Object {
25+
Hole, // Temporary object for unmarshalling
26+
//Null,
27+
None,
28+
False,
29+
True,
30+
//StopIter,
31+
//Ellipsis,
32+
Int(u32),
33+
//Float,
34+
//BinaryFloat,
35+
//Complex,
36+
//BinaryComplex,
37+
String(::std::string::String),
38+
//Interned,
39+
//Ref_,
40+
Tuple(Vec<Object>),
41+
List(Vec<Object>),
42+
//Dict,
43+
Code(Box<Code>),
44+
//Unknown,
45+
Set(Vec<Object>),
46+
FrozenSet(Vec<Object>),
47+
Ref(u32),
48+
49+
Bytes(Vec<u8>), // aka. ASCII in CPython's marshal
50+
//ShortAscii,
51+
//ShortAsciiInterned
52+
}

src/marshal/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod common;
2+
pub mod unmarshal;

src/marshal.rs renamed to src/marshal/unmarshal.rs

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::fmt;
22
use std::io;
3-
use std::sync::Arc;
3+
4+
use super::common::{Object, Code};
45

56
#[derive(Debug)]
67
pub enum UnmarshalError {
@@ -21,57 +22,6 @@ impl fmt::Display for UnmarshalError {
2122
}
2223
}
2324

24-
#[derive(PartialEq)]
25-
#[derive(Debug)]
26-
struct Code {
27-
argcount: u32,
28-
kwonlyargcount: u32,
29-
nlocals: u32,
30-
stacksize: u32,
31-
flags: u32,
32-
code: Object,
33-
consts: Object,
34-
names: Object,
35-
varnames: Object,
36-
freevars: Object,
37-
cellvars: Object,
38-
filename: Object,
39-
name: Object,
40-
firstlineno: u32,
41-
lnotab: Object,
42-
}
43-
44-
#[derive(PartialEq)]
45-
#[derive(Debug)]
46-
pub enum Object {
47-
Hole, // Temporary object for unmarshalling
48-
//Null,
49-
None,
50-
False,
51-
True,
52-
//StopIter,
53-
//Ellipsis,
54-
Int(u32),
55-
//Float,
56-
//BinaryFloat,
57-
//Complex,
58-
//BinaryComplex,
59-
String(::std::string::String),
60-
//Interned,
61-
//Ref_,
62-
Tuple(Vec<Object>),
63-
List(Vec<Object>),
64-
//Dict,
65-
Code(Box<Code>),
66-
//Unknown,
67-
Set(Vec<Object>),
68-
FrozenSet(Vec<Object>),
69-
Ref(u32),
70-
71-
Bytes(Vec<u8>), // aka. ASCII in CPython's marshal
72-
//ShortAscii,
73-
//ShortAsciiInterned
74-
}
7525

7626
macro_rules! read_byte {
7727
( $r:expr ) => {{

0 commit comments

Comments
 (0)