Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Implementation for LibraryElementHasher #597

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/org.eclipse.fordiac.ide.export.forte_ng.st/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
type="org.eclipse.fordiac.ide.model.libraryElement.STFunctionBody">
</source>
</factory>
</extension>
<extension
point="org.eclipse.fordiac.ide.export.forte_ng.util.LibraryElementHasherExtension">
<client
class="org.eclipse.fordiac.ide.export.forte_ng.st.LibraryElementHasher"/>
</extension>

</plugin>

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions plugins/org.eclipse.fordiac.ide.export.forte_ng/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
</source>
</factory>
</extension>
<extension-point id="org.eclipse.fordiac.ide.export.forte_ng.util.LibraryElementHasherExtension" name="Extension point for Library Element Hasher" schema="schema/org.eclipse.fordiac.ide.export.forte_ng.util.LibraryElementHasherExtension.exsd"/>

</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.fordiac.ide.export.forte_ng" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.eclipse.fordiac.ide.export.forte_ng" id="org.eclipse.fordiac.ide.export.forte_ng.util.LibraryElementHasherExtension" name="Extension for Library Element Hasher"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>

<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
<element ref="client"/>
</choice>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>

</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>

</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<element name="client">
<complexType>
<attribute name="class" type="string">
<annotation>
<documentation>

</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.eclipse.fordiac.ide.export.forte_ng.util.IHasher"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>

<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
3.0
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>

<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>


</schema>
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ abstract class ForteFBTemplate<T extends FBType> extends ForteLibraryElementTemp

def protected generateInterfaceDeclarations() '''
«generateInterfaceVariableAndConnectionDeclarations()»
static const std::string hash_version = "«getHashType»";
static const std::string hash_value = "«type.generateTypeHash»";

«generateAccessorDeclarations()»
«generateEventAccessorDefinitions»
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import org.eclipse.fordiac.ide.model.libraryElement.LibraryElement
import org.eclipse.fordiac.ide.model.libraryElement.LibraryElementPackage
import org.eclipse.fordiac.ide.model.value.StringValueConverter


import static extension org.eclipse.emf.ecore.util.EcoreUtil.getRootContainer

final class ForteNgExportUtil {
Expand Down Expand Up @@ -135,6 +136,14 @@ final class ForteNgExportUtil {
default: '''«type.generateTypeBasename»_gen.cpp'''
}
}

def static String getHashType() {
return Hasher.getHashType();
}

def static String generateTypeHash(INamedElement type) {
return Hasher.getINamedElementHash(type);
}

def static String generateTypeInclude(INamedElement type) '''«type.generateTypeBasename».h'''

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.eclipse.fordiac.ide.export.forte_ng.util;

import java.util.List;

import org.eclipse.fordiac.ide.model.libraryElement.INamedElement;
import org.eclipse.fordiac.ide.model.libraryElement.LibraryElement;
import org.eclipse.fordiac.ide.model.typelibrary.TypeLibraryManager;

public class Hasher {

public static String getINamedElementHash(final INamedElement type, final String version) {
final List<IHasher> hashers = TypeLibraryManager.listExtensions(
"org.eclipse.fordiac.ide.export.forte_ng.util.LibraryElementHasherExtension", //$NON-NLS-1$
IHasher.class);
if (type instanceof final LibraryElement libelem) {
return hashers.getFirst().getLibraryElementHash(libelem, version);
}
return ""; // TODO error here //$NON-NLS-1$
}

public static String getINamedElementHash(final INamedElement type) {
final List<IHasher> hashers = TypeLibraryManager.listExtensions(
"org.eclipse.fordiac.ide.export.forte_ng.util.LibraryElementHasherExtension", //$NON-NLS-1$
IHasher.class);
if (type instanceof final LibraryElement libelem) {
return hashers.getFirst().getLibraryElementHash(libelem);
}
return ""; // TODO error here //$NON-NLS-1$
}

public static String getHashType() {
final List<IHasher> hashers = TypeLibraryManager.listExtensions(
"org.eclipse.fordiac.ide.export.forte_ng.util.LibraryElementHasherExtension", //$NON-NLS-1$
IHasher.class);
return hashers.getFirst().getHashType();

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.eclipse.fordiac.ide.export.forte_ng.util;

import org.eclipse.fordiac.ide.model.libraryElement.LibraryElement;

public interface IHasher {

String getLibraryElementHash(final LibraryElement libelem, final String version);

String getLibraryElementHash(final LibraryElement libelem);

String getHashType();
}
3 changes: 2 additions & 1 deletion plugins/org.eclipse.fordiac.ide.export/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.fordiac.ide.model,
org.eclipse.fordiac.ide.ui,
org.eclipse.core.resources,
org.eclipse.fordiac.ide.util
org.eclipse.fordiac.ide.util,
org.eclipse.fordiac.ide.structuredtextcore
Bundle-Vendor: Eclipse 4diac
Bundle-ActivationPolicy: lazy
Bundle-Version: 3.0.0.qualifier
Expand Down
Loading