Cairo__CObject.st
changeset 43 1006839761af
parent 40 28dfc583beb5
child 63 054f0513ea65
equal deleted inserted replaced
42:475e93b10c8f 43:1006839761af
     3 "{ NameSpace: Cairo }"
     3 "{ NameSpace: Cairo }"
     4 
     4 
     5 ExternalAddress subclass:#CObject
     5 ExternalAddress subclass:#CObject
     6 	instanceVariableNames:''
     6 	instanceVariableNames:''
     7 	classVariableNames:'Lobby'
     7 	classVariableNames:'Lobby'
     8 	poolDictionaries:''
     8 	poolDictionaries:'Cairo::Status'
     9 	category:'Cairo-Objects'
     9 	category:'Cairo-Objects'
    10 !
    10 !
    11 
    11 
    12 
    12 
    13 !CObject class methodsFor:'initialization'!
    13 !CObject class methodsFor:'initialization'!
    38 
    38 
    39     ^ self subclassResponsibility
    39     ^ self subclassResponsibility
    40 
    40 
    41     "Created: / 09-09-2008 / 20:33:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
    41     "Created: / 09-09-2008 / 20:33:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
    42     "Modified: / 28-12-2014 / 22:09:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    42     "Modified: / 28-12-2014 / 22:09:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    43 !
       
    44 
       
    45 status
       
    46     "Checks whether an error has previously occurred for this object.
       
    47      See Cairo::Status pool for possible values."    
       
    48 
       
    49     ^ self subclassResponsibility
       
    50 
       
    51     "Created: / 23-02-2016 / 10:43:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    43 ! !
    52 ! !
    44 
    53 
    45 !CObject methodsFor:'finalization'!
    54 !CObject methodsFor:'finalization'!
    46 
    55 
    47 executor
    56 executor
    53     "Created: / 10-09-2008 / 18:57:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
    62     "Created: / 10-09-2008 / 18:57:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
    54     "Modified: / 25-12-2014 / 10:36:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    63     "Modified: / 25-12-2014 / 10:36:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    55 !
    64 !
    56 
    65 
    57 finalize
    66 finalize
    58     self infoPrintCR:'Instance destroyed'.
    67     Logger debug: '%1@%2 instance finalized' with: self address with: self referenceCount.
    59     self destroy
    68     self destroy
    60 
    69 
    61     "Created: / 09-09-2008 / 20:30:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
    70     "Created: / 09-09-2008 / 20:30:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
    62     "Modified: / 10-09-2008 / 18:45:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
    71     "Modified: / 10-09-2008 / 18:45:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
    63     "Modified: / 28-12-2014 / 21:39:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    72     "Modified: / 28-12-2014 / 21:39:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    64 ! !
    73 ! !
    65 
    74 
    66 !CObject methodsFor:'initialization & release'!
    75 !CObject methodsFor:'initialization & release'!
    67 
    76 
       
    77 initialize
       
    78     | status |
       
    79     
       
    80     Logger debug: '%1@%2 instance created' with: self address with: self referenceCount.
       
    81     self registerForFinalization.
       
    82     status := self status.
       
    83     status ~~ CAIRO_STATUS_SUCCESS ifTrue:[ 
       
    84         CError raiseWith: status errorString: 'Failed to create ', self class name
       
    85     ].
       
    86 
       
    87     "Created: / 23-02-2016 / 10:54:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    88     "Modified: / 23-02-2016 / 16:57:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    89 !
       
    90 
    68 release
    91 release
       
    92     Logger debug: '%1@%2 instance released explicitly' with: self address with: self referenceCount.
    69     self unregisterForFinalization.
    93     self unregisterForFinalization.
    70     ^self destroy
    94     ^self destroy
    71 
    95 
    72     "Created: / 25-12-2014 / 10:34:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    96     "Created: / 25-12-2014 / 10:34:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    73     "Modified: / 13-02-2016 / 16:10:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    97     "Modified: / 13-02-2016 / 16:10:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    84     ^ self subclassResponsibility
   108     ^ self subclassResponsibility
    85 
   109 
    86     "Created: / 28-12-2014 / 21:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   110     "Created: / 28-12-2014 / 21:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    87 !
   111 !
    88 
   112 
    89 fromExternalAddress:anExternalAddress 
   113 statusCheck
    90     self setAddress: anExternalAddress address.  
   114     <resource: #skipInDebuggersWalkBack>        
    91     self registerForFinalization.
       
    92     self infoPrintCR:'Instance created'.
       
    93 
   115 
    94     "Created: / 09-09-2008 / 20:35:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
   116     | status |
    95     "Modified: / 10-09-2008 / 18:45:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
       
    96     "Modified: / 25-12-2014 / 10:36:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    97 !
       
    98 
   117 
    99 infoPrintCR:aString 
   118     status := self status.
   100     Stdout
   119     status ~~ CAIRO_STATUS_SUCCESS ifTrue:[ 
   101         nextPutAll:'Cairo [info] (';
   120         CError raiseWith: status errorString: 'Operation failed'.  
   102         nextPutAll:self class nameWithoutPrefix;
   121     ].
   103         nextPutAll:' @ 0x';
       
   104         nextPutAll:(self address printStringRadix:16);
       
   105         nextPutAll:' @ ';
       
   106         nextPutAll:(self referenceCount printString);
       
   107         nextPutAll:': ';
       
   108         nextPutAll:aString;
       
   109         cr
       
   110 
   122 
   111     "Created: / 10-09-2008 / 18:45:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
   123     "Created: / 21-02-2016 / 15:11:55 / jv"
       
   124     "Modified: / 23-02-2016 / 16:56:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   112 ! !
   125 ! !
   113 
   126 
   114 !CObject class methodsFor:'documentation'!
   127 !CObject class methodsFor:'documentation'!
   115 
   128 
   116 version
   129 version