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
36 lines (32 loc) · 1.06 KB
/
PBDeserializer.class.st
File metadata and controls
36 lines (32 loc) · 1.06 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
Class {
#name : #PBDeserializer,
#superclass : #LanguageLinkDeserializer,
#category : #'PythonBridge-Serialization'
}
{ #category : #'instance creation' }
PBDeserializer class >> deserialize: anObject [
^ self new
deserialize: anObject
]
{ #category : #'private protocol' }
PBDeserializer >> buildProxyFor: rawObject [
| proxy |
proxy := PBProxyObject
pythonClass: (rawObject at: #__pyclass__)
pythonVar: (rawObject at: #__pyid__) asP3GI
application: self application
superclasses: (rawObject at: #__superclasses__ ifAbsent: [ #() ]).
self executionHandler registerObject: proxy.
^ proxy
]
{ #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 ]
]