Refactor publicity system

This commit is contained in:
2026-05-13 05:48:59 +02:00
parent e416af3403
commit c1cb9bd7bf
9 changed files with 49 additions and 44 deletions
+6 -6
View File
@@ -2,7 +2,7 @@ use <super::task>;
use <super::logger>;
use <super::event>;
public class Application {
pub class Application {
String name;
Vec<task::Task> tasks;
@@ -13,7 +13,7 @@ public class Application {
bool running;
i32 ticks;
public constructor(str* name) {
pub constructor(str* name) {
self.name = name.to_string();
self.tasks = new Vec();
@@ -25,7 +25,7 @@ public class Application {
self.ticks = 0;
}
public void boot(self mut*) {
pub void boot(self mut*) {
self.logger.info("booting application");
self.running = true;
@@ -33,7 +33,7 @@ public class Application {
self.emit(event::Event::Startup);
}
public void run(self mut*) {
pub void run(self mut*) {
while(self.running) {
self.tick();
@@ -55,7 +55,7 @@ public class Application {
println!("tasks: {}", self.tasks.len());
}
public void shutdown(self mut*) {
pub void shutdown(self mut*) {
self.emit(event::Event::Shutdown);
self.logger.warning("shutdown");
@@ -63,7 +63,7 @@ public class Application {
self.running = false;
}
public void register_plugin(self mut*, String name) {
pub void register_plugin(self mut*, String name) {
self.plugins.push(name.clone());
self.emit(event::Event::PluginLoaded(name));
+1 -1
View File
@@ -1,4 +1,4 @@
public enum Event {
pub enum Event {
Startup,
Shutdown,
TaskExecuted(String),
+7 -7
View File
@@ -1,10 +1,10 @@
use <std::fmt>;
public trait TestLogging<T: fmt::Display>: fmt::Display {
pub trait TestLogging<T: fmt::Display>: fmt::Display {
String get();
}
public enum LogLevel {
pub enum LogLevel {
Info,
Warning,
Error,
@@ -28,22 +28,22 @@ impl fmt::Display for LogLevel {
}
}
public class Logger {
pub class Logger {
String prefix;
public constructor(str* prefix) {
pub constructor(str* prefix) {
self.prefix = prefix.to_string();
}
public void info(self*, str* message) {
pub void info(self*, str* message) {
self.log(LogLevel::Info, message);
}
public void warning(self*, str* message) {
pub void warning(self*, str* message) {
self.log(LogLevel::Warning, message);
}
public void error(self*, str* message) {
pub void error(self*, str* message) {
self.log(LogLevel::Error, message);
}
+6 -6
View File
@@ -1,16 +1,16 @@
public struct PluginInfo {
public String name,
public String version,
pub struct PluginInfo {
pub String name,
pub String version,
}
public class PluginRegistry<T> {
pub class PluginRegistry<T> {
T plugins;
public constructor(T plugins) {
pub constructor(T plugins) {
self.plugins = plugins;
}
public T plugins(self) {
pub T plugins(self) {
return self.plugins;
}
}
+6 -6
View File
@@ -1,17 +1,17 @@
public enum TaskState {
pub enum TaskState {
Pending,
Running,
Finished,
Failed,
}
public struct Task {
public String name,
public TaskState state,
public i32 executions,
pub struct Task {
pub String name,
pub TaskState state,
pub i32 executions,
}
public Task create_task(str* name) {
pub Task create_task(str* name) {
return Task {
name: name.to_string(),
state: TaskState::Pending,