Skip to content

Commit

Permalink
Add example of JsOptional on a static member
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 577194842
  • Loading branch information
kevinoconnor7 authored and copybara-github committed Oct 27, 2023
1 parent 2854f1d commit 1409d05
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public void method1(int i1, @JsOptional Double d, @JsOptional Integer i) {}
@JsMethod
public void method2(String s1, @JsOptional Double d, Boolean... i) {}

@JsMethod
public static void staticMethod1(int i1, @JsOptional Double d, @JsOptional Integer i) {}

@JsMethod
public static void staticMethod2(String s1, @JsOptional Double d, Boolean... i) {}

@JsFunction
interface Function {
Object f1(@JsOptional String s, Object... args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ class Main extends j_l_Object {
method2(/** ?string */ s1, /** ?number= */ d, .../** ...?boolean */ i) {
$Arrays.$stampType(i, Boolean, 1);
}

static staticMethod1(/** number */ i1, /** ?number= */ d, /** Integer= */ i) {
Main.$clinit();
}

static staticMethod2(/** ?string */ s1, /** ?number= */ d, .../** ...?boolean */ i) {
Main.$clinit();
$Arrays.$stampType(i, Boolean, 1);
}
/** @nodts */
$ctor__jsoptional_Main__java_lang_String__void(/** ?string */ a) {
this.$ctor__java_lang_Object__void();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
[d] => [d] "d"
[i] => [i] "i"
[{}] => [$Arrays.$stampType(i, Boolean, 1);] "jsoptional.Main.method2"
[staticMethod1] => [staticMethod1]
[i1] => [i1] "i1"
[d] => [d] "d"
[i] => [i] "i"
[{}] => [Main.$clinit();] "jsoptional.Main.staticMethod1"
[staticMethod2] => [staticMethod2]
[s1] => [s1] "s1"
[d] => [d] "d"
[i] => [i] "i"
[{}] => [Main.$clinit();] "jsoptional.Main.staticMethod2"
[{}] => [$Arrays.$stampType(i, Boolean, 1);] "jsoptional.Main.staticMethod2"
[Main] => [$ctor__jsoptional_Main__java_lang_String__void]
[a] => [a] "a"
[{}] => [this.$ctor__java_lang_Object__void();] "jsoptional.Main.<init>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
#import <Foundation/NSObjCRuntime.h>

@class J2ktJsoptionalMain;
@class J2ktJsoptionalMainCompanion;
@class NSString;

NS_ASSUME_NONNULL_BEGIN

@compatibility_alias JsoptionalMain J2ktJsoptionalMain;

@compatibility_alias JsoptionalMainCompanion J2ktJsoptionalMainCompanion;

NS_INLINE J2ktJsoptionalMain* create_JsoptionalMain_initWithNSString_(NSString* _Nullable a) {
return [[J2ktJsoptionalMain alloc] initWithNSString:a];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import kotlin.String
import kotlin.Suppress
import kotlin.experimental.ExperimentalObjCName
import kotlin.jvm.JvmField
import kotlin.jvm.JvmStatic
import kotlin.native.ObjCName

@ObjCName("J2ktJsoptionalMain", exact = true)
Expand Down Expand Up @@ -77,6 +78,29 @@ open class Main {
@ObjCName("withJsoptionalMain_Function") @JsOptional f: Main.Function?
) {}

@ObjCName("J2ktJsoptionalMainCompanion", exact = true)
companion object {
@JvmStatic
@ObjCName("staticMethod1")
@JsMethod
fun staticMethod1(
@ObjCName("withInt") i1: Int,
@ObjCName("withJavaLangDouble") @JsOptional d: Double?,
@ObjCName("withJavaLangInteger") @JsOptional i: Int?
) {}

@JvmStatic
@ObjCName("staticMethod2")
@JsMethod
fun staticMethod2(
@ObjCName("withNSString") s1: String?,
@ObjCName("withJavaLangDouble") @JsOptional d: Double?,
vararg @ObjCName("withJavaLangBooleanArray") i: Boolean?
) {
val i_1: Array<Boolean?>? = i as Array<Boolean?>?
}
}

@JsFunction
fun interface Function {
@ObjCName("f1")
Expand Down
Loading

0 comments on commit 1409d05

Please sign in to comment.