-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
316 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ out/ | |
*.ini | ||
**/webapp/** | ||
**/example-core/src/** | ||
**/example-desktop/src/** |
4 changes: 2 additions & 2 deletions
4
...atan/jparser/example/NormalClassTest.java → ...xpenatan/jparser/example/NormalClass.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
9 changes: 9 additions & 0 deletions
9
example/example-base/src/main/java/com/github/xpenatan/jparser/example/ParentClass.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,9 @@ | ||
package com.github.xpenatan.jparser.example; | ||
|
||
public class ParentClass { | ||
/*[-C++;-NATIVE] | ||
#include "ParentClass.h" | ||
*/ | ||
|
||
|
||
} |
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,6 @@ | ||
#include "NormalClass.h" | ||
|
||
int NormalClass::addIntValue(int a, int b) | ||
{ | ||
return a + b; | ||
} |
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,10 @@ | ||
#ifndef NORMALCLASS_H | ||
#define NORMALCLASS_H | ||
|
||
class NormalClass | ||
{ | ||
public: | ||
int addIntValue(int a, int b); | ||
}; | ||
|
||
#endif //NORMALCLASS_H |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
#include "ParentClass.h" | ||
|
||
float ParentClass::addFloatValue(float a, float b) | ||
{ | ||
return a + b; | ||
} | ||
|
||
bool ParentClass::invertBoolean(bool value) | ||
{ | ||
return !value; | ||
} |
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,11 @@ | ||
#ifndef PARENTCLASS_H | ||
#define PARENTCLASS_H | ||
|
||
class ParentClass | ||
{ | ||
public: | ||
float addFloatValue(float a, float b); | ||
bool invertBoolean(bool value); | ||
}; | ||
|
||
#endif //PARENTCLASS_H |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
interface ParentClassTest { | ||
float getFloatValue(); | ||
interface ParentClass { | ||
float addFloatValue(float a, float b); | ||
boolean invertBoolean(boolean value); | ||
}; | ||
|
||
interface NormalClassTest { | ||
long getIntValue(); | ||
boolean getBoolValue(float floatValue); | ||
interface NormalClass { | ||
void NormalClassTest(); | ||
long addIntValue(long a, long b); | ||
}; | ||
NormalClassTest implements ParentClassTest; | ||
NormalClass implements ParentClass; |
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,36 @@ | ||
apply plugin: "java" | ||
|
||
group = project.groupId | ||
version = "1.0.0" | ||
|
||
def module_name = "example-core" | ||
|
||
dependencies { | ||
testImplementation project(":jParser:loader") | ||
testImplementation project(":example:example-core") | ||
testImplementation "junit:junit:$project.jUnitVersion" | ||
} | ||
|
||
clean.doFirst { | ||
def srcPath = projectDir.toString() + "/src/main/" | ||
project.delete(files(srcPath)) | ||
} | ||
|
||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
artifactId = module_name | ||
from components.java | ||
} | ||
} | ||
} | ||
|
||
tasks.register("prepareTest", GradleBuild) { | ||
tasks = [ | ||
":example:example-build:clean", | ||
":example:example-core:clean", | ||
":example:example-build:generateNativeProject", | ||
"compileTestJava" | ||
] | ||
} | ||
test.dependsOn "prepareTest" |
47 changes: 47 additions & 0 deletions
47
...le/example-desktop/src/test/java/com/github/xpenatan/jparser/example/NormalClassTest.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,47 @@ | ||
package com.github.xpenatan.jparser.example; | ||
|
||
import com.github.xpenatan.jparser.loader.JParserLibraryLoader; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class NormalClassTest { | ||
|
||
@BeforeClass | ||
public static void setUp() throws Exception { | ||
String libDir = "src/main/resources/example-test-natives.jar"; | ||
new JParserLibraryLoader(libDir).load("example-test"); | ||
} | ||
|
||
@Test | ||
public void test_add_int() { | ||
NormalClass normalClass = new NormalClass(); | ||
int ret = normalClass.addIntValue(10, 10); | ||
assertEquals(20, ret); | ||
} | ||
|
||
@Test | ||
public void test_add_float() { | ||
NormalClass normalClass = new NormalClass(); | ||
float ret = normalClass.addFloatValue(10.3f, 10.3f); | ||
assertEquals(20.6, ret, 1.0f); | ||
} | ||
|
||
@Test | ||
public void test_invert_boolean_should_be_false() { | ||
NormalClass normalClass = new NormalClass(); | ||
boolean ret = normalClass.invertBoolean(true); | ||
assertFalse(ret); | ||
} | ||
|
||
@Test | ||
public void test_invert_boolean_should_be_true() { | ||
NormalClass normalClass = new NormalClass(); | ||
boolean ret = normalClass.invertBoolean(false); | ||
assertTrue(ret); | ||
} | ||
|
||
} | ||
|
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
Oops, something went wrong.