Commit a5234629 authored by Depasse Arthur's avatar Depasse Arthur

ajout de la génération automatique des classes de parsing à partir de l'asn1,...

ajout de la génération automatique des classes de parsing à partir de l'asn1, des modifs restent à faire
parent f799c630
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>fr.supelec.plong9.acceleo.feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="fr.supelec.plong9.acceleo.feature"
label="Feature"
version="1.0.0.qualifier">
<description url="http://www.example.com/description">
[Enter Feature Description here.]
</description>
<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
</copyright>
<license url="http://www.example.com/license">
[Enter License Description here.]
</license>
<plugin
id="fr.supelec.plong9.acceleo.generation.ui"
download-size="0"
install-size="0"
version="0.0.0"/>
<plugin
id="fr.supelec.plong9.acceleo.generation"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>
......@@ -5,8 +5,8 @@ Bundle-SymbolicName: fr.supelec.plong9.acceleo.generation
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: fr.supelec.plong9.acceleo.generation.Activator
Bundle-Vendor: Eclipse Modeling Project
Require-Bundle: org.eclipse.core.runtime,
fr.supelec.plong9.fsm,
Require-Bundle: org.eclipse.core.runtime,
fr.supelec.plong9.fsm,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.xmi,
org.eclipse.ocl,
......@@ -15,9 +15,12 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.acceleo.model;bundle-version="3.3.0",
org.eclipse.acceleo.profiler;bundle-version="3.3.0",
org.eclipse.acceleo.engine;bundle-version="3.3.0",
com.google.guava
com.google.guava,
org.eclipse.osgi,
org.eclipse.core.resources
Bundle-RequiredExecutionEnvironment: JavaSE-10
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
Export-Package: fr.supelec.plong9.acceleo.generation.main
Eclipse-BundleShape: dir
instructions.install = \
chmod(targetDir:${installFolder}/resources/asn1_scripts/jasn1-compiler,targetFile:resources/asn1_scripts/jasn1-compiler,permissions:755);\
chmod(targetDir:${installFolder}/resources/asn1_scripts/jasn1-compiler.bat,targetFile:resources/asn1_scripts/jasn1-compiler.bat,permissions:755);
instructions.install.import = org.eclipse.equinox.p2.touchpoint.eclipse.chmod
\ No newline at end of file
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
.,\
resources/
jre.compilation.profile = JavaSE-10
#!/bin/bash
JARS_LOCATION="build/libs-all"
MAIN_CLASS="org.openmuc.jasn1.compiler.Compiler"
SYSPROPS=""
PARAMS=""
SCRIPT_HOME=`dirname $0`
CLASSPATH=$(JARS=("$SCRIPT_HOME"/"$JARS_LOCATION"/*.jar); IFS=:; echo "${JARS[*]}")
for i in $@; do
if [[ $i == -D* ]]; then
SYSPROPS="$SYSPROPS $i";
else
PARAMS="$PARAMS $i";
fi
done
java $SYSPROPS -cp $CLASSPATH $MAIN_CLASS $PARAMS
::BATCH file to windows
ECHO compiling
set BATDIR=%~dp0
set LIBDIR=%BATDIR%..\build\libs-all
java -Djava.ext.dirs=%LIBDIR% org.openmuc.jasn1.compiler.Compiler %*
......@@ -10,19 +10,31 @@
*******************************************************************************/
package fr.supelec.plong9.acceleo.generation.main;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.acceleo.engine.event.IAcceleoTextGenerationListener;
import org.eclipse.acceleo.engine.generation.strategy.IAcceleoGenerationStrategy;
import org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
/**
* Entry point of the 'Main' generation module.
......@@ -171,7 +183,7 @@ public class Main extends AbstractAcceleoGenerator {
* This will be used to display progress information to the user.
* @throws IOException
* This will be thrown if any of the output files cannot be saved to disk.
* @generated
* @generated NOT
*/
@Override
public void doGenerate(Monitor monitor) throws IOException {
......@@ -200,6 +212,39 @@ public class Main extends AbstractAcceleoGenerator {
//}
super.doGenerate(monitor);
URL fileURL = new URL("platform:/plugin/fr.supelec.plong9.acceleo.generation/resources/asn1_scripts/jasn1-compiler");
System.out.println(fileURL.toString());
File file = null;
try {
file = new File(FileLocator.resolve(fileURL).toURI());
} catch (URISyntaxException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
System.out.println(file.getAbsolutePath());
File currentDirFile = new File(".");
String helper = currentDirFile.getAbsolutePath();
String currentDir = helper.substring(0, helper.length() - currentDirFile.getCanonicalPath().length());
System.out.println("project dir : " + currentDir);
var wrkspace_path = ResourcesPlugin.getWorkspace().getRoot().getLocation();
String[] args = {wrkspace_path.append("exampleFSM/src-gen/MessagePing.asn1").toString(), wrkspace_path.append("exampleFSM/src-gen").toString(), "asn1"};
Process process = new ProcessBuilder(file.getAbsolutePath(), "-f", args[0], "-o", args[1], "-p", args[2]).start();
//System.out.println(process.exitValue());
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
System.out.printf("Output of running %s is:", Arrays.toString(args));
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
/**
......
......@@ -32,6 +32,7 @@
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.emf.codegen.ecore_2.14.0.v20180418-0836.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.emf.codegen_2.13.0.v20180319-0813.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/com.google.guava_21.0.0.v20170206-1425.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.core.resources_3.13.0.v20180512-1138.jar"/>
</path>
<path id="fr.supelec.plong9.acceleo.generation.classpath">
......
/**
* This class file was automatically generated by jASN1 v1.10.0 (http://www.openmuc.org)
*/
package asn1.messageping;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import org.openmuc.jasn1.ber.*;
import org.openmuc.jasn1.ber.types.*;
import org.openmuc.jasn1.ber.types.string.*;
public class MESSAGETYPE extends BerEnum {
private static final long serialVersionUID = 1L;
public MESSAGETYPE() {
}
public MESSAGETYPE(byte[] code) {
super(code);
}
public MESSAGETYPE(BigInteger value) {
super(value);
}
public MESSAGETYPE(long value) {
super(value);
}
}
/**
* This class file was automatically generated by jASN1 v1.10.0 (http://www.openmuc.org)
*/
package asn1.messageping;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import org.openmuc.jasn1.ber.*;
import org.openmuc.jasn1.ber.types.*;
import org.openmuc.jasn1.ber.types.string.*;
public class MessagePing implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
public byte[] code = null;
private BerInteger id = null;
private MESSAGETYPE type = null;
public MessagePing() {
}
public MessagePing(byte[] code) {
this.code = code;
}
public void setId(BerInteger id) {
this.id = id;
}
public BerInteger getId() {
return id;
}
public void setType(MESSAGETYPE type) {
this.type = type;
}
public MESSAGETYPE getType() {
return type;
}
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
codeLength += type.encode(reverseOS, true);
codeLength += id.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerInteger.tag)) {
id = new BerInteger();
subCodeLength += id.decode(is, false);
subCodeLength += berTag.decode(is);
}
else {
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(MESSAGETYPE.tag)) {
type = new MESSAGETYPE();
subCodeLength += type.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
}
throw new IOException("Unexpected end of sequence, length tag: " + totalLength + ", actual sequence length: " + subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (id != null) {
sb.append("id: ").append(id);
}
else {
sb.append("id: <empty-required-field>");
}
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (type != null) {
sb.append("type: ").append(type);
}
else {
sb.append("type: <empty-required-field>");
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment