Skip to content

Commit 19cb9e7

Browse files
committed
Added TeaVM stubs to get CI working with the new port
1 parent d6a5930 commit 19cb9e7

53 files changed

Lines changed: 5484 additions & 42 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Ports/JavaScriptPort/src/main/java/com/codename1/impl/html5/ParparVMBootstrap.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
import com.codename1.io.Log;
1010
import com.codename1.system.Lifecycle;
1111
import com.codename1.ui.Display;
12+
import org.teavm.jso.JSBody;
13+
import org.teavm.jso.browser.Window;
14+
import org.teavm.jso.dom.events.Event;
1215

1316
/**
1417
* Bootstrap for ParparVM JavaScript builds.
15-
* This is a minimal bootstrap that doesn't depend on TeaVM JSO classes.
16-
* The browser runtime handles JS interop via parparvm_runtime.js and browser_bridge.js.
18+
* Uses parparvm_runtime.js for JS interop via native method bindings.
1719
*/
1820
public final class ParparVMBootstrap implements Runnable {
1921
private final Lifecycle lifecycle;
@@ -23,20 +25,37 @@ public ParparVMBootstrap(Lifecycle lifecycle) {
2325
}
2426

2527
public static void bootstrap(Lifecycle lifecycle) {
26-
// Note: ImplementationFactory is set by the translated app's static initializers
27-
// For ParparVM, native bindings are provided by parparvm_runtime.js
28+
com.codename1.impl.ImplementationFactory.setInstance(new com.codename1.impl.ImplementationFactory());
2829
ParparVMBootstrap bootstrap = new ParparVMBootstrap(lifecycle);
2930
Display.init(bootstrap);
3031
bootstrap.run();
3132
}
3233

34+
@JSBody(params = {}, script = "window.cn1Initialized = true;")
35+
private static native void setInitialized();
36+
37+
@JSBody(params = {}, script = "window.cn1Started = true;")
38+
private static native void setStarted();
39+
3340
@Override
3441
public void run() {
3542
try {
43+
HTML5Implementation.setMainClass(lifecycle);
44+
dispatchEvent("beforecn1init", 201);
3645
lifecycle.init(this);
46+
setInitialized();
47+
dispatchEvent("aftercn1init", 202);
48+
dispatchEvent("beforecn1start", 203);
3749
lifecycle.start();
50+
setStarted();
51+
dispatchEvent("aftercn1start", 204);
3852
} catch (Throwable t) {
3953
Log.e(t);
4054
}
4155
}
42-
}
56+
57+
private static void dispatchEvent(String type, int code) {
58+
Event evt = HTML5Implementation.createCustomEvent(type, "", code);
59+
Window.current().dispatchEvent(evt);
60+
}
61+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2026 Codename One and contributors.
3+
*/
4+
package org.teavm.jso.classlib.impl.tz;
5+
6+
public class DateTimeZone {
7+
private final String id;
8+
9+
public DateTimeZone(String id) {
10+
this.id = id;
11+
}
12+
13+
public String getID() {
14+
return id;
15+
}
16+
17+
public long getOffset(long instant) {
18+
return 0;
19+
}
20+
21+
public static DateTimeZone forID(String id) {
22+
return new DateTimeZone(id);
23+
}
24+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2026 Codename One and contributors.
3+
*/
4+
package org.teavm.jso.classlib.impl.tz;
5+
6+
import org.teavm.jso.JSBody;
7+
import org.teavm.jso.JSObject;
8+
9+
public final class DateTimeZoneProvider {
10+
private DateTimeZoneProvider() {}
11+
12+
@JSBody(params = {}, script = "return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'")
13+
public static native String detect();
14+
15+
public static DateTimeZone getDefault() {
16+
return new DateTimeZone(detect());
17+
}
18+
19+
@JSBody(params = {}, script = "return true")
20+
public static native boolean timeZoneDetectionEnabled();
21+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2026 Codename One and contributors.
3+
* Licensed under the PolyForm Noncommercial License 1.0.0.
4+
*/
5+
package org.teavm.interop;
6+
7+
import java.lang.annotation.ElementType;
8+
import java.lang.annotation.Retention;
9+
import java.lang.annotation.RetentionPolicy;
10+
import java.lang.annotation.Target;
11+
12+
@Target(ElementType.METHOD)
13+
@Retention(RetentionPolicy.RUNTIME)
14+
public @interface Async {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright (c) 2026 Codename One and contributors.
3+
* Licensed under the PolyForm Noncommercial License 1.0.0.
4+
*/
5+
package org.teavm.interop;
6+
7+
public interface AsyncCallback<T> {
8+
void complete(T result);
9+
void error(Throwable t);
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2026 Codename One and contributors.
3+
* Licensed under the PolyForm Noncommercial License 1.0.0.
4+
*/
5+
package org.teavm.interop;
6+
7+
import java.lang.annotation.ElementType;
8+
import java.lang.annotation.Retention;
9+
import java.lang.annotation.RetentionPolicy;
10+
import java.lang.annotation.Target;
11+
12+
@Target({ElementType.TYPE, ElementType.METHOD})
13+
@Retention(RetentionPolicy.RUNTIME)
14+
public @interface SuppressSyncErrors {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2026 Codename One and contributors.
3+
* Licensed under the PolyForm Noncommercial License 1.0.0.
4+
*/
5+
package org.teavm.interop;
6+
7+
import java.lang.annotation.ElementType;
8+
import java.lang.annotation.Retention;
9+
import java.lang.annotation.RetentionPolicy;
10+
import java.lang.annotation.Target;
11+
12+
@Target(ElementType.METHOD)
13+
@Retention(RetentionPolicy.RUNTIME)
14+
public @interface Sync {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2026 Codename One and contributors.
3+
* Licensed under the PolyForm Noncommercial License 1.0.0.
4+
*/
5+
package org.teavm.jso;
6+
7+
import java.lang.annotation.ElementType;
8+
import java.lang.annotation.Retention;
9+
import java.lang.annotation.RetentionPolicy;
10+
import java.lang.annotation.Target;
11+
12+
@Target(ElementType.METHOD)
13+
@Retention(RetentionPolicy.RUNTIME)
14+
public @interface JSBody {
15+
String[] params() default {};
16+
String script() default "";
17+
boolean module() default false;
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2026 Codename One and contributors.
3+
*/
4+
package org.teavm.jso;
5+
6+
import java.lang.annotation.ElementType;
7+
import java.lang.annotation.Retention;
8+
import java.lang.annotation.RetentionPolicy;
9+
import java.lang.annotation.Target;
10+
11+
/**
12+
* Marker annotation for JSFunctor parameters.
13+
*/
14+
@Target(ElementType.PARAMETER)
15+
@Retention(RetentionPolicy.RUNTIME)
16+
public @interface JSByRef {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2026 Codename One and contributors.
3+
* Licensed under the PolyForm Noncommercial License 1.0.0.
4+
*/
5+
package org.teavm.jso;
6+
7+
import java.lang.annotation.ElementType;
8+
import java.lang.annotation.Retention;
9+
import java.lang.annotation.RetentionPolicy;
10+
import java.lang.annotation.Target;
11+
12+
@Target(ElementType.TYPE)
13+
@Retention(RetentionPolicy.RUNTIME)
14+
public @interface JSFunctor {}

0 commit comments

Comments
 (0)