Skip to content

Commit 1e39882

Browse files
committed
Callout docs
1 parent 34164eb commit 1e39882

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

isc/py/Callout.cls

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/// Main callout wrapper.
2+
/// To use:
3+
/// 1. Call: write ##class(isc.py.Callout).Setup() once per systems start
4+
/// 2. Call: do ##class(isc.py.Callout).Initialize() once per process
5+
/// 3. Call main method (can be called many times, context persists): write ##class(isc.py.Callout).SimpleString(code, data)
6+
/// 4. Call: do ##class(isc.py.Callout).Finalize() to free Python context
7+
/// 5. Call: write ##class(isc.py.Callout).Unload() to free callout library
18
Class isc.py.Callout
29
{
310

@@ -17,6 +24,8 @@ Parameter SimpleString As Integer = 6;
1724

1825
Parameter DLL As COSEXPRESSION = "$g(^isc.py.Callout, $g(^%SYS(""bindir"")) _ ""libhelloworld.dll"")";
1926

27+
/// Should be executed once per system start. Idempotent.
28+
/// Add to ZSTART or production start.
2029
/// write ##class(isc.py.Callout).Setup()
2130
ClassMethod Setup()
2231
{
@@ -25,7 +34,7 @@ ClassMethod Setup()
2534
quit sc
2635
}
2736

28-
/// Init Python context
37+
/// Init Python context. Idempotent.
2938
/// do ##class(isc.py.Callout).Initialize()
3039
ClassMethod Initialize(debug As %Boolean = {$$$NO}) As %Integer
3140
{
@@ -70,7 +79,7 @@ ClassMethod SimpleStringFull(code = {"import random;" _ $$$NL _ "x=random.random
7079

7180
/// Eval code vaiable in initialized context and
7281
/// return value of variable str evaluation
73-
/// w ##class(isc.py.Callout).SimpleString()
82+
/// write ##class(isc.py.Callout).SimpleString()
7483
ClassMethod SimpleString(code As %String = {"import random;" _ $$$NL _ "x=random.random();"}, variable As %String = "x") As %Double
7584
{
7685
set converted = $$$NO
@@ -85,15 +94,15 @@ ClassMethod SimpleString(code As %String = {"import random;" _ $$$NL _ "x=random
8594
quit result
8695
}
8796

88-
/// Finalize Python
97+
/// Finalize Python. Idempotent.
8998
/// do ##class(isc.py.Callout).Finalize()
9099
ClassMethod Finalize() As %Integer
91100
{
92101
set path = ..#DLL
93102
do $ZF(-6, ..#PyLibId, ..#Finalize)
94103
}
95104

96-
/// Unload library
105+
/// Unload library. Idempotent.
97106
/// write ##class(isc.py.Callout).Unload()
98107
ClassMethod Unload() As %Integer
99108
{

0 commit comments

Comments
 (0)