Skip to content

Commit c0c4d60

Browse files
committed
New dynamic object macros.
1 parent 2bd442d commit c0c4d60

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

MDX2JSON/MDX2JSON.inc.xml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@
1010
#define Private '$$$Public
1111
1212
#; For work with dynamic objects
13-
#define IsNewVersion $S($System.Version.GetMajor()>2015:"1",$System.Version.GetMajor()=2015:$S($System.Version.GetMinor()>=3:"1",1:"0"),1:"0")
14-
#define NewDynObj ##Expression($S($$$IsNewVersion=1:"##class(%Object).%New()",1:"##class(%ZEN.proxyObject).%New()"))
15-
#define NewDynObjList ##Expression($S($$$IsNewVersion=1:"##class(%Array).%New()",1:"##class(%ListOfObjects).%New()"))
16-
#define NewDynDTList ##Expression($S($$$IsNewVersion=1:"##class(%Array).%New()",1:"##class(%ListOfDataTypes).%New()"))
17-
#define Insert(%obj,%element) ##Expression($S($$$IsNewVersion=1:"do %obj.$push(%element)",1:"do %obj.Insert(%element)"))
18-
#define InsertQuoted(%obj,%element) ##Expression($S($$$IsNewVersion=1:"do %obj.$push("%element")",1:"do %obj.Insert("%element")"))
19-
#define DynObjToJSON(%obj) ##Expression($S($$$IsNewVersion=1:"do %obj.$toJSON()",1:"do %obj.%ToJSON()"))
20-
#define ListToJSON(%obj) ##Expression($S($$$IsNewVersion=1:"do %obj.$toJSON()",1:"do ##class(%ZEN.Auxiliary.jsonProvider).%ObjectToJSON(%obj)"))
13+
#if $$$comClassDefined("%Library.Array")
14+
#define NewDynObj ##class(%Object).%New()
15+
#define NewDynDTList ##class(%Array).%New()
16+
#define NewDynObjList $$$NewDynDTList
17+
#define Insert(%obj,%element) do %obj.$push(%element)
18+
#define DynObjToJSON(%obj) do %obj.$toJSON()
19+
#define ListToJSON(%obj) $$$DynObjToJSON(%obj)
20+
#else
21+
#define NewDynObj ##class(%ZEN.proxyObject).%New()
22+
#define NewDynDTList ##class(%ListOfDataTypes).%New()
23+
#define NewDynObjList ##class(%ListOfObjects).%New()
24+
#define Insert(%obj,%element) do %obj.Insert(%element)
25+
#define DynObjToJSON(%obj) do %obj.%ToJSON()
26+
#define ListToJSON(%obj) do ##class(%ZEN.Auxiliary.jsonProvider).%ObjectToJSON(%obj)
27+
#endif
2128
2229
]]></Routine>
2330
</Export>

MDX2JSON/Tests.cls.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ do ##class(MDX2JSON.Tests).DynamicObjects()</Description>
109109
<ClassMethod>1</ClassMethod>
110110
<Implementation><![CDATA[
111111
112-
set obj = $$$NewDynObj
112+
/*set obj = $$$NewDynObj
113113
set obj.prop = "val"
114114
$$$DynObjToJSON(obj)
115-
115+
*/
116116
set dtList = $$$NewDynDTList
117117
s a=1
118-
$$$Insert(dtList,a)
119-
$$$ListToJSON(dtList)
118+
$$$Insert(dtList,"a")
119+
//$$$ListToJSON(dtList)
120120
]]></Implementation>
121121
</Method>
122122
</Class>

0 commit comments

Comments
 (0)