Skip to content

Commit dbefb18

Browse files
committed
stuff
1 parent 4e99af5 commit dbefb18

10 files changed

Lines changed: 324 additions & 223 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
11
#include "android_globals.hxx"
2+
3+
void android_globals_wrapper::create(ANativeActivity* native_activity)
4+
{
5+
utki::assert(native_activity, SL);
6+
utki::assert(!native_activity->instance, SL);
7+
8+
utki::assert(!android_globals_wrapper::native_activity, SL);
9+
10+
try {
11+
android_globals_wrapper::native_activity = native_activity;
12+
13+
native_activity->instance = new android_globals_wrapper();
14+
} catch (...) {
15+
android_globals_wrapper::native_activity = nullptr;
16+
throw;
17+
}
18+
}
19+
20+
void android_globals_wrapper::destroy()
21+
{
22+
utki::assert(android_globals_wrapper::native_activity, SL);
23+
utki::assert(android_globals_wrapper::native_activity->instance, SL);
24+
25+
auto wrapper = static_cast<android_globals_wrapper*>(android_globals_wrapper::native_activity->instance);
26+
delete wrapper;
27+
28+
android_globals_wrapper::native_activity->instance = nullptr;
29+
android_globals_wrapper::native_activity = nullptr;
30+
}
Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
11
#pragma once
22

3+
#include <android/asset_manager.h>
4+
#include <android/configuration.h>
35
#include <android/native_activity.h>
6+
#include <android/window.h>
7+
#include <nitki/queue.hpp>
8+
#include <utki/debug.hpp>
49

510
#include "../../application.hpp"
611

12+
#include "java_functions.hxx"
13+
714
namespace {
815
struct android_globals_wrapper final {
9-
static ANativeActivity* native_activity = nullptr;
16+
static ANativeActivity* native_activity = nullptr;
17+
18+
static void create(ANativeActivity* native_activity);
19+
static void destroy();
1020

11-
// static void android_globals_wrapper::
21+
static android_globals_wrapper& get()
22+
{
23+
utki::assert(native_activity, SL);
24+
utki::assert(native_activity->instance, SL);
25+
return
26+
}
1227

13-
static android_globals_wrapper& get(){
14-
utki::assert(native_activity, SL);
15-
utki::assert(native_activity->instance, SL);
16-
}
28+
java_functions_wrapper java_functions;
29+
30+
nitki::queue ui_queue;
1731

1832
std::unique_ptr<ruisapp::application> app;
33+
34+
ANativeWindow* android_window = nullptr;
1935
};
2036
} // namespace
37+
38+
namespace {
39+
inline android_globals_wrapper& get_glob()
40+
{
41+
auto na = android_globals_wrapper::native_activity;
42+
utki::assert(na, SL);
43+
utki::assert(na->instance, SL);
44+
return *static_cast<android_globals_wrapper*>(na->instance);
45+
}
46+
} // namespace

src/ruisapp/glue/android/application.hxx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,33 @@
22

33
#include <utki/destructable.hpp>
44

5+
#include "../../application.hpp"
6+
#include "../../window.hpp"
7+
8+
namespace {
9+
class app_window : public ruisapp::window
10+
{
11+
public:
12+
};
13+
} // namespace
14+
515
namespace {
616
class application_glue : public utki::destructable
717
{
818
public:
919
};
1020
} // namespace
21+
22+
namespace {
23+
inline application_glue& get_glue(ruisapp::application& app)
24+
{
25+
return static_cast<application_glue&>(app.pimpl.get());
26+
}
27+
} // namespace
28+
29+
namespace {
30+
inline application_glue& get_glue()
31+
{
32+
return get_glue(ruisapp::application::inst());
33+
}
34+
} // namespace

src/ruisapp/glue/android/display.cxx

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/ruisapp/glue/android/display.hxx

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)