updates coredsl version and makes BitValues with leading zeros

This commit is contained in:
2025-09-27 12:30:34 +02:00
parent 6ee86b26db
commit b37ab5d008
10 changed files with 24 additions and 15 deletions

View File

@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Automatic-Module-Name: com.minres.coredsl.json
Bundle-ManifestVersion: 2
Bundle-Vendor: MINRES Technologies GmbH
Bundle-Version: 2.0.1
Bundle-Version: 2.0.2
Bundle-SymbolicName: com.minres.coredsl.json;singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: com.minres.coredsl;bundle-version="2.0.0",

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>com.minres.coredsl</groupId>
<artifactId>com.minres.coredsl.json.parent</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<relativePath>..</relativePath>
</parent>
<artifactId>com.minres.coredsl.json</artifactId>

View File

@@ -20,6 +20,7 @@ import org.json.JSONObject
import org.json.JSONArray
import com.minres.coredsl.coreDsl.Statement
import org.eclipse.xtext.resource.XtextResource
import com.minres.coredsl.util.TypedBigInteger
/**
* Generates code from your model files on save.
@@ -108,7 +109,15 @@ class CoreDslJsonGenerator extends AbstractGenerator {
def dispatch asString(BitField i) '''«i.name»[«i.startIndex.value.intValue»:«i.endIndex.value.intValue»]'''
def dispatch asString(BitValue i) {
i.value.toString(2)
val str = i.value.toString(2)
if(i.value instanceof TypedBigInteger) {
val v = i.value as TypedBigInteger
if(v.size > str.length) {
val format_string = String.format("%%%ds", v.size)
return String.format(format_string, str).replace(' ', '0');
}
}
return str
}