Skip to content

Instantly share code, notes, and snippets.

@biochimia
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biochimia/809c1757ada7d3b17dab to your computer and use it in GitHub Desktop.
Save biochimia/809c1757ada7d3b17dab to your computer and use it in GitHub Desktop.
diff --git a/StdLib/Core/UnoCore/Source/Uno/Platform2/Application.uno b/StdLib/Core/UnoCore/Source/Uno/Platform2/Application.uno
index 248fb38..1a4d708 100644
--- a/StdLib/Core/UnoCore/Source/Uno/Platform2/Application.uno
+++ b/StdLib/Core/UnoCore/Source/Uno/Platform2/Application.uno
@@ -37,32 +37,31 @@ namespace Uno.Platform2
[TargetSpecificImplementation] private static void DidEnterBackground() { }
[TargetSpecificImplementation] private static void WillTerminate() { }
[InvokedFromNativeCode]
private static void Start()
{
assert State == ApplicationState.Uninitialized;
- _Start();
+ // NOTE: Ressurrect (Android) shouldn't need to call these.
+ Uno.Runtime.Runtime.InitializeResourceSystem();
+ Uno.Runtime.Runtime.RunStaticInitializers();
State = ApplicationState.Background;
DidStart();
ApplicationStateTransitionHandler handler = Started;
if (handler != null)
handler(State);
assert State == ApplicationState.Background;
}
- [TargetSpecificImplementation]
- private extern static void _Start();
-
[InvokedFromNativeCode]
private static void EnterForeground()
{
switch (State)
{
case ApplicationState.Terminating:
debug_log "EnterForeground() called on terminating application";
return;
diff --git a/StdLib/Core/UnoCore/Source/Uno/Platform2/DefaultSetup.uno b/StdLib/Core/UnoCore/Source/Uno/Platform2/DefaultSetup.uno
index 0b7132d..f453b09 100644
--- a/StdLib/Core/UnoCore/Source/Uno/Platform2/DefaultSetup.uno
+++ b/StdLib/Core/UnoCore/Source/Uno/Platform2/DefaultSetup.uno
@@ -23,34 +23,42 @@ namespace Uno.Platform2
RootView.TouchDown += OnTouchDown;
RootView.TouchMove += OnTouchMove;
RootView.TouchUp += OnTouchUp;
if (defined(GC))
RootView.DidPauseRendering += OnDidPauseRendering;
}
+ public static Uno.Application CurrentApplication { get; private set; }
+
private static void OnStarted(ApplicationState state)
{
- Uno.Application.Current.Load();
+ // NOTE: CurrentApplication gets set after constructor completes.
+ // In the legacy setup Uno.Application.Current is set first
+ // thing in the base constructor.
+ CurrentApplication = Uno.Runtime.Runtime.InstantiateMainClass();
+ CurrentApplication.Load();
}
private static void OnTerminating(ApplicationState state)
{
Application.Started -= OnStarted;
Application.EnteringForeground -= OnEnterForeground;
Application.EnteringInteractive -= OnEnterInteractive;
Application.ExitedInteractive -= OnExitInteractive;
Application.EnteringBackground -= OnEnterBackground;
Application.Terminating -= OnTerminating;
Application.KeyDown -= OnKeyDown;
Application.KeyUp -= OnKeyUp;
RootView.HandleReady -= OnViewHandleReady;
RootView = null;
+
+ CurrentApplication = null;
}
public static bool _forceDrawNextFrame = false;
public static GraphicsView RootView { get; private set; }
private static void OnEnterForeground(ApplicationState state)
{
Display.MainDisplay.FramesPerSecond = 20;
@@ -86,85 +94,72 @@ namespace Uno.Platform2
private static void OnDisplayFrameChanged(object sender, Uno.EventArgs args)
{
RootView.Frame = (sender as Display).Frame;
_forceDrawNextFrame = true;
}
private static void OnViewFrameChanged(object sender, Uno.EventArgs args)
{
- var app = Uno.Application.Current;
-
- app.GraphicsContext.UpdateBackbuffer();
- app.Window.OnResized(Uno.EventArgs.Empty);
+ CurrentApplication.GraphicsContext.UpdateBackbuffer();
+ CurrentApplication.Window.OnResized(Uno.EventArgs.Empty);
_forceDrawNextFrame = true;
}
[ExportCondition("GC")]
private static void OnDidPauseRendering(object sender, Uno.EventArgs args)
{
extern "uGarbageCollect()";
}
private static void OnUpdate(object sender, TimerEventArgs args)
{
- var app = Uno.Application.Current;
-
- app.FrameTime = args.LastTickTimestamp + args.TickDuration;
- app.FrameInterval = args.TickDuration;
- app.Update();
+ CurrentApplication.FrameTime = args.LastTickTimestamp + args.TickDuration;
+ CurrentApplication.FrameInterval = args.TickDuration;
+ CurrentApplication.Update();
- if (app.DrawNextFrame || _forceDrawNextFrame)
+ if (CurrentApplication.DrawNextFrame || _forceDrawNextFrame)
{
RootView.Draw += OnDraw;
_forceDrawNextFrame = false;
}
}
private static void OnDraw(object sender, TimerEventArgs args)
{
- var app = Uno.Application.Current;
- var gc = app.GraphicsContext;
+ var gc = CurrentApplication.GraphicsContext;
gc.SetRenderTarget(gc.Backbuffer);
- gc.Clear(app.ClearColor, app.ClearDepth);
- app.Draw();
+ gc.Clear(CurrentApplication.ClearColor, CurrentApplication.ClearDepth);
+ CurrentApplication.Draw();
RootView.Draw -= OnDraw;
}
private static void OnTouchDown(object sender, TouchEventArgs args)
{
- var app = Uno.Application.Current;
-
var pointerArgs = new Uno.Platform.PointerEventArgs(Uno.Platform.PointerType.Touch, 0, args.IsPrimary, args.Position, args.PointerID, 0, float2(), Uno.Platform.WheelDeltaMode.DeltaPixel);
- app.Window.OnPointerPressed(pointerArgs);
+ CurrentApplication.Window.OnPointerPressed(pointerArgs);
}
private static void OnTouchMove(object sender, TouchEventArgs args)
{
- var app = Uno.Application.Current;
-
var pointerArgs = new Uno.Platform.PointerEventArgs(Uno.Platform.PointerType.Touch, 0, args.IsPrimary, args.Position, args.PointerID, 0, float2(), Uno.Platform.WheelDeltaMode.DeltaPixel);
- app.Window.OnPointerMoved(pointerArgs);
+ CurrentApplication.Window.OnPointerMoved(pointerArgs);
}
private static void OnTouchUp(object sender, TouchEventArgs args)
{
- var app = Uno.Application.Current;
-
var pointerArgs = new Uno.Platform.PointerEventArgs(Uno.Platform.PointerType.Touch, 0, args.IsPrimary, args.Position, args.PointerID, 0, float2(), Uno.Platform.WheelDeltaMode.DeltaPixel);
- app.Window.OnPointerReleased(pointerArgs);
+ CurrentApplication.Window.OnPointerReleased(pointerArgs);
}
private static void OnKeyDown(object sender, Uno.Platform.KeyEventArgs args)
{
- var app = Uno.Application.Current;
- app.Window.OnKeyPressed(args);
+ CurrentApplication.Window.OnKeyPressed(args);
}
private static void OnKeyUp(object sender, Uno.Platform.KeyEventArgs args)
{
- var app = Uno.Application.Current;
- app.Window.OnKeyReleased(args);
+ CurrentApplication.Window.OnKeyReleased(args);
}
}
}
diff --git a/StdLib/Core/UnoCore/Source/Uno/Runtime/Runtime.uno b/StdLib/Core/UnoCore/Source/Uno/Runtime/Runtime.uno
new file mode 100644
index 0000000..b0d1382
--- /dev/null
+++ b/StdLib/Core/UnoCore/Source/Uno/Runtime/Runtime.uno
@@ -0,0 +1,14 @@
+namespace Uno.Runtime
+{
+ internal class Runtime
+ {
+ internal static void InitializeResourceSystem() { /* Compiler-generated */ }
+ internal static void RunStaticInitializers() { /* Compiler-generated */ }
+
+ internal static Uno.Application InstantiateMainClass()
+ {
+ /* Compiler-generated */
+ return null;
+ }
+ }
+}
diff --git a/StdLib/Core/UnoCore/Targets/CPlusPlus/Source/Uno.Platform2.cpp.uxl b/StdLib/Core/UnoCore/Targets/CPlusPlus/Source/Uno.Platform2.cpp.uxl
index a1e0595..e0ce8bd 100644
--- a/StdLib/Core/UnoCore/Targets/CPlusPlus/Source/Uno.Platform2.cpp.uxl
+++ b/StdLib/Core/UnoCore/Targets/CPlusPlus/Source/Uno.Platform2.cpp.uxl
@@ -50,21 +50,16 @@
<Require Entity="Uno.Platform2.TextInputView.OnReturnPressed()" />
<Require Entity="Uno.Platform2.TextInputView.SetTextFromNativeEvent(string)" />
</Template>
<Type Name="Uno.Platform2.Application">
<Require Header.Include="Uno/Platform2.h" />
<Require Source.Include="@{Uno.Application:Include}" />
- <Method Signature="_Start()">
- <Require Source.Declaration="void uStartApp();" />
- <Expression>::uStartApp()</Expression>
- </Method>
-
<Method Signature="DidEnterForeground()">
</Method>
<Method Signature="DidEnterInteractive()">
</Method>
<Method Signature="DidExitInteractive()">
</Method>
<Method Signature="DidEnterBackground()">
</Method>
diff --git a/StdLib/Core/UnoCore/UnoCore.unoproj b/StdLib/Core/UnoCore/UnoCore.unoproj
index 442c8db..0922160 100644
--- a/StdLib/Core/UnoCore/UnoCore.unoproj
+++ b/StdLib/Core/UnoCore/UnoCore.unoproj
@@ -353,16 +353,17 @@
<SourceFile Name="Source/Uno/Runtime/Implementation/ShaderBackends/OpenGL/GLException.uno" />
<SourceFile Name="Source/Uno/Runtime/Implementation/ShaderBackends/OpenGL/GLHelpers.uno" />
<SourceFile Name="Source/Uno/Runtime/Implementation/ShaderBackends/OpenGL/GLInterop.uno" />
<SourceFile Name="Source/Uno/Runtime/Implementation/ShaderBackends/OpenGL/GLProgram.uno" />
<ExtensionsFile Name="Source/Uno/Runtime/Implementation/TextEncodingImpl.cpp.uxl" />
<ExtensionsFile Name="Source/Uno/Runtime/Implementation/TextEncodingImpl.cs.uxl" />
<ExtensionsFile Name="Source/Uno/Runtime/Implementation/TextEncodingImpl.js.uxl" />
<SourceFile Name="Source/Uno/Runtime/Implementation/TextEncodingImpl.uno" />
+ <SourceFile Name="Source/Uno/Runtime/Runtime.uno" />
<ExtensionsFile Name="Source/Uno/SByte.cpp.uxl" />
<ExtensionsFile Name="Source/Uno/SByte.js.uxl" />
<SourceFile Name="Source/Uno/SByte.uno" />
<SourceFile Name="Source/Uno/SByte2.uno" />
<SourceFile Name="Source/Uno/SByte4.uno" />
<ExtensionsFile Name="Source/Uno/Short.cpp.uxl" />
<ExtensionsFile Name="Source/Uno/Short.js.uxl" />
<SourceFile Name="Source/Uno/Short.uno" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment