Skip to content

Commit 425f2f6

Browse files
committed
Bugs fixed
1 parent 89ab559 commit 425f2f6

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

src/cls/CacheUpdater/TextServices.cls

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Class CacheUpdater.TextServices Extends %Compiler.UDL.TextServices
2+
{
3+
4+
/// This method takes a namespace an integer subscripted array containing lines of text which represent a
5+
/// class definition in the UDL class definition language. Subscript value 0 should contain a count
6+
/// of lines of text which are defined as subscript value 1 ... n in the array
7+
///
8+
/// Unlike %Compiler.UDL.TextServices saves classes with grammar errors. Taken from Atelier API
9+
///
10+
/// It is important to realize that this method will replace the existing class definition if present and therefore
11+
/// must contain a full representation of the class as can be obtained by calling the GetClassXXX() method(s) in
12+
/// this class. Note: The name of the class is derived from the name of the class defined within the text
13+
ClassMethod SetTextFromArray(pNamespace As %String = {$namespace}, pClassname As %String, ByRef pDocumentArray As %String) As %Status
14+
{
15+
#dim tSC,tStatus As %Status = $$$OK
16+
#dim e As %Exception.AbstractException
17+
18+
#dim tErrList,tOneErr As %String
19+
#dim tResultCode,tI As %Integer
20+
21+
Try {
22+
#; TODO: make sure pClassname and classname within the text match, else throw an error
23+
#; Remember pClassname has .cls extension!
24+
25+
#; Swap namespace if necessary
26+
If pNamespace'=$namespace new $namespace Set $namespace=pNamespace
27+
28+
#; Save the definition (just saves, doesn't compile)
29+
Set tFlags=16777216 ; 0x01000000 = IPARSE_UDL_SAVEWITHERRORS save even if parse errors
30+
31+
Set tResultCode=$compile(pDocumentArray,128,tErrList,,,tFlags)
32+
If tResultCode {
33+
For tI=1:1:$ll(tErrList) {
34+
Set tOneErr = $list(tErrList,tI),tStatus=$$$ERROR($$$ClassSaveError,$li(tOneErr,4),$li(tOneErr,1),$li(tOneErr,2),$li(tOneErr,6))
35+
If tSC=$$$OK {
36+
Set tSC=tStatus
37+
} else {
38+
Set tSC=$$$ADDSC(tSC,tStatus)
39+
}
40+
}
41+
}
42+
} Catch (e) {
43+
Set tSC=e.AsStatus()
44+
}
45+
Quit tSC
46+
}
47+
48+
}

src/cls/CacheUpdater/UDL.cls

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Class CacheUpdater.UDL Extends %RegisteredObject
22
{
33

4+
Parameter NamespacePar As %String = {$Namespace};
5+
46
/// Checks whether this file is in UDL format
57
/// <b>stream</b> - stream which contains file definition
68
ClassMethod IsUDLFile(stream As %GlobalCharacterStream) As %Boolean
@@ -199,7 +201,9 @@ ClassMethod CreateClass(contentStream As %CharacterStream, url As %String, ByRef
199201

200202

201203
Set namespace = $namespace
202-
Set st = ##class(%Compiler.UDL.TextServices).SetTextFromStream(namespace, className, contentStream)
204+
Set $namespace = ..#NamespacePar
205+
Set st = ##class(CacheUpdater.TextServices).SetTextFromStream(namespace,className, contentStream)
206+
Set $namespace = namespace
203207

204208
if st {
205209
w !, "Imported " _ className, !

0 commit comments

Comments
 (0)