Added a MessagePage class into a new module folder. Also set up module folder compilation, and fixed compile when objects are actually used.

This commit is contained in:
Relintai 2020-12-01 13:47:02 +01:00
parent ca06a248b2
commit 5559b663b5
7 changed files with 128 additions and 4 deletions

View File

@ -89,6 +89,25 @@ for x in sorted(glob.glob("database/*")):
sys.path.remove(tmppath)
sys.modules.pop("detect")
module_list = []
for x in sorted(glob.glob("modules/*")):
if not os.path.isdir(x) or not os.path.exists(x + "/detect.py"):
continue
tmppath = "./" + x
sys.path.insert(0, tmppath)
import detect
if detect.is_active() and detect.can_build():
x = x.replace("modules/", "") # rest of world
x = x.replace("modules\\", "") # win32
module_list += [x]
sys.path.remove(tmppath)
sys.modules.pop("detect")
# Build options
@ -142,6 +161,33 @@ for d in database_list:
sys.path.remove(tmppath)
sys.modules.pop("detect")
for m in module_list:
tmppath = "./modules/" + m
sys.path.insert(0, tmppath)
import detect
env_mod = env_base.Clone()
# Compilation DB requires SCons 3.1.1+.
from SCons import __version__ as scons_raw_version
scons_ver = env_mod._get_major_minor_revision(scons_raw_version)
if scons_ver >= (4, 0, 0):
env_mod.Tool("compilation_db")
env_mod.Alias("compiledb", env.CompilationDatabase())
detect.configure(env_mod)
detect.configure(env)
Export("env_mod")
SConscript("modules/" + m + "/SCsub")
sys.path.remove(tmppath)
sys.modules.pop("detect")
Export("env")
SConscript("core/SCsub")

View File

@ -9,20 +9,19 @@
#define RCPP_OBJECT(m_class, m_inherits) \
private: \
void operator=(const m_class &p_rval) {} \
mutable std::stringName _class_name; \
\
public: \
virtual std::string get_class() const override { \
return std::string(#m_class); \
} \
static _FORCE_INLINE_ void *get_class_ptr_static() { \
static void *get_class_ptr_static() { \
static int ptr; \
return &ptr; \
} \
static _FORCE_INLINE_ std::string get_class_static() { \
static std::string get_class_static() { \
return std::string(#m_class); \
} \
static _FORCE_INLINE_ std::string get_parent_class_static() { \
static std::string get_parent_class_static() { \
return m_inherits::get_class_static(); \
} \
static void get_inheritance_list_static(std::list<std::string> *p_inheritance_list) { \
@ -47,6 +46,27 @@ private:
class Object {
public:
virtual std::string get_class() const { return "Object"; }
static void *get_class_ptr_static() {
static int ptr;
return &ptr;
}
static std::string get_class_static() { return "Object"; }
static std::string get_parent_class_static() { return std::string(); }
static void get_inheritance_list_static(std::list<std::string> *p_inheritance_list) { p_inheritance_list->push_back("Object"); }
virtual bool is_class(const std::string &p_class) const { return (p_class == "Object"); }
virtual bool is_class_ptr(void *p_ptr) const { return get_class_ptr_static() == p_ptr; }
static void get_valid_parents_static(std::list<std::string> *p_parents) {}
static void _get_valid_parents_static(std::list<std::string> *p_parents) {}
//dbconnection
//setting object?
//FileCache? -> set it to the global singleton by default?
Object();
virtual ~Object();
};

View File

@ -7,6 +7,8 @@
#include "rdn_application.h"
#include "modules/message_page/message_page.h"
#define MAIN_CLASS RDNApplication
int main(int argc, char **argv) {
@ -34,6 +36,10 @@ int main(int argc, char **argv) {
HTTPServer *server = new HTTPServer();
MessagePage *mp = new MessagePage();
printf("%s\n", mp->get_class().c_str());
server->port = 8080;
server->initialize();
server->main_loop();
@ -41,6 +47,7 @@ int main(int argc, char **argv) {
delete server;
delete app;
delete file_cache;
delete mp;
return 0;
}

View File

@ -0,0 +1,11 @@
#!/usr/bin/env python
Import("env_mod")
env_mod.core_sources = []
env_mod.add_source_files(env_mod.core_sources, "*.cpp")
# Build it all as a library
lib = env_mod.add_library("message_page", env_mod.core_sources)
env_mod.Prepend(LIBS=[lib])

View File

@ -0,0 +1,27 @@
import os
import platform
import sys
def is_active():
return True
def get_name():
return "message_page"
def can_build():
return True
def get_opts():
return []
def get_flags():
return []
def configure(env):
pass

View File

View File

@ -0,0 +1,13 @@
#ifndef MESSAGE_PAGE_H
#define MESSAGE_PAGE_H
#include "core/object.h"
class MessagePage : public Object {
RCPP_OBJECT(MessagePage, Object);
public:
};
#endif