forked from ObjectProfile/PythonBridge
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPBDeserializer.class.st
More file actions
50 lines (43 loc) · 1.34 KB
/
PBDeserializer.class.st
File metadata and controls
50 lines (43 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Class {
#name : #PBDeserializer,
#superclass : #PBMapper,
#category : #'PythonBridge-Serialization'
}
{ #category : #'private protocol' }
PBDeserializer class >> deserialize: anObject [
^ self new
deserialize: anObject
]
{ #category : #'private protocol' }
PBDeserializer >> application [
^ self executionHandler application
]
{ #category : #'private protocol' }
PBDeserializer >> buildProxyFor: rawObject [
| proxy |
proxy := PBProxyObject
pythonClass: (rawObject at: #__pyclass__)
pythonVar: (rawObject at: #__pyid__) asP3GI
application: self application.
self executionHandler registerObject: proxy.
^ proxy
]
{ #category : #'private protocol' }
PBDeserializer >> deserialize: str [
^ self privateDeserialize: (serializerWrapper deserialize: str).
]
{ #category : #'private protocol' }
PBDeserializer >> objectRegistry [
^ self executionHandler objectRegistry
]
{ #category : #'private protocol' }
PBDeserializer >> privateDeserialize: rawObj [
rawObj isCollection ifFalse: [ ^ rawObj ].
rawObj isDictionary and: [ (rawObj includesKey: #__pyid__)
ifTrue: [ ^ self reifyProxyFor: rawObj ] ].
^ rawObj collect: [ :elem | self privateDeserialize: elem ]
]
{ #category : #'private protocol' }
PBDeserializer >> reifyProxyFor: rawObj [
^ self objectRegistry resolve: (rawObj at: #__pyid__) ifAbsent: [ self buildProxyFor: rawObj ]
]