Skip to content

Commit

Permalink
add namespace test
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Aug 31, 2024
1 parent 3b963a3 commit 53a8869
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.github.xpenatan.jparser.example.testlib.TestCallbackClass;
import com.github.xpenatan.jparser.example.testlib.TestConstructorClass;
import com.github.xpenatan.jparser.example.testlib.TestMethodClass;
import com.github.xpenatan.jparser.example.testlib.TestNamespaceClass;
import com.github.xpenatan.jparser.example.testlib.TestObjectClass;
import com.github.xpenatan.jparser.example.testlib.TestObjectClassArray;
import com.github.xpenatan.jparser.example.testlib.idl.helper.IDLString;
Expand All @@ -21,6 +22,7 @@ public static boolean test() {
boolean staticMethodTest = testStaticMethodClass();
boolean callbackTest = testCallbackClass();
boolean callbackTestManual = testCallbackClassManual();
boolean namespaceTest = testNamespaceClass();

System.out.println("constructorTest: " + constructorTest);
System.out.println("stringConstructorTest: " + stringConstructorTest);
Expand All @@ -30,8 +32,9 @@ public static boolean test() {
System.out.println("methodTest: " + methodTest);
System.out.println("staticMethodTest: " + staticMethodTest);
System.out.println("callbackTest: " + callbackTest);
System.out.println("namespaceTest: " + namespaceTest);
return constructorTest && stringConstructorTest && attributeTest && staticAttributeTest
&& attributeArrayTest && methodTest && staticMethodTest && callbackTest && callbackTestManual;
&& attributeArrayTest && methodTest && staticMethodTest && callbackTest && callbackTestManual && namespaceTest;
}

private static boolean testConstructorClass() {
Expand Down Expand Up @@ -429,7 +432,6 @@ public short onUnsignedShortCallback(short unsignedShort) {
}

private static boolean testCallbackClassManual() {

{
TestCallbackClass test = new TestCallbackClass();
try {
Expand Down Expand Up @@ -542,4 +544,38 @@ public void internal_onStringCallback(String strValue01) {
}
return true;
}

private static boolean testNamespaceClass() {
{
TestNamespaceClass test = new TestNamespaceClass();
try {
int value = 20;
test.setMethod01Value(value);
if(!(value == test.getMethod01Value())) {
throw new RuntimeException("value == test.getMethod01Value()");
}
} catch(Throwable e) {
e.printStackTrace();
test.dispose();
return false;
}
test.dispose();
}
{
TestNamespaceClass test = new TestNamespaceClass();
try {
int value = 40;
test.set_intValue01(value);
if(!(value == test.get_intValue01())) {
throw new RuntimeException("value == test.get_intValue01()");
}
} catch(Throwable e) {
e.printStackTrace();
test.dispose();
return false;
}
test.dispose();
}
return true;
}
}
8 changes: 8 additions & 0 deletions example/lib/lib-build/src/main/cpp/TestLib.idl
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ interface TestCallbackClass {
void callManualStringCallback(CallbackClassManual callback);
};

[Prefix="TestNamespace::"]
interface TestNamespaceClass {
attribute long intValue01;
void TestNamespaceClass();
void setMethod01Value(long intValue01);
long getMethod01Value();
};

enum TestEnumWithinClass {
"TestEnumClass::e_val"
};
Expand Down
16 changes: 16 additions & 0 deletions example/lib/lib-build/src/main/cpp/source/TestLib/src/TestLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,22 @@ class TestCallbackClass {
};
};


namespace TestNamespace {
class TestNamespaceClass {
private:
public:
int intValue01;

void setMethod01Value(int intValue01) {
this->intValue01 = intValue01;
}
int getMethod01Value() {
return intValue01;
}
};
};

class TestEnumClass {
private:

Expand Down

0 comments on commit 53a8869

Please sign in to comment.