Skip to content

Commit 20aabf3

Browse files
committed
Initial ObjectScript code
1 parent 318afe8 commit 20aabf3

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

isc/py/Callout.cls

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Class isc.py.Callout
2+
{
3+
4+
Parameter DLL As COSEXPRESSION = "$g(^isc.py.Callout)";
5+
6+
/// Init Python context
7+
/// do ##class(isc.py.Callout).Initialize()
8+
ClassMethod Initialize() As %Integer
9+
{
10+
set path = ..#DLL
11+
do $ZF(-3, path, "Initialize")
12+
}
13+
14+
/// Test method. Get random number
15+
/// w ##class(isc.py.Callout).GetRandom()
16+
ClassMethod GetRandom() As %Double
17+
{
18+
set path = ..#DLL
19+
set random = $ZF(-3, path, "GetRandom")
20+
quit random
21+
}
22+
23+
/// Init, eval code and return variable x.
24+
/// w ##class(isc.py.Callout).SimpleString()
25+
ClassMethod SimpleString(code = {"import random;" _ $$$NL _ "x=random.random();"}) As %Double
26+
{
27+
set path = ..#DLL
28+
set result = $ZF(-3, path, "SimpleString", code)
29+
quit result
30+
}
31+
32+
/// Eval code vaiable in initialized context and
33+
/// return value of variable (currently limited to double and similar)
34+
/// w ##class(isc.py.Callout).SimpleStringN()
35+
ClassMethod SimpleStringN(code As %String = {"import random;" _ $$$NL _ "x=random.random();"}, variable As %String = "") As %Double
36+
{
37+
set path = ..#DLL
38+
set result = $ZF(-3, path, "SimpleStringN", code, variable)
39+
quit result
40+
}
41+
42+
/// Finalize Python
43+
/// do ##class(isc.py.Callout).Finalize()
44+
ClassMethod Finalize() As %Integer
45+
{
46+
set path = ..#DLL
47+
do $ZF(-3, path, "Finalize")
48+
}
49+
50+
/// Unload library
51+
/// write ##class(Utils.Callout).Unload()
52+
ClassMethod Unload() As %Integer
53+
{
54+
set result = $ZF(-3, "")
55+
quit result
56+
}
57+
58+
}
59+

sc-list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
isc.py.pkg

0 commit comments

Comments
 (0)