--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Cairo__CObject.st Mon Dec 29 00:14:00 2014 +0100
@@ -0,0 +1,112 @@
+"{ Package: 'stx:goodies/libcairo' }"
+
+"{ NameSpace: Cairo }"
+
+ExternalAddress subclass:#CObject
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Cairo-Objects'
+!
+
+
+!CObject class methodsFor:'instance creation'!
+
+fromExternalAddress: anExternalAddress
+ ^ self new fromExternalAddress: anExternalAddress
+
+ "Created: / 24-12-2014 / 22:18:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 25-12-2014 / 10:33:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CObject methodsFor:'accessing'!
+
+referenceCount
+ "Return value or reference counter"
+
+ ^ self subclassResponsibility
+
+ "Created: / 09-09-2008 / 20:33:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 28-12-2014 / 22:09:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CObject methodsFor:'finalization'!
+
+executor
+
+ ^self class basicNew
+ setAddress: self address;
+ yourself
+
+ "Created: / 10-09-2008 / 18:57:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 25-12-2014 / 10:36:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+finalize
+ self infoPrintCR:'Instance destroyed'.
+ self destroy
+
+ "Created: / 09-09-2008 / 20:30:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 10-09-2008 / 18:45:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 28-12-2014 / 21:39:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CObject methodsFor:'initialization & release'!
+
+release
+ self setAddress: nil.
+ self unregisterForFinalization.
+ ^self destroy
+
+ "Created: / 25-12-2014 / 10:34:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 28-12-2014 / 21:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CObject methodsFor:'private'!
+
+destroy
+ "Tell Cairo library to destroy the corresponding C object.
+ Remember that object is physically destroyed only if internal
+ refcounter goes to zero. However, after calling destroy,
+ this instance should be treated as invalid."
+
+ ^ self subclassResponsibility
+
+ "Created: / 28-12-2014 / 21:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+fromExternalAddress:anExternalAddress
+ self setAddress: anExternalAddress address.
+ self registerForFinalization.
+ self infoPrintCR:'Instance created'.
+
+ "Created: / 09-09-2008 / 20:35:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 10-09-2008 / 18:45:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 25-12-2014 / 10:36:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+infoPrintCR:aString
+ Stdout
+ nextPutAll:'Cairo [info] (';
+ nextPutAll:self class nameWithoutPrefix;
+ nextPutAll:' @ 0x';
+ nextPutAll:(self address printStringRadix:16);
+ nextPutAll:' @ ';
+ nextPutAll:(self referenceCount printString);
+ nextPutAll:': ';
+ nextPutAll:aString;
+ cr
+
+ "Created: / 10-09-2008 / 18:45:23 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!CObject class methodsFor:'documentation'!
+
+version
+ ^'$Id$'
+!
+
+version_HG
+ ^ '$Changeset: <not expanded> $'
+! !
+