Skip to content

Commit

Permalink
Bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
gevorg95 committed Feb 2, 2017
1 parent 89ab559 commit 425f2f6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
48 changes: 48 additions & 0 deletions src/cls/CacheUpdater/TextServices.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Class CacheUpdater.TextServices Extends %Compiler.UDL.TextServices
{

/// This method takes a namespace an integer subscripted array containing lines of text which represent a
/// class definition in the UDL class definition language. Subscript value 0 should contain a count
/// of lines of text which are defined as subscript value 1 ... n in the array
///
/// Unlike %Compiler.UDL.TextServices saves classes with grammar errors. Taken from Atelier API
///
/// It is important to realize that this method will replace the existing class definition if present and therefore
/// must contain a full representation of the class as can be obtained by calling the GetClassXXX() method(s) in
/// this class. Note: The name of the class is derived from the name of the class defined within the text
ClassMethod SetTextFromArray(pNamespace As %String = {$namespace}, pClassname As %String, ByRef pDocumentArray As %String) As %Status
{
#dim tSC,tStatus As %Status = $$$OK
#dim e As %Exception.AbstractException

#dim tErrList,tOneErr As %String
#dim tResultCode,tI As %Integer

Try {
#; TODO: make sure pClassname and classname within the text match, else throw an error
#; Remember pClassname has .cls extension!

#; Swap namespace if necessary
If pNamespace'=$namespace new $namespace Set $namespace=pNamespace

#; Save the definition (just saves, doesn't compile)
Set tFlags=16777216 ; 0x01000000 = IPARSE_UDL_SAVEWITHERRORS save even if parse errors

Set tResultCode=$compile(pDocumentArray,128,tErrList,,,tFlags)
If tResultCode {
For tI=1:1:$ll(tErrList) {
Set tOneErr = $list(tErrList,tI),tStatus=$$$ERROR($$$ClassSaveError,$li(tOneErr,4),$li(tOneErr,1),$li(tOneErr,2),$li(tOneErr,6))
If tSC=$$$OK {
Set tSC=tStatus
} else {
Set tSC=$$$ADDSC(tSC,tStatus)
}
}
}
} Catch (e) {
Set tSC=e.AsStatus()
}
Quit tSC
}

}
6 changes: 5 additions & 1 deletion src/cls/CacheUpdater/UDL.cls
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Class CacheUpdater.UDL Extends %RegisteredObject
{

Parameter NamespacePar As %String = {$Namespace};

/// Checks whether this file is in UDL format
/// <b>stream</b> - stream which contains file definition
ClassMethod IsUDLFile(stream As %GlobalCharacterStream) As %Boolean
Expand Down Expand Up @@ -199,7 +201,9 @@ ClassMethod CreateClass(contentStream As %CharacterStream, url As %String, ByRef


Set namespace = $namespace
Set st = ##class(%Compiler.UDL.TextServices).SetTextFromStream(namespace, className, contentStream)
Set $namespace = ..#NamespacePar
Set st = ##class(CacheUpdater.TextServices).SetTextFromStream(namespace,className, contentStream)
Set $namespace = namespace

if st {
w !, "Imported " _ className, !
Expand Down

0 comments on commit 425f2f6

Please sign in to comment.