]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/windows/uniscribe/uniscribe.factor
Updating code to use with-out-parameters
[factor.git] / basis / windows / uniscribe / uniscribe.factor
old mode 100755 (executable)
new mode 100644 (file)
index feb0bef..ca90450
@@ -4,29 +4,28 @@ USING: kernel assocs math sequences fry io.encodings.string
 io.encodings.utf16n accessors arrays combinators destructors
 cache namespaces init fonts alien.c-types windows.usp10
 windows.offscreen windows.gdi32 windows.ole32 windows.types
-windows.fonts opengl.textures locals windows.errors ;
+windows.fonts opengl.textures locals windows.errors
+classes.struct ;
 IN: windows.uniscribe
 
-TUPLE: script-string font string metrics ssa size image disposed ;
+TUPLE: script-string < disposable font string metrics ssa size image ;
 
 : line-offset>x ( n script-string -- x )
     2dup string>> length = [
         ssa>> ! ssa
-        swap 1- ! icp
+        swap 1 - ! icp
         TRUE ! fTrailing
     ] [
         ssa>>
         swap ! icp
         FALSE ! fTrailing
     ] if
-    0 <int> [ ScriptStringCPtoX ole32-error ] keep *int ;
+    { int } [ ScriptStringCPtoX ole32-error ] [ ] with-out-parameters ;
 
 : x>line-offset ( x script-string -- n trailing )
     ssa>> ! ssa
     swap ! iX
-    0 <int> ! pCh
-    0 <int> ! piTrailing
-    [ ScriptStringXtoCP ole32-error ] 2keep [ *int ] bi@ ;
+    { int int } [ ScriptStringXtoCP ole32-error ] [ ] with-out-parameters ;
 
 <PRIVATE
 
@@ -81,15 +80,15 @@ TUPLE: script-string font string metrics ssa size image disposed ;
 : script-string-size ( script-string -- dim )
     ssa>> ScriptString_pSize
     dup win32-error=0/f
-    [ SIZE-cx ] [ SIZE-cy ] bi 2array ;
+    [ cx>> ] [ cy>> ] bi 2array ;
 
 : dc-metrics ( dc -- metrics )
-    "TEXTMETRICW" <c-object>
+    TEXTMETRICW <struct>
     [ GetTextMetrics drop ] keep
     TEXTMETRIC>metrics ;
 
 : <script-string> ( font string -- script-string )
-    [ script-string new ] 2dip
+    [ script-string new-disposable ] 2dip
         [ >>font ] [ >>string ] bi*
     [
         {
@@ -111,5 +110,5 @@ SYMBOL: cached-script-strings
 : cached-script-string ( font string -- script-string )
     cached-script-strings get-global [ <script-string> ] 2cache ;
 
-[ <cache-assoc> cached-script-strings set-global ]
-"windows.uniscribe" add-init-hook
+[ <cache-assoc> &dispose cached-script-strings set-global ]
+"windows.uniscribe" add-startup-hook