Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lang] Generate the Java code for the casted expression's overriding …
…function. see #767 Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
1 parent
d428004
commit 0a62cdf
Showing
26 changed files
with
1,763 additions
and
1,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
....core/src/io/sarl/lang/scoping/extensions/cast/GeneralCastImplicitlyImportedFeatures.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2018 the original authors or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sarl.lang.scoping.extensions.cast; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Singleton; | ||
|
||
/** Provide static functions related to the casting for primitive types that are not numbers. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.9 | ||
*/ | ||
@Singleton | ||
public class GeneralCastImplicitlyImportedFeatures { | ||
|
||
/** Fill the given list with the implicitly imported features. | ||
* | ||
* @param features the list to fill. | ||
*/ | ||
@SuppressWarnings("static-method") | ||
public void getImportedFeatures(List<Class<?>> features) { | ||
features.add(PrimitiveCastExtensions.class); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
...s/io.sarl.lang.core/src/io/sarl/lang/scoping/extensions/cast/PrimitiveCastExtensions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2018 the original authors or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sarl.lang.scoping.extensions.cast; | ||
|
||
import org.eclipse.xtext.xbase.lib.Inline; | ||
import org.eclipse.xtext.xbase.lib.Pure; | ||
|
||
/** Provide static functions related to the casting of primitives that are not numbers. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.9 | ||
*/ | ||
public final class PrimitiveCastExtensions { | ||
|
||
private PrimitiveCastExtensions() { | ||
// | ||
} | ||
|
||
/** Convert the given value to {@code String}. | ||
* | ||
* @param value a value of {@code boolean} type. | ||
* @return the equivalent value to {@code value} of {@code String} type. | ||
*/ | ||
@Pure | ||
@Inline(value = "$2.toString($1)", imported = Boolean.class) | ||
public static String toString(boolean value) { | ||
return Boolean.toString(value); | ||
} | ||
|
||
/** Convert the given value to {@code String}. | ||
* | ||
* @param value a value of {@code char} type. | ||
* @return the equivalent value to {@code value} of {@code String} type. | ||
*/ | ||
@Pure | ||
@Inline(value = "$2.toString($1)", imported = Character.class) | ||
public static String toString(char value) { | ||
return Character.toString(value); | ||
} | ||
|
||
} |
Oops, something went wrong.