Skip to content

Commit

Permalink
add IDLStringView
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Aug 11, 2024
1 parent e5ca25c commit fe1d438
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
39 changes: 39 additions & 0 deletions jParser/base/src/main/java/idl/helper/IDLStringView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package idl.helper;

import idl.IDLBase;

public class IDLStringView extends IDLBase {

public static IDLStringView TMP_EMPTY_1 = new IDLStringView((byte)0, '0');

public static IDLStringView TMP_1 = new IDLStringView();
public static IDLStringView TMP_2 = new IDLStringView();

public static void disposeTEMP() {
TMP_1.dispose();
TMP_2.dispose();
}

public IDLStringView() {
}

public IDLStringView(byte b, char c) {}

public String data() {
String text = dataNATIVE(getCPointer());
return text;
}

/*[-JNI;-NATIVE]
IDLStringView* nativeObject = (IDLStringView*)this_addr;
const char* str = nativeObject->data();
jstring jstrBuf = env->NewStringUTF(str);
return jstrBuf;
*/
/*[-TEAVM;-NATIVE]
var jsObj = [MODULE].wrapPointer(this_addr, [MODULE].IDLStringView);
var returnedJSObj = jsObj.data();
return returnedJSObj;
*/
private static native String dataNATIVE(long this_addr);
}
1 change: 1 addition & 0 deletions jParser/base/src/main/resources/IDLHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdint.h> // intptr_t

typedef std::string IDLString;
typedef std::string_view IDLStringView;

class IDLBoolArray {
private:
Expand Down
8 changes: 8 additions & 0 deletions jParser/base/src/main/resources/IDLHelper.idl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ interface IDLString {
[Const] DOMString c_str();
};

interface IDLStringView {
void IDLStringView([Const] DOMString text);
void IDLStringView([Const] DOMString text, long size);
long size();
byte at(long index);
[Const] DOMString data();
};

interface IDLBoolArray {
void IDLBoolArray(long size);
void resize(long size);
Expand Down

0 comments on commit fe1d438

Please sign in to comment.