]> gitweb.factorcode.org Git - factor.git/commitdiff
windows.com.wrapper: Fix up docs example so it runs.
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 17 Mar 2018 23:15:30 +0000 (18:15 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 17 Mar 2018 23:15:30 +0000 (18:15 -0500)
basis/windows/com/wrapper/wrapper-docs.factor

index ea77f31c4d38597512ecfdf59f761ce1c0023af9..154c7870bc35f0d7ceb8514538cded9e1882f60c 100644 (file)
@@ -7,6 +7,7 @@ HELP: <com-wrapper>
 { $values { "implementations" "an assoc relating COM interface names to arrays of quotations implementing that interface" } { "wrapper" "a " { $link com-wrapper } " tuple" } }
 { $description "Constructs a " { $link com-wrapper } " tuple. Each key in the " { $snippet "implementations" } " assoc must be the name of an interface defined with " { $link POSTPONE: COM-INTERFACE: } ". The corresponding value must be an array of quotations implementing the methods of that interface in order, including those of its parent interfaces. The " { $snippet "IUnknown" } " methods (" { $link IUnknown::QueryInterface } ", " { $link IUnknown::AddRef } ", and " { $link IUnknown::Release } ") will be defined automatically and must not be specified in the array. These quotations should have stack effects mirroring those of the interface methods being implemented; for example, a method " { $snippet "void foobar ( int foo, int bar )" } " should be implemented with a quotation of effect " { $snippet "( this foo bar -- )" } ". The " { $snippet "this" } " parameter (that is, the leftmost parameter of any COM method) will be automatically converted from an alien pointer to the underlying Factor object before the quotation is invoked.\n\nThe resulting wrapper can be applied to a Factor object using the " { $link com-wrap } " word. The COM interface pointer returned by " { $snippet "com-wrap" } " can then be passed to C functions requiring a COM object as a parameter. The vtables constructed by " { $snippet "<com-wrapper>" } " are stored on the non-GC heap in order to be accessible to C functions; when the wrapper object and its vtables are no longer needed, the object's resources must be freed using " { $link dispose } ".\n\nExample:" }
 { $code "
+<<
 COM-INTERFACE: ISimple IUnknown {216fb341-0eb2-44b1-8edb-60b76e353abc}
     HRESULT returnOK ( )
     HRESULT returnError ( ) ;
@@ -18,19 +19,21 @@ COM-INTERFACE: IInherited ISimple {9620ecec-8438-423b-bb14-86f835aa40dd}
 COM-INTERFACE: IUnrelated IUnknown {b06ac3f4-30e4-406b-a7cd-c29cead4552c}
     int xPlus ( int y )
     int xMulAdd ( int mul, int add ) ;
-
+>>
+<<
 {
-    { \"IInherited\" {
+    { IInherited {
         [ drop S_OK ]    ! ISimple::returnOK
         [ drop E_FAIL ]  ! ISimple::returnError
         [ x>> ]          ! IInherited::getX
         [ >>x drop ]     ! IInherited::setX
     } }
-    { \"IUnrelated\" {
+    { IUnrelated {
         [ [ x>> ] [ + ] bi* ]   ! IUnrelated::xPlus
         [ [ x>> ] [ * ] [ + ] tri* ] ! IUnrealted::xMulAdd
     } }
-} <com-wrapper>" } ;
+} <com-wrapper> . ! In your code, set to a variable instead of printing
+>>" } ;
 
 HELP: com-wrap
 { $values { "object" "The factor object to wrap" } { "wrapper" "A " { $link com-wrapper } " object" } { "wrapped-object" "A COM object referencing " { $snippet "object" } } }