|
| 1 | +;;***************************************************************************** |
| 2 | +;; |
| 3 | +;; Title: ParameterBridgeDefinition.dbl |
| 4 | +;; |
| 5 | +;; Type: Class |
| 6 | +;; |
| 7 | +;; Description: A custom parameter loop expansion token for use with Harmony Core |
| 8 | +;; |
| 9 | +;; Date: 9th November 2020 |
| 10 | +;; |
| 11 | +;;***************************************************************************** |
| 12 | +;; |
| 13 | +;; Copyright (c) 2020, Synergex International, Inc. |
| 14 | +;; All rights reserved. |
| 15 | +;; |
| 16 | +;; Redistribution and use in source and binary forms, with or without |
| 17 | +;; modification, are permitted provided that the following conditions are met: |
| 18 | +;; |
| 19 | +;; * Redistributions of source code must retain the above copyright notice, |
| 20 | +;; this list of conditions and the following disclaimer. |
| 21 | +;; |
| 22 | +;; * Redistributions in binary form must reproduce the above copyright notice, |
| 23 | +;; this list of conditions and the following disclaimer in the documentation |
| 24 | +;; and/or other materials provided with the distribution. |
| 25 | +;; |
| 26 | +;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 27 | +;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 28 | +;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 29 | +;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 30 | +;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 31 | +;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 32 | +;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 33 | +;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 34 | +;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 35 | +;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 36 | +;; POSSIBILITY OF SUCH DAMAGE. |
| 37 | +;; |
| 38 | +;;***************************************************************************** |
| 39 | + |
| 40 | +import System |
| 41 | +import System.Collections.Generic |
| 42 | +import CodeGen.Engine |
| 43 | +import CodeGen.MethodCatalogAPI |
| 44 | +import CodeGen.RepositoryAPI |
| 45 | +import System.IO |
| 46 | +import Newtonsoft.Json |
| 47 | +import System.Linq |
| 48 | +import Newtonsoft.Json.Linq |
| 49 | + |
| 50 | +namespace HarmonyCoreExtensions |
| 51 | + |
| 52 | + public class ParameterBridgeDefinition implements IExpansionToken |
| 53 | + |
| 54 | + public property TokenName, String |
| 55 | + method get |
| 56 | + proc |
| 57 | + mreturn "HARMONYCORE_BRIDGE_PARAMETER_DEFINITION" |
| 58 | + endmethod |
| 59 | + endproperty |
| 60 | + |
| 61 | + public property Description, String |
| 62 | + method get |
| 63 | + proc |
| 64 | + mreturn "Generates a Synergy data type definition for a method parameter for use with Harmony Core Traditional Bridge." |
| 65 | + endmethod |
| 66 | + endproperty |
| 67 | + |
| 68 | + public property Validity, TokenValidity |
| 69 | + method get |
| 70 | + proc |
| 71 | + mreturn TokenValidity.ParameterLoop |
| 72 | + endmethod |
| 73 | + endproperty |
| 74 | + |
| 75 | + public property TokenCase, TokenCaseMode |
| 76 | + method get |
| 77 | + proc |
| 78 | + mreturn TokenCaseMode.AllCasingOptions |
| 79 | + endmethod |
| 80 | + endproperty |
| 81 | + |
| 82 | + public method Expand, String |
| 83 | + tkn, @Token |
| 84 | + template, @FileNode |
| 85 | + loops, @IEnumerable<LoopNode> |
| 86 | + proc |
| 87 | + lambda doExpand(catalog,iface,meth,param) |
| 88 | + begin |
| 89 | + using param.Type select |
| 90 | + (ParameterType.Alpha), |
| 91 | + begin |
| 92 | + mreturn String.Format("A{0}",param.Size) |
| 93 | + end |
| 94 | + (ParameterType.Decimal), |
| 95 | + begin |
| 96 | + mreturn String.Format("D{0}",param.Size) |
| 97 | + end |
| 98 | + (ParameterType.Enumeration), |
| 99 | + begin |
| 100 | + mreturn param.EnumName |
| 101 | + end |
| 102 | + (ParameterType.Handle, ParameterType.BinaryHandle), |
| 103 | + begin |
| 104 | + mreturn "D_HANDLE" |
| 105 | + end |
| 106 | + (ParameterType.ImpliedDecimal), |
| 107 | + begin |
| 108 | + mreturn String.Format("D{0}.{1}",param.Size==param.Precision?param.Size+1:param.Size,param.Precision) |
| 109 | + end |
| 110 | + (ParameterType.Integer), |
| 111 | + begin |
| 112 | + mreturn String.Format("I{0}",param.Size) |
| 113 | + end |
| 114 | + (ParameterType.String), |
| 115 | + begin |
| 116 | + mreturn "STRING" |
| 117 | + end |
| 118 | + (ParameterType.Structure), |
| 119 | + begin |
| 120 | + mreturn String.Format(param.StructureName) |
| 121 | + end |
| 122 | + endusing |
| 123 | + end |
| 124 | + mreturn TokenExpander.ExpandParameterLoopToken(tkn, template, loops, doExpand) |
| 125 | + endmethod |
| 126 | + |
| 127 | + endclass |
| 128 | + |
| 129 | +endnamespace |
0 commit comments