File: openmath.gd

package info (click to toggle)
gap-scscp 2.4.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,704 kB
  • sloc: xml: 1,231; sh: 406; makefile: 19
file content (247 lines) | stat: -rw-r--r-- 9,617 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#############################################################################
##
#W openmath.gd              The SCSCP package              Olexandr Konovalov
#W                                                               Steve Linton
##
#############################################################################


###########################################################################
##
##  OMGetObjectWithAttributes
##
##  <#GAPDoc Label="OMGetObjectWithAttributes">
##  
##  <ManSection>
##  <Func Name="OMGetObjectWithAttributes" Arg="stream" />
##  <Returns>
##  record with components <C>object</C> and <C>attributes</C>, or <K>fail</K>
##  </Returns>	 
##  <Description>
##  <!-- TODO: Document option return_tree -->
##  This function is similar to the function <C>OMGetObject</C> from the
##  &OpenMath; package, and the main difference is that it is able to
##  understand &OpenMath; attribution pairs. It retrieves exactly one
##  &OpenMath; object from the stream <A>stream</A>, and stores it in the
##  <C>object</C> component of the returned record. If the &OpenMath; object
##  has no attributes, the <C>attributes</C> component of the returned record
##  will be an empty list, otherwise it will contain pairs
##  <C>[attribute&uscore;name,attribute&uscore;value]</C>, where
##  <C>attribute&uscore;name</C> is a string, and <C>attribute&uscore;value</C>
##  is a &GAP; object, whose type is determined by the kind of an attribute.
##  Only attributes, defined by the SCSCP are allowed, otherwise an error
##  message will be displayed. <P/> If the procedure was not successful, the
##  function returns <K>fail</K> instead of an error message like the function
##  <Ref BookName="OpenMath" Func="OMGetObject" /> does. Returning <K>fail</K>
##  is useful when <C>OMGetObjectWithAttributes</C> is used inside
##  accept-evaluate-return loop.
##  <P/>
##  As an example, the file <File>scscp/tst/omdemo.om</File> contains some 
##  &OpenMath; objects, including those from the SCSCP Specification 
##  <Cite Key="SCSCP"/>. We can retrieve them from this file,
##  preliminary installing some SCSCP procedures
##  using the function <Ref Func="InstallSCSCPprocedure"/>:
##  <Example>
##  <![CDATA[
##  gap> InstallSCSCPprocedure("WS_Factorial", Factorial );
##  gap> InstallSCSCPprocedure("GroupIdentificationService", IdGroup );
##  gap> InstallSCSCPprocedure("GroupByIdNumber", SmallGroup );
##  gap> InstallSCSCPprocedure( "Length", Length, 1, 1 );
##  gap> test:=Filename( Directory( Concatenation(
##  >         GAPInfo.PackagesInfo.("scscp")[1].InstallationPath,"/tst/" ) ), 
##  >         "omdemo.om" );;
##  gap> stream:=InputTextFile(test);;
##  gap> OMGetObjectWithAttributes(stream); 
##  rec( 
##    attributes := [ [ "option_return_object", "" ], [ "call_id", "5rc6rtG62" ] ]
##      , object := 6 )
##  gap> OMGetObjectWithAttributes(stream);
##  rec( attributes := [  ], object := 1 )
##  gap> OMGetObjectWithAttributes(stream);
##  rec( attributes := [  ], object := 120 )
##  gap> OMGetObjectWithAttributes(stream);
##  rec( 
##    attributes := [ [ "call_id", "alexk_9053" ], [ "option_runtime", 300000 ], 
##        [ "option_min_memory", 40964 ], [ "option_max_memory", 134217728 ], 
##        [ "option_debuglevel", 2 ], [ "option_return_object", "" ] ], 
##    object := [ 24, 12 ] )
##  gap> OMGetObjectWithAttributes(stream);
##  rec( 
##    attributes := [ [ "call_id", "alexk_9053" ], [ "option_return_cookie", "" ] 
##       ], object := <pc group of size 24 with 4 generators> )
##  gap> OMGetObjectWithAttributes(stream);
##  rec( attributes := [ [ "call_id", "alexk_9053" ], [ "info_runtime", 1234 ], 
##        [ "info_memory", 134217728 ] ], object := [ 24, 12 ] )
##  gap> CloseStream( stream );
##  ]]>
##  </Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareGlobalFunction( "OMGetObjectWithAttributes" );

DeclareGlobalFunction( "OMgetObjectXMLTreeWithAttributes" );


###########################################################################
##
##  OMPutProcedureCall( <stream>, <proc_name>, <objrec> )
##
##  <#GAPDoc Label="OMPutProcedureCall">
##  
##  <ManSection>
##  <Func Name="OMPutProcedureCall" Arg="stream proc_name objrec" />
##  <Returns>
##    nothing
##  </Returns>	 
##  <Description>
##  Takes a stream <A>stream</A>, the string <A>proc&uscore;name</A> and a
##  record <A>objrec</A>, and writes to <A>stream</A> an &OpenMath; object
##  <C>procedure&uscore;call</C> for the procedure <A>proc&uscore;name</A> with
##  arguments given by the list <C>objrec.object</C> and procedure call options
##  (which should be encoded as &OpenMath; attributes) given in the list
##  <C>objrec.attributes</C>. 
##  <P/>
##  This function accepts options <C>cd</C> and <C>debuglevel</C>.
##  <P/>
##  <C>cd:="cdname"</C> may be used to specify the name of the content 
##  dictionary if the procedure is actually a standard &OpenMath; symbol.
##  Note that the server may reject such a call if it accepts only calls 
##  of procedures from the transient content dictionary, see 
##  <Ref Func="InstallSCSCPprocedure"/> for explanation). If the <C>cdname</C> 
##  is not specified, <C>scscp_transient_1</C> content dictionary will be 
##  assumed by default.
##  The value of the <C>debuglevel</C> option is an integer. If it is non-zero,
##  the <C>procedure&uscore;completed</C> message will carry on also some
##  additional information about the call, for example, runtime and memory 
##  used.
##  <!-- TODO: document debuglevel option in more details -->
##  <Example>
##  <![CDATA[
##  gap> t:="";; stream:=OutputTextString(t,true);;
##  gap> OMPutProcedureCall( stream, "WS_Factorial", rec( object:= [ 5 ], 
##  >      attributes:=[ [ "call_id", "user007" ], 
##  >                    ["option_runtime",1000],
##  >                    ["option_min_memory",1024], 
##  >                    ["option_max_memory",2048],
##  >                    ["option_debuglevel",1], 
##  >                    ["option_return_object"] ] ) );;
##  gap> Print(t);
##  <?scscp start ?>
##  <OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
##  	<OMATTR>
##  		<OMATP>
##  			<OMS cd="scscp1" name="call_id"/>
##  			<OMSTR>user007</OMSTR>
##  			<OMS cd="scscp1" name="option_runtime"/>
##  			<OMI>1000</OMI>
##  			<OMS cd="scscp1" name="option_min_memory"/>
##  			<OMI>1024</OMI>
##  			<OMS cd="scscp1" name="option_max_memory"/>
##  			<OMI>2048</OMI>
##  			<OMS cd="scscp1" name="option_debuglevel"/>
##  			<OMI>1</OMI>
##  			<OMS cd="scscp1" name="option_return_object"/>
##  			<OMSTR></OMSTR>
##  		</OMATP>
##  		<OMA>
##  			<OMS cd="scscp1" name="procedure_call"/>
##  			<OMA>
##  				<OMS cd="scscp_transient_1" name="WS_Factorial"/>
##  				<OMI>5</OMI>
##  			</OMA>
##  		</OMA>
##  	</OMATTR>
##  </OMOBJ>
##  <?scscp end ?>
##  ]]>
##  </Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareGlobalFunction( "OMPutProcedureCall" );


###########################################################################
##
##  OMPutProcedureCompleted
##
##  <#GAPDoc Label="OMPutProcedureCompleted">
##  
##  <ManSection>
##  <Func Name="OMPutProcedureCompleted" Arg="stream objrec"/>
##  <Returns>
##    <K>true</K>
##  </Returns>	 
##  <Description>
##  Takes a stream <A>stream</A>, and a record 
##  <A>objrec</A>, and writes to <A>stream</A> an &OpenMath; object 
##  <C>procedure&uscore;completed</C> 
##  with the result being <C>objrec.object</C> and information messages
##  (as &OpenMath; attributes) given in the list <C>objrec.attributes</C>.
##  <Example>
##  <![CDATA[
##  gap> t:="";; stream:=OutputTextString(t,true);;
##  gap> OMPutProcedureCompleted( stream, 
##  >      rec(object:=120, 
##  >      attributes:=[ [ "call_id", "user007" ] ] ) );
##  true
##  gap> Print(t);
##  <?scscp start ?>
##  <OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
##  	<OMATTR>
##  		<OMATP>
##  			<OMS cd="scscp1" name="call_id"/>
##  			<OMSTR>user007</OMSTR>
##  		</OMATP>
##  		<OMA>
##  			<OMS cd="scscp1" name="procedure_completed"/>
##  			<OMI>120</OMI>
##  		</OMA>
##  	</OMATTR>
##  </OMOBJ>
##  <?scscp end ?>
##  ]]>
##  </Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "OMPutProcedureCompleted" );


###########################################################################
##
##  OMPutProcedureTerminated
##
##  <#GAPDoc Label="OMPutProcedureTerminated">
##  
##  <ManSection>
##  <Func Name="OMPutProcedureTerminated" Arg="stream objrec error_cd error_type"/>
##  <Returns>
##    nothing
##  </Returns>	 
##  <Description>
##  Takes a stream <A>stream</A>, and a record with an error message
##  <A>objrec</A> (for example <C>rec( attributes := [ [ "call_id",
##  "localhost:26133:87643:gcX33cCf" ] ],</C> <C>object := "localhost:26133
##  reports : Rational operations: &lt;divisor> must not be zero")</C> and
##  writes to the <A>stream</A> an &OpenMath; object
##  <C>procedure&uscore;terminated</C> containing an error determined by the
##  symbol <A>error_type</A> from the content dictionary <A>error_cd</A> (for
##  example, <C>error_memory</C>, <C>error_runtime</C> or
##  <C>error_system_specific</C> from the &scscp1; content dictionary (<Cite
##  Key="scscp1cd"/>). <P/> This is the internal function of the package which
##  is used only in the code for the &SCSCP; server to return the error message
##  to the client.   
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction( "OMPutProcedureTerminated" );


###########################################################################
##
#E 
##