|
| 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 | +} |
0 commit comments