diff options
Diffstat (limited to 'old')
-rw-r--r-- | old/include/luma/main.hh | 87 | ||||
-rw-r--r-- | old/initgfx.cc | 52 | ||||
-rw-r--r-- | old/isvkphysdevvalid.cc | 5 | ||||
-rw-r--r-- | old/setdispsrvproto.cc | 35 | ||||
-rw-r--r-- | old/src/luma/app_t/app_t.cc | 95 | ||||
-rw-r--r-- | old/src/luma/app_t/archstr.cc | 22 | ||||
-rw-r--r-- | old/src/luma/app_t/arghandl.cc | 12 | ||||
-rw-r--r-- | old/src/luma/app_t/dbgmsgf.cc | 6 | ||||
-rw-r--r-- | old/src/luma/app_t/exit.cc | 5 | ||||
-rw-r--r-- | old/src/luma/app_t/getenv.cc | 13 | ||||
-rw-r--r-- | old/src/luma/app_t/kernelstr.cc | 34 | ||||
-rw-r--r-- | old/src/luma/app_t/msgf.cc | 8 | ||||
-rw-r--r-- | old/src/luma/app_t/msgferr.cc | 4 | ||||
-rw-r--r-- | old/src/luma/app_t/msgfout.cc | 4 | ||||
-rw-r--r-- | old/src/luma/app_t/strcmp.cc | 11 | ||||
-rw-r--r-- | old/src/luma/app_t/strcut.cc | 25 | ||||
-rw-r--r-- | old/src/luma/app_t/strlen.cc | 8 | ||||
-rw-r--r-- | old/src/main.cc | 6 | ||||
-rw-r--r-- | old/stdlibsock__gfx__crtwin.cc | 30 | ||||
-rw-r--r-- | old/stdlibsock__gfx__destwin.cc | 4 | ||||
-rw-r--r-- | old/termgfx.cc | 13 |
21 files changed, 340 insertions, 139 deletions
diff --git a/old/include/luma/main.hh b/old/include/luma/main.hh new file mode 100644 index 0000000..1061e10 --- /dev/null +++ b/old/include/luma/main.hh @@ -0,0 +1,87 @@ +# if !defined(LUMA__HEADER__MAIN) +# define LUMA__HEADER__MAIN +# include <cstddef> +// constexpr -> const -> normal +// typedef -> enum class -> class -> operator -> variable -> function +namespace luma { + typedef decltype(nullptr) nullptr_t; // Official way to define nullptr_t + enum class arch_t { + aarch64, + amd64, + ia64, + ppc64, + unknown, + }; + enum class kernel_t { + darwinos, + dragonflybsd, + freebsd, + hurd, + linux, + minix, + netbsd, + openbsd, + unknown, + }; + class app_t { + public: + app_t(int const argc, char const * * argv); + ~app_t(); + private: + bool constexpr static debug = +# if defined(NDEBUG) + false; +# else + true; +# endif + luma::arch_t constexpr static arch = luma::arch_t:: +# if defined(__aarch64__) + aarch64; +# elif (defined(_M_AMD64) || defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(x86_64__)) + amd64; +# elif (defined(_IA64) defined(_M_IA64) || defined(__IA64__) || defined(__ia64__) || defined(__itanium__)) + ia64; +# elif (defined(_ARCH_PPC64) || defined(__powerpc64__) || defined(__PPC64__) || defined(__ppc64__)) + ppc64; +# else + unknown; +# endif + luma::kernel_t constexpr static kernel = luma::kernel_t:: +# if defined(__APPLE__) + darwinos; +# elif defined(__DragonFly__) + dragonflybsd; +# elif defined(__FreeBSD__) + freebsd; +# elif (defined(__GNU__) || defined(__gnu_hurd__)) + hurd; +# elif defined(__linux__) + linux; +# elif defined(__minix) + minix; +# elif defined(__NetBSD__) + netbsd; +# elif defined(__OpenBSD__) + openbsd; +# else + unknown; +# endif + int stderr = 0x0; + int stdout = 0x0; + char const * archstr(luma::arch_t arch) noexcept; + char const * getenv(char const * envvar); + char const * kernelstr(luma::kernel_t kernel) noexcept; + char const * strcut(char const * str,int pos,int len); + int strcmp(char const * lstr,char const * rstr) noexcept; + int strlen(char const * str) noexcept; + void arghandl(char const * arg); + void dbgmsgf(char const * msg); + [[noreturn]] void exit() noexcept; + //template<typename T,typename ... Args> + //void msgf(char const * msg, Args const & ... args); + void msgf(int pipe,char const * buf,std::size_t count); + void msgferr(char const * buf); + void msgfout(char const * buf); + }; +} +# endif diff --git a/old/initgfx.cc b/old/initgfx.cc deleted file mode 100644 index ffaf1e5..0000000 --- a/old/initgfx.cc +++ /dev/null @@ -1,52 +0,0 @@ -# include <luma/main.hh> -# include <vulkan/vulkan.h> -# include <wayland-client.h> -# include <xcb/xcb.h> -void luma::app_t::initgfx() { - this->gfxisinit = true; - // Determine if X should be used or if Wayland is da way. - this->setdispsrvproto(); - if(this->dispsrvproto == this->dispsrvproto_t::x) { - this->dbgmsg("Creating X connection... "); - this->xconn = xcb_connect(nullptr,nullptr); - this->xscrn = xcb_setup_roots_iterator(xcb_get_setup(this->xconn)).data; - this->xwin = xcb_generate_id(this->xconn); - this->dbgmsg("O.K.\n"); - } - else { - this->dbgmsg("Creating Wayland connection... "); - this->wldisp = wl_display_connect(nullptr); - if(this->wldisp == nullptr) { - this->dbgmsg("Error\n"); - } - else { - this->dbgmsg("O.K.\n"); - } - } - // Set data required by Vulkan. - this->vkappinf.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; - this->vkappinf.pApplicationName = "Luma Standard Library"; - this->vkappinf.pEngineName = "Luma Standard Library"; - this->vkinstcrtinf.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - this->vkinstcrtinf.pApplicationInfo = &this->vkappinf; - this->vkinstcrtinf.enabledLayerCount = 0x0; - this->dbgmsg("Creating Vulkan instance... "); - this->vkreslt = vkCreateInstance(&this->vkinstcrtinf,nullptr,&this->vkinst); - if(this->vkreslt == VK_SUCCESS) { - this->dbgmsg("O.K.\n"); - } - else { - this->dbgmsg("Error\n"); - } - int extcount = 0x0; - this->vkexts = std::vector<VkExtensionProperties>(extcount); - ::vkEnumerateInstanceExtensionProperties(nullptr,&extcount,this->vkexts.data()); - //this->dbgmsg(std::basic_string<char_t> {std::to_string(extcount) + " Vulkan extensions supported.\n"}.c_str()); - this->dbgmsg("The following Vulkan extensions are supported:\n"); - for(auto const & ext : this->vkexts) { - this->dbgmsg(ext.extensionName); - } - int devcount = 0x0; - ::vkEnumeratePhysicalDevices(this->vkinst,&devcount,this->vkphysdevs.data()); - //this->dbgmsg(std::basic_string<char> {std::to_string(devcount) + " Vulkan-compatible device(s) found.\n"}.c_str()); -} diff --git a/old/isvkphysdevvalid.cc b/old/isvkphysdevvalid.cc deleted file mode 100644 index 27a169b..0000000 --- a/old/isvkphysdevvalid.cc +++ /dev/null @@ -1,5 +0,0 @@ -# include <luma/main.hh> -# include <vulkan/vulkan.h> -//isVulkanPhysicalDeviceValid -void luma::app_t::isvkphysdevvalid(VkPhysicalDevice & dev) { -} diff --git a/old/setdispsrvproto.cc b/old/setdispsrvproto.cc deleted file mode 100644 index a423ccc..0000000 --- a/old/setdispsrvproto.cc +++ /dev/null @@ -1,35 +0,0 @@ -# include <luma/main.hh> -void luma::app_t::setdispsrvproto() { - this->dispsrvproto = this->dispsrvproto_t::wayland; -# if 0 - char const * envval = this->getenv("LUMA__DISPSRVPROTO"); - if(envval != "") { - if(envval == "x") { - this->dbgmsg("Setting the display server protocol to X.\n"); - this->dispsrvproto = this->dispsrvproto_t::x; - } - else if(envval == "wayland") { - this->dbgmsg("Setting the display server protocol to Wayland.\n"); - this->dispsrvproto = this->dispsrvproto_t::wayland; - } - else { - //std::cerr << "$LUMA__DISPSRVPROTO is set to \"" + envval + "\", which is an unrecognized display server protocol.\n"; - } - } - else { - this->dbgmsg("Getting current display server protocol.\n"); - std::string xdgsesstype = std::getenv("XDG_SESSION_TYPE"); - if(xdgsesstype == "wayland") { - this->dbgmsg("It appears to be Wayland.\n"); - this->dispsrvproto = this->dispsrvproto_t::wayland; - } - else if(xdgsesstype == "x11") { - this->dbgmsg("It appears to be X.\n"); - this->dispsrvproto = this->dispsrvproto_t::x; - } - else { - this->dbgmsg("Error\n"); - } - } -# endif -} diff --git a/old/src/luma/app_t/app_t.cc b/old/src/luma/app_t/app_t.cc new file mode 100644 index 0000000..c650071 --- /dev/null +++ b/old/src/luma/app_t/app_t.cc @@ -0,0 +1,95 @@ +# include <fcntl.h> +# include <iostream> +# include <luma/main.hh> +# include <unistd.h> +luma::app_t::app_t(int const argc,char const * * argv) { + this->stderr = ::open("/dev/stderr",O_WRONLY); + this->stdout = ::open("/dev/stdout",O_WRONLY); + if(argc < 0x2) { + this->msgferr("Missing argument \"file\".\n"); + this->msgferr("Use \"--help\" for help.\n"); + this->exit(); + } + //else { + // for(int i = 0x0;i < argc;++i) { + // this->arghandl(argv[i]); + // } + //} + this->msgfout(this->archstr(this->arch)); + this->msgfout(this->kernelstr(this->kernel)); + if(!::access(argv[0x1],R_OK)) { + int lumafile = ::open(argv[0x1],O_RDONLY); + for(int line = 0x0,pos = 0x0;;++pos) { + char * tok; + ::read(lumafile,&tok,0x1); + this->msgfout("Here?\n"); + std::cout << line << ":" << pos << "=" << "\u000A"; + int pipe = ::open("/dev/stdout",O_WRONLY); + this->msgf(pipe,tok,0x4); + if(this->strcmp(tok,"\u000A") == 0x0) { + ++line; + } + else if(this->strcmp(tok,"\u0061") == 0x0) { + this->msgfout("\'a\' detected!"); + } + } + /* + char const * toks[] = { + "\u0009", // Horizontal Tabulation + "\u000A", // New Line (Nl) + "\u0020", // Space + "\u0023", // Number Sign + "\u0028", // Left Parenthesis + "\u0029", // Right Parenthesis + "\u002B", // Plus Sign + "\u003C", // Less-Than Sign + "\u003D", // Equals Sign + "\u003E", // Greater-Than Sign + "\u0061", // Latin Small Letter a + "\u0062", // Latin Small Letter b + "\u0063", // Latin Small Letter c + "\u0064", // Latin Small Letter d + "\u0065", // Latin Small Letter e + "\u0066", // Latin Small Letter f + "\u0067", // Latin Small Letter g + "\u0068", // Latin Small Letter h + "\u0069", // Latin Small Letter i + "\u006a", // Latin Small Letter j + "\u006B", // Latin Small Letter k + "\u006C", // Latin Small Letter l + "\u006D", // Latin Small Letter m + "\u006E", // Latin Small Letter n + "\u006F", // Latin Small Letter o + "\u0070", // Latin Small Letter p + "\u0071", // Latin Small Letter q + "\u0072", // Latin Small Letter r + "\u0073", // Latin Small Letter s + "\u0074", // Latin Small Letter t + "\u0075", // Latin Small Letter u + "\u0076", // Latin Small Letter v + "\u0077", // Latin Small Letter w + "\u0078", // Latin Small Letter x + "\u0079", // Latin Small Letter y + "\u007A", // Latin Small Letter z + "\u00D7", // Multiplication Sign + "\u00F7", // Division Sign + "\u201C", // Left Double Quotation Mark + "\u201D", // Right Double Quotation Mark + "\u218A", // Turned Digit Two + "\u218B", // Turned Digit Three + "\u2212", // Minus Sign + "\u2217", // Asterisk Operator + "\u2260", // Not Equal To + "\u2264", // Less-Than or Equal To + "\u2265", // Greater-Than or Equal To + }; + */ + } + else { + this->msgferr("The file doesn\'t exist.\n"); + this->exit(); + } +} +luma::app_t::~app_t() { + this->exit(); +} diff --git a/old/src/luma/app_t/archstr.cc b/old/src/luma/app_t/archstr.cc new file mode 100644 index 0000000..57b32dc --- /dev/null +++ b/old/src/luma/app_t/archstr.cc @@ -0,0 +1,22 @@ +# include <luma/main.hh> +char const * luma::app_t::archstr(luma::arch_t arch) noexcept { + char const * str = ""; + switch(arch) { + default: + str = "Unknown"; + break; + case luma::arch_t::aarch64: + str = "ARM64/AArch64"; + break; + case luma::arch_t::amd64: + str = "AMD64/x86-64"; + break; + case luma::arch_t::ia64: + str = "IA-64"; + break; + case luma::arch_t::ppc64: + str = "PPC64"; + break; + } + return str; +} diff --git a/old/src/luma/app_t/arghandl.cc b/old/src/luma/app_t/arghandl.cc new file mode 100644 index 0000000..74a63ed --- /dev/null +++ b/old/src/luma/app_t/arghandl.cc @@ -0,0 +1,12 @@ +# include <luma/main.hh> +void luma::app_t::arghandl(char const * arg) { + char const * appinf = "Luma ()"; + if(this->strcmp(arg,"--help")) { + this->msgfout("\n"); + this->exit(); + } + else if(this->strcmp(arg,"--version")) { + this->msgfout("\n"); + this->exit(); + } +} diff --git a/old/src/luma/app_t/dbgmsgf.cc b/old/src/luma/app_t/dbgmsgf.cc new file mode 100644 index 0000000..fe0631c --- /dev/null +++ b/old/src/luma/app_t/dbgmsgf.cc @@ -0,0 +1,6 @@ +# include <luma/main.hh> +void luma::app_t::dbgmsgf(char const * msg) { + if constexpr(debug) { + this->msgferr(msg); + } +} diff --git a/old/src/luma/app_t/exit.cc b/old/src/luma/app_t/exit.cc new file mode 100644 index 0000000..8a975e6 --- /dev/null +++ b/old/src/luma/app_t/exit.cc @@ -0,0 +1,5 @@ +# include <luma/main.hh> +# include <unistd.h> +[[noreturn]] void luma::app_t::exit() noexcept { + ::_exit(0x0); +} diff --git a/old/src/luma/app_t/getenv.cc b/old/src/luma/app_t/getenv.cc new file mode 100644 index 0000000..2c1b3f4 --- /dev/null +++ b/old/src/luma/app_t/getenv.cc @@ -0,0 +1,13 @@ +# include <luma/main.hh> +# include <unistd.h> +char const * luma::app_t::getenv(char const * envvar) { + /* + strlen = this->strlen(envvar); + for(char const * var : ::environ) { + if(this->strcmp(this->strcut(envvar,0x0,this->strlen(envvar),envvar) == 0x0) { + + } + } + */ + return "wayland"; +} diff --git a/old/src/luma/app_t/kernelstr.cc b/old/src/luma/app_t/kernelstr.cc new file mode 100644 index 0000000..9b326bd --- /dev/null +++ b/old/src/luma/app_t/kernelstr.cc @@ -0,0 +1,34 @@ +# include <luma/main.hh> +char const * luma::app_t::kernelstr(luma::kernel_t kernel) noexcept { + char const * str = ""; + switch(kernel) { + default: + str = "Unknown"; + break; + case luma::kernel_t::darwinos: + str = "Dawin OS"; + break; + case luma::kernel_t::dragonflybsd: + str = "DragonFly BSD"; + break; + case luma::kernel_t::freebsd: + str = "FreeBSD"; + break; + case luma::kernel_t::hurd: + str = "Hurd"; + break; + case luma::kernel_t::linux: + str = "Linux"; + break; + case luma::kernel_t::minix: + str = "MINIX"; + break; + case luma::kernel_t::netbsd: + str = "NetBSD"; + break; + case luma::kernel_t::openbsd: + str = "OpenBSD"; + break; + } + return str; +} diff --git a/old/src/luma/app_t/msgf.cc b/old/src/luma/app_t/msgf.cc new file mode 100644 index 0000000..cf61c98 --- /dev/null +++ b/old/src/luma/app_t/msgf.cc @@ -0,0 +1,8 @@ +# include <cstddef> +# include <luma/main.hh> +# include <unistd.h> +void luma::app_t::msgf(int pipe,char const * msg,std::size_t count) { + if(::write(pipe,msg,count) < 0x0) { + // ??? + } +} diff --git a/old/src/luma/app_t/msgferr.cc b/old/src/luma/app_t/msgferr.cc new file mode 100644 index 0000000..f5bf60c --- /dev/null +++ b/old/src/luma/app_t/msgferr.cc @@ -0,0 +1,4 @@ +# include <luma/main.hh> +void luma::app_t::msgferr(char const * msg) { + this->msgf(this->stderr,msg,this->strlen(msg)); +} diff --git a/old/src/luma/app_t/msgfout.cc b/old/src/luma/app_t/msgfout.cc new file mode 100644 index 0000000..3373d51 --- /dev/null +++ b/old/src/luma/app_t/msgfout.cc @@ -0,0 +1,4 @@ +# include <luma/main.hh> +void luma::app_t::msgfout(char const * msg) { + this->msgf(this->stdout,msg,this->strlen(msg)); +} diff --git a/old/src/luma/app_t/strcmp.cc b/old/src/luma/app_t/strcmp.cc new file mode 100644 index 0000000..ce8e082 --- /dev/null +++ b/old/src/luma/app_t/strcmp.cc @@ -0,0 +1,11 @@ +# include <luma/main.hh> +int luma::app_t::strcmp(char const * lstr,char const * rstr) noexcept { + for(int i = 0x0;;++i) { + if(lstr[i] != rstr[i]) { + return lstr[i] < rstr[i] ? -0x1 : 0x1; + } + if(lstr[i] == '\0') { + return 0x0; + } + } +} diff --git a/old/src/luma/app_t/strcut.cc b/old/src/luma/app_t/strcut.cc new file mode 100644 index 0000000..233c47f --- /dev/null +++ b/old/src/luma/app_t/strcut.cc @@ -0,0 +1,25 @@ +# include <luma/main.hh> +char const * luma::app_t::strcut(char const * str,int pos,int len) { + /* + if((this->strlen(str) - pos - len - 0x1) < 0x0) { // 0x1 counts null as well + // string too short + this->msgerr("String too short!\n"); + return nullptr; + } + else { + char * outstr = nullptr; + int outstrpos = 0x0; + this->msg("boys"); + for(int pos = 0x0;(pos < len);++pos) { + this->msg("diers"); + char chr = str[pos]; + this->msg("hallo"); + outstr[outstrpos] = chr; + ++outstrpos; + } + outstr[++outstrpos] = '\0'; + return outstr; + } + */ + return nullptr; +} diff --git a/old/src/luma/app_t/strlen.cc b/old/src/luma/app_t/strlen.cc new file mode 100644 index 0000000..a4c9ba6 --- /dev/null +++ b/old/src/luma/app_t/strlen.cc @@ -0,0 +1,8 @@ +# include <luma/main.hh> +int luma::app_t::strlen(char const * str) noexcept { + int len = 0x0; + while(str[len] != '\0') { + ++len; + } + return len; +} diff --git a/old/src/main.cc b/old/src/main.cc new file mode 100644 index 0000000..7bca331 --- /dev/null +++ b/old/src/main.cc @@ -0,0 +1,6 @@ +# include <fcntl.h> +# include <luma/main.hh> +# include <unistd.h> +int main(int const argc,char const * * argv) { + luma::app_t app(argc,argv); +} diff --git a/old/stdlibsock__gfx__crtwin.cc b/old/stdlibsock__gfx__crtwin.cc deleted file mode 100644 index 8ef4325..0000000 --- a/old/stdlibsock__gfx__crtwin.cc +++ /dev/null @@ -1,30 +0,0 @@ -# include <cstring> -# include <iostream> -# include <luma/main.hh> -# include <string> -# include <unistd.h> -# include <vulkan/vulkan.h> -# include <wayland-client.h> -# include <xcb/xcb.h> -# include <xcb/xcb_atom.h> -int luma::app_t::stdlibsock__gfx__crtwin(char const * nm, int pos_x, int pos_y, int res_x, int res_y, bool flscrn) { - if(!this->gfxisinit) { - this->initgfx(); - } - if(flscrn) { - std::cerr << "Fullscreen is not supported yet!\n"; - } - if(this->dispsrvproto == luma::dispsrvproto_t::wayland) { - } - else if(this->dispsrvproto == luma::dispsrvproto_t::x) { - this->dbgmsg("Creating X window... "); - ::xcb_create_window(this->xconn,XCB_COPY_FROM_PARENT,this->xwin,this->xscrn->root,pos_y,pos_x,res_x,res_y,0xa,XCB_WINDOW_CLASS_INPUT_OUTPUT,this->xscrn->root_visual,0x0,nullptr); - ::xcb_change_property(this->xconn,XCB_PROP_MODE_REPLACE,this->xwin,XCB_ATOM_WM_NAME,XCB_ATOM_STRING,0x8,nm.size(),nm.c_str()); - ::xcb_map_window(this->xconn,this->xwin); - ::xcb_flush(this->xconn); - this->dbgmsg("O.K.\n"); - } - ::sleep(0x6); - this->termgfx(); - return 0x0; -} diff --git a/old/stdlibsock__gfx__destwin.cc b/old/stdlibsock__gfx__destwin.cc deleted file mode 100644 index c2445e4..0000000 --- a/old/stdlibsock__gfx__destwin.cc +++ /dev/null @@ -1,4 +0,0 @@ -# include <luma/main.hh> -void luma::app_t::stdlibsock__gfx__destwin() { - -} diff --git a/old/termgfx.cc b/old/termgfx.cc deleted file mode 100644 index 2897b13..0000000 --- a/old/termgfx.cc +++ /dev/null @@ -1,13 +0,0 @@ -# include <luma/main.hh> -# include <vulkan/vulkan.h> -# include <wayland-client.h> -# include <xcb/xcb.h> -void luma::app_t::termgfx() { - ::vkDestroyInstance(this->vkinst,nullptr); - if(this->dispsrvproto == this->dispsrvproto_t::x) { - ::xcb_disconnect(this->xconn); - } - else if(this->dispsrvproto == this->dispsrvproto_t::wayland) { - ::wl_display_disconnect(this->wldisp); - } -} |