Fixed problems
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
use <collections::list>;
|
||||
use <core::task>;
|
||||
use <core::logger>;
|
||||
use <core::event>;
|
||||
use <super::task>;
|
||||
use <super::logger>;
|
||||
use <super::event>;
|
||||
|
||||
public class Application {
|
||||
String name;
|
||||
|
||||
list::List<task::Task> tasks;
|
||||
list::List<String> plugins;
|
||||
Vec<task::Task> tasks;
|
||||
Vec<String> plugins;
|
||||
|
||||
logger::Logger logger;
|
||||
|
||||
@@ -17,8 +16,8 @@ public class Application {
|
||||
public constructor(String name) {
|
||||
self.name = name;
|
||||
|
||||
self.tasks = new list::List();
|
||||
self.plugins = new list::List();
|
||||
self.tasks = new Vec();
|
||||
self.plugins = new Vec();
|
||||
|
||||
self.logger = new logger::Logger("app");
|
||||
|
||||
@@ -65,7 +64,7 @@ public class Application {
|
||||
}
|
||||
|
||||
public void register_plugin(self mut*, String name) {
|
||||
self.plugins.push(name);
|
||||
self.plugins.push(name.clone());
|
||||
|
||||
self.emit(event::Event::PluginLoaded(name));
|
||||
}
|
||||
@@ -89,7 +88,7 @@ public class Application {
|
||||
}
|
||||
|
||||
event::Event::Error(message) => {
|
||||
self.logger.error(message);
|
||||
self.logger.error(&message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,23 +7,23 @@ public enum LogLevel {
|
||||
public class Logger {
|
||||
String prefix;
|
||||
|
||||
public constructor(String prefix) {
|
||||
self.prefix = prefix;
|
||||
public constructor(str* prefix) {
|
||||
self.prefix = prefix.to_string();
|
||||
}
|
||||
|
||||
public void info(self*, String message) {
|
||||
public void info(self*, str* message) {
|
||||
self.log(LogLevel::Info, message);
|
||||
}
|
||||
|
||||
public void warning(self*, String message) {
|
||||
public void warning(self*, str* message) {
|
||||
self.log(LogLevel::Warning, message);
|
||||
}
|
||||
|
||||
public void error(self*, String message) {
|
||||
public void error(self*, str* message) {
|
||||
self.log(LogLevel::Error, message);
|
||||
}
|
||||
|
||||
void log(self*, LogLevel level, String message) {
|
||||
void log(self*, LogLevel level, str* message) {
|
||||
match(level) {
|
||||
LogLevel::Info => {
|
||||
println!("[INFO] {} {}", self.prefix, message);
|
||||
|
||||
@@ -11,9 +11,9 @@ public struct Task {
|
||||
public i32 executions,
|
||||
}
|
||||
|
||||
public Task create_task(String name) {
|
||||
public Task create_task(str* name) {
|
||||
return Task {
|
||||
name: name,
|
||||
name: name.to_string(),
|
||||
state: TaskState::Pending,
|
||||
executions: 0,
|
||||
};
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
mod core;
|
||||
|
||||
use <core::app>;
|
||||
use <plugins::greeting>;
|
||||
use <plugins::statistics>;
|
||||
// use <plugins::greeting>;
|
||||
// use <plugins::statistics>;
|
||||
|
||||
i32 main() {
|
||||
void main() {
|
||||
var app = new app::Application("mist-app");
|
||||
|
||||
greeting::register(&mut app);
|
||||
statistics::register(&mut app);
|
||||
// greeting::register(&mut app);
|
||||
// statistics::register(&mut app);
|
||||
|
||||
app.boot();
|
||||
app.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
public class MyClass {
|
||||
String message;
|
||||
|
||||
public constructor(str* name) {
|
||||
self.message = format!("Hello {}!", name);
|
||||
}
|
||||
|
||||
public void greet(self*) {
|
||||
println!("{}", self.message);
|
||||
}
|
||||
}
|
||||
|
||||
public enum MyEnum {
|
||||
Named,
|
||||
Tuple(i32, String),
|
||||
Struct { i32 x }
|
||||
}
|
||||
Reference in New Issue
Block a user