Skip to content

Commit

Permalink
make serializer have limits
Browse files Browse the repository at this point in the history
  • Loading branch information
noha committed Dec 16, 2024
1 parent 6fcec99 commit aa84e61
Show file tree
Hide file tree
Showing 19 changed files with 364 additions and 302 deletions.
4 changes: 2 additions & 2 deletions source/SnapDump-Core/Context.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #Context }
Extension { #name : 'Context' }

{ #category : #'*SnapDump-Core' }
{ #category : '*SnapDump-Core' }
Context >> asSnapshot [
^ SDMemorySnapshot new
setContext: self exceptionClassName: 'ContextWithoutException'
Expand Down
4 changes: 2 additions & 2 deletions source/SnapDump-Core/Exception.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #Exception }
Extension { #name : 'Exception' }

{ #category : #'*snapdump-core' }
{ #category : '*snapdump-core' }
Exception >> asSnapshot [
^ SDMemorySnapshot fromException: self
]
4 changes: 2 additions & 2 deletions source/SnapDump-Core/MemoryFileWriteStream.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #MemoryFileWriteStream }
Extension { #name : 'MemoryFileWriteStream' }

{ #category : #'*SnapDump-Core' }
{ #category : '*SnapDump-Core' }
MemoryFileWriteStream >> nextBytesPutAll: aCollection [
^ self stream nextPutAll: aCollection
]
64 changes: 33 additions & 31 deletions source/SnapDump-Core/SDException.class.st
Original file line number Diff line number Diff line change
@@ -1,77 +1,79 @@
Class {
#name : #SDException,
#superclass : #Object,
#name : 'SDException',
#superclass : 'Object',
#instVars : [
'version',
'id',
'exceptionClassName',
'exceptionSignalerClassName',
'exceptionSignalerSelector'
],
#category : #'SnapDump-Core-Model'
#category : 'SnapDump-Core-Model',
#package : 'SnapDump-Core',
#tag : 'Model'
}

{ #category : #'instance-creation' }
{ #category : 'instance-creation' }
SDException class >> id: aString [
^ self new id: aString; yourself
]

{ #category : #accessing }
{ #category : 'accessing' }
SDException class >> neoJsonMapping: mapper [
mapper for: self do: [ :mapping |
mapping mapInstVars: #(id exceptionSignalerClassName exceptionClassName exceptionSignalerSelector) ]
]

{ #category : #private }
{ #category : 'private' }
SDException >> buildId [
^ (SHA256 hashMessage: self fullSignature) hex
]

{ #category : #'accessing - exception properties' }
{ #category : 'accessing - exception properties' }
SDException >> exceptionClassName [

^ exceptionClassName
]

{ #category : #'accessing - exception properties' }
{ #category : 'accessing - exception properties' }
SDException >> exceptionClassName: aString [

exceptionClassName := aString
]

{ #category : #'accessing - exception properties' }
{ #category : 'accessing - exception properties' }
SDException >> exceptionSignalerClassName [
^ exceptionSignalerClassName
]

{ #category : #'accessing - exception properties' }
{ #category : 'accessing - exception properties' }
SDException >> exceptionSignalerClassName: aString [
exceptionSignalerClassName := aString
]

{ #category : #'accessing - exception properties' }
{ #category : 'accessing - exception properties' }
SDException >> exceptionSignalerSelector [
^ exceptionSignalerSelector
]

{ #category : #'accessing - exception properties' }
{ #category : 'accessing - exception properties' }
SDException >> exceptionSignalerSelector: aString [
exceptionSignalerSelector := aString
]

{ #category : #services }
{ #category : 'services' }
SDException >> freeSlots [

^ self store freeSlotsForException: self
]

{ #category : #signatures }
{ #category : 'signatures' }
SDException >> fullSignature [
^ String streamContents: [ :stream |
self fullSignatureOn: stream ]
]

{ #category : #signatures }
{ #category : 'signatures' }
SDException >> fullSignatureOn: stream [

stream
Expand All @@ -82,19 +84,19 @@ SDException >> fullSignatureOn: stream [
self signatureOn: stream
]

{ #category : #accessing }
{ #category : 'accessing' }
SDException >> id [

^ id ifNil: [ id := self buildId ]
]

{ #category : #accessing }
{ #category : 'accessing' }
SDException >> id: aString [

id := aString
]

{ #category : #'accessing - exception properties' }
{ #category : 'accessing - exception properties' }
SDException >> initializeExceptionProperties [

| snapshot |
Expand All @@ -104,38 +106,38 @@ SDException >> initializeExceptionProperties [
exceptionSignalerSelector := snapshot selector
]

{ #category : #initialization }
{ #category : 'initialization' }
SDException >> initializeFromClassName: aName receiver: aReceiver method: aSmalltalkMethod [

exceptionSignalerClassName := aReceiver class name asString.
exceptionSignalerSelector := aSmalltalkMethod selector asString.
exceptionClassName := aName
]

{ #category : #accessing }
{ #category : 'accessing' }
SDException >> project [

^ version project
]

{ #category : #accessing }
{ #category : 'accessing' }
SDException >> projectName [

^ version projectName
]

{ #category : #accessing }
{ #category : 'accessing' }
SDException >> selector [
^ exceptionSignalerSelector
]

{ #category : #signatures }
{ #category : 'signatures' }
SDException >> signalerSignature [
^ String streamContents: [ :stream |
self signalerSignatureOn: stream ]
]

{ #category : #signatures }
{ #category : 'signatures' }
SDException >> signalerSignatureOn: stream [

stream
Expand All @@ -144,13 +146,13 @@ SDException >> signalerSignatureOn: stream [
<< self exceptionSignalerSelector
]

{ #category : #signatures }
{ #category : 'signatures' }
SDException >> signature [
^ String streamContents: [ :stream |
self signatureOn: stream ]
]

{ #category : #signatures }
{ #category : 'signatures' }
SDException >> signatureOn: stream [

stream
Expand All @@ -159,28 +161,28 @@ SDException >> signatureOn: stream [
self signalerSignatureOn: stream
]

{ #category : #services }
{ #category : 'services' }
SDException >> snapshots [

^ self store snapshotsOfException: self
]

{ #category : #accessing }
{ #category : 'accessing' }
SDException >> store [
^ version store
]

{ #category : #accessing }
{ #category : 'accessing' }
SDException >> version [
^ version
]

{ #category : #accessing }
{ #category : 'accessing' }
SDException >> version: anObject [
version := anObject
]

{ #category : #accessing }
{ #category : 'accessing' }
SDException >> versionString [

^ version string
Expand Down
16 changes: 9 additions & 7 deletions source/SnapDump-Core/SDFileFormat.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,33 @@ I'm the base class of the snap file format. The structure of the format is
--- end of file ---
"
Class {
#name : #SDFileFormat,
#superclass : #Object,
#name : 'SDFileFormat',
#superclass : 'Object',
#instVars : [
'stream'
],
#category : #'SnapDump-Core-Base'
#category : 'SnapDump-Core-Base',
#package : 'SnapDump-Core',
#tag : 'Base'
}

{ #category : #accessing }
{ #category : 'accessing' }
SDFileFormat >> formatSignature [
^ 'SNAP'
]

{ #category : #accessing }
{ #category : 'accessing' }
SDFileFormat >> formatVersion [
^ 2
]

{ #category : #initialization }
{ #category : 'initialization' }
SDFileFormat >> initializeStream: aStream [

stream := aStream
]

{ #category : #accessing }
{ #category : 'accessing' }
SDFileFormat >> stream [
^ stream
]
16 changes: 9 additions & 7 deletions source/SnapDump-Core/SDFileSnapshot.class.st
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
Class {
#name : #SDFileSnapshot,
#superclass : #SDSnapshot,
#name : 'SDFileSnapshot',
#superclass : 'SDSnapshot',
#instVars : [
'file'
],
#category : #'SnapDump-Core-Model'
#category : 'SnapDump-Core-Model',
#package : 'SnapDump-Core',
#tag : 'Model'
}

{ #category : #accessing }
{ #category : 'accessing' }
SDFileSnapshot >> file: aFileReference [
file := aFileReference
]

{ #category : #'as yet unclassified' }
{ #category : 'as yet unclassified' }
SDFileSnapshot >> fileSize [
^ file size
]

{ #category : #options }
{ #category : 'options' }
SDFileSnapshot >> newReader [
^ SDSnapshotFileReader file: file
]

{ #category : #'as yet unclassified' }
{ #category : 'as yet unclassified' }
SDFileSnapshot >> storeRaw: aByteArray [

file binaryWriteStream
Expand Down
Loading

0 comments on commit aa84e61

Please sign in to comment.