summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore11
-rw-r--r--Makefile34
-rw-r--r--PKGBUILD4
-rw-r--r--README.html60
-rw-r--r--dbgmsg.cc6
-rw-r--r--examples/example0.luma17
-rw-r--r--getenv.cc5
-rw-r--r--include/luma/main.hh101
-rw-r--r--include/luma/stdlibsock.hh3
-rw-r--r--include/luma/stdlibsock/gfx.hh13
-rw-r--r--initgfx.cc52
-rw-r--r--main.cc79
-rw-r--r--msg.cc7
-rw-r--r--msgerr.cc7
-rw-r--r--msgout.cc7
-rw-r--r--old/initgfx.cc52
-rw-r--r--old/isvkphysdevvalid.cc (renamed from isvkphysdevvalid.cc)2
-rw-r--r--old/setdispsrvproto.cc35
-rw-r--r--old/stdlibsock__gfx__crtwin.cc30
-rw-r--r--old/stdlibsock__gfx__destwin.cc4
-rw-r--r--old/termgfx.cc13
-rw-r--r--setdispsrvproto.cc35
-rw-r--r--src/luma/app_t/app_t.cc79
-rw-r--r--src/luma/app_t/archstr.cc (renamed from archstr.cc)2
-rw-r--r--src/luma/app_t/arghandl.cc12
-rw-r--r--src/luma/app_t/dbgmsgf.cc6
-rw-r--r--src/luma/app_t/exit.cc5
-rw-r--r--src/luma/app_t/getenv.cc13
-rw-r--r--src/luma/app_t/kernelstr.cc (renamed from kernelstr.cc)2
-rw-r--r--src/luma/app_t/msgf.cc7
-rw-r--r--src/luma/app_t/msgferr.cc4
-rw-r--r--src/luma/app_t/msgfout.cc4
-rw-r--r--src/luma/app_t/strcmp.cc11
-rw-r--r--src/luma/app_t/strcut.cc25
-rw-r--r--src/luma/app_t/strlen.cc (renamed from strlen.cc)2
-rw-r--r--src/main.cc6
-rw-r--r--stdlibsock/gfx/crtwin.cc31
-rw-r--r--stdlibsock/gfx/destwin.cc4
-rw-r--r--termgfx.cc13
39 files changed, 450 insertions, 353 deletions
diff --git a/.gitignore b/.gitignore
index d573c89..e494714 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,2 @@
-*
-!*.cc
-!*.gitignore
-!*.hh
-!*.luma
-!COPYING
-!Makefile
-!PKGBUILD
-!README
+*.elf
+*.o
diff --git a/Makefile b/Makefile
index afabf8d..24f0be4 100644
--- a/Makefile
+++ b/Makefile
@@ -7,27 +7,25 @@ ifeq ($(LUMA__X),1)
CXXFLAGS += -DLUMA__X=true
endif
CXXFLAGS += -std=c++20 -Wall -Wextra -Wpedantic
-CXXFLAGS += -march=native -O3
+CXXFLAGS += -march=native -mtune=native -O3
LDFLAGS = -lgmp -lmpfr -lpthread -lvulkan -lwayland-client -lxcb
HDRS_CXX = \
- include/luma/stdlibsock/gfx.hh \
- include/luma/main.hh \
- include/luma/stdlibsock.hh
+ include/luma/main.hh
SRCS_CXX = \
- stdlibsock/gfx/crtwin.cc \
- stdlibsock/gfx/destwin.cc \
- setdispsrvproto.cc \
- archstr.cc \
- dbgmsg.cc \
- getenv.cc \
- initgfx.cc \
- kernelstr.cc \
- main.cc \
- msg.cc \
- msgerr.cc \
- msgout.cc \
- strlen.cc \
- termgfx.cc
+ src/luma/app_t/app_t.cc \
+ src/luma/app_t/archstr.cc \
+ src/luma/app_t/arghandl.cc \
+ src/luma/app_t/dbgmsgf.cc \
+ src/luma/app_t/exit.cc \
+ src/luma/app_t/getenv.cc \
+ src/luma/app_t/msgf.cc \
+ src/luma/app_t/msgferr.cc \
+ src/luma/app_t/msgfout.cc \
+ src/luma/app_t/kernelstr.cc \
+ src/luma/app_t/strcmp.cc \
+ src/luma/app_t/strcut.cc \
+ src/luma/app_t/strlen.cc \
+ src/main.cc
SRCS=$(SRCS_CXX)
OBJS=$(SRCS:.cc=.o)
luma.elf: $(OBJS)
diff --git a/PKGBUILD b/PKGBUILD
index a64401f..409f629 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
pkgname="luma"
-pkgver=11
+pkgver=12
pkgrel=1
arch=('any')
license=('AGPL3')
depends=('gmp' 'libxcb' 'mpfr' 'wayland')
-makedepends=('glm' 'vulkan-headers')
+makedepends=('vulkan-headers')
diff --git a/README.html b/README.html
new file mode 100644
index 0000000..1d544e5
--- /dev/null
+++ b/README.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr">
+ <head>
+ <meta charset="utf-8">
+ <style type="text/css">
+ body {
+ margin: 0vw auto;
+ padding: 0vw;
+ text-align: center;
+ width: 75vw;
+ }
+ h1 {
+ font-size: 1.5em;
+ }
+ h2 {
+ font-size: 1.25em;
+ }
+ </style>
+ </head>
+ <body>
+ <p style="font-size:0.75em;">Copyright 2021 Gabriel Jensen</p>
+ <h1>LICENSE NOTE</h1>
+ <p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p>
+ <p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU Affero General Public License for more details.</p>
+ <p>You should have received a copy of the GNU Affero General Public License along with this program.</p>
+ <p>If not, see <a href="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</a>.</p>
+ <h1>INTRODUCTION</h1>
+ <p>TO-DO: Write short introduction to the programming language and the reasons it was made.</p>
+ <h2>CODING PRINCIPLES</h2>
+ <p>Luma has the following coding principles:</p>
+ <p>TO-DO: Write down the principles.</p>
+ <h2>IMPORTANT FORMATING INFORMATION ABOUT LITERALS</h2>
+ <p>Luma is morden in the sense it breaks free of traditions which, more often than not, are from the beginning of the age of the computer.</p>
+ <p>To begin with, integral literals are written in base-twelve.</p>
+ <p>The number 10 would be written as ↊ (U+218A ↊ Turned Digit Two), and the number 11 would be written as ↋ (U+218B ↋ Turned Digit Three).</p>
+ <p>They are also written as little-endian, so numbers increment to the right instead of the left.</p>
+ <p>Down below is a short conversion table for how integral literals must be written:</p>
+ <p>TO-DO: Create conversion table.</p>
+ 8 -> 8
+ 9 -> 9
+ 10 -> ↊
+ 11 -> ↋
+ 12 -> 01
+ 13 -> 11
+ 14 -> 21
+ 15 -> 31
+ 16 -> 41
+ 100 -> 48
+ 120 -> 0↊
+ 132 -> 0↋
+ 144 -> 001
+ 156 -> 011
+ 168 -> 021
+ 1000 -> 4↋6
+ 1728 -> 0001
+ <p>And lastly integral literals must have the '#' (U+0023 # NUMBER SIGN) prefix.</p>
+
+ </body>
+</html>
diff --git a/dbgmsg.cc b/dbgmsg.cc
deleted file mode 100644
index f09ebf7..0000000
--- a/dbgmsg.cc
+++ /dev/null
@@ -1,6 +0,0 @@
-# include <luma/main.hh>
-void luma::dbgmsg(char const * msg) {
- if constexpr(debug) {
- luma::msgerr(msg);
- }
-}
diff --git a/examples/example0.luma b/examples/example0.luma
new file mode 100644
index 0000000..8a7f9c8
--- /dev/null
+++ b/examples/example0.luma
@@ -0,0 +1,17 @@
+\ '\' defines single-line comments.
+\<
+ '\<' followed by '\>' defines multi-line comments.
+ The contents of multi-line comments must be indented.
+ Indentation is always a tab in Luma.
+\>
+\ Modules are automaticly imported by the interpreter.
+\ Modules are folders with source code. Each source file contains the definition of the name of the file.
+\ /gfx/win_t (example module) will be defined in the file win_t.luma which itself is inside the gfx folder.
+\ This makes is easy for the interpreter to find the definitions. Therefore, each file in a module must only contain one definition.
+\ This has the drawback of making single-file programs impossible if they want to utilize non-centralized modules.
+\ A fix to this is to put the source files in an archive (like a Tarball), which is already a standard thing to do.
+\ Define variable main of type void_t as function that doesn't return.
+void_t:main -fn [] -noret
+ // Use '$' followed by a dozenal number to
+ /std/fout "1 + 1 = $0" (#1 + #1)
+ exit
diff --git a/getenv.cc b/getenv.cc
deleted file mode 100644
index d37a35e..0000000
--- a/getenv.cc
+++ /dev/null
@@ -1,5 +0,0 @@
-# include <luma/main.hh>
-# include <unistd.h>
-char const * luma::getenv(char const * envvar) {
- return "wayland";
-}
diff --git a/include/luma/main.hh b/include/luma/main.hh
index 9528e92..a3f196d 100644
--- a/include/luma/main.hh
+++ b/include/luma/main.hh
@@ -1,14 +1,10 @@
# if !defined(LUMA__HEADER__MAIN)
# define LUMA__HEADER__MAIN
-# include <fcntl.h>
-# include <luma/stdlibsock.hh>
-# include <luma/stdlibsock/gfx.hh>
# include <vector>
-# include <vulkan/vulkan.h>
-# include <wayland-client.h>
-# include <xcb/xcb.h>
-// enum class -> class -> operator -> constexpr -> function -> variable -> inline function
+// 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,
@@ -16,11 +12,6 @@ namespace luma {
ppc64,
unknown,
};
- enum class dispsrvproto_t {
- unknown,
- wayland,
- x,
- };
enum class kernel_t {
darwinos,
dragonflybsd,
@@ -32,71 +23,65 @@ namespace luma {
openbsd,
unknown,
};
- class dat_t {
+ class app_t {
public:
- bool gfxisinit;
- luma::dispsrvproto_t dispsrvproto= luma::dispsrvproto_t::wayland;
- std::vector<VkExtensionProperties> vkexts;
- std::vector<VkPhysicalDevice> vkphysdevs;
- ::VkApplicationInfo vkappinf {};
- ::VkInstance vkinst;
- ::VkInstanceCreateInfo vkinstcrtinf {};
- ::VkResult vkreslt;
- ::wl_buffer * wlbuff = nullptr;
- ::wl_display * wldisp = nullptr;
- ::wl_shell_surface * wlsurf = nullptr;
- ::xcb_connection_t * xconn = nullptr;
- ::xcb_screen_t * xscrn = nullptr;
- ::xcb_window_t xwin;
- } extern dat;
- bool constexpr debug =
+ app_t(int const argc, char const * * argv);
+ ~app_t();
+ private:
+ bool constexpr static debug =
# if defined(NDEBUG)
- false;
+ false;
# else
- true;
+ true;
# endif
- luma::arch_t constexpr arch = luma::arch_t::
+ luma::arch_t constexpr static arch = luma::arch_t::
# if defined(__aarch64__)
- aarch64;
+ aarch64;
# elif (defined(_M_AMD64) || defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(x86_64__))
- amd64;
+ amd64;
# elif (defined(_IA64) defined(_M_IA64) || defined(__IA64__) || defined(__ia64__) || defined(__itanium__))
- ia64;
+ ia64;
# elif (defined(_ARCH_PPC64) || defined(__powerpc64__) || defined(__PPC64__) || defined(__ppc64__))
- ppc64;
+ ppc64;
# else
- unknown;
+ unknown;
# endif
- luma::kernel_t constexpr kernel = luma::kernel_t::
+ luma::kernel_t constexpr static kernel = luma::kernel_t::
# if defined(__APPLE__)
- darwinos;
+ darwinos;
# elif defined(__DragonFly__)
- dragonflybsd;
+ dragonflybsd;
# elif defined(__FreeBSD__)
- freebsd;
+ freebsd;
# elif (defined(__GNU__) || defined(__gnu_hurd__))
- hurd;
+ hurd;
# elif defined(__linux__)
- linux;
+ linux;
# elif defined(__minix)
- minix;
+ minix;
# elif defined(__NetBSD__)
- netbsd;
+ netbsd;
# elif defined(__OpenBSD__)
- openbsd;
+ openbsd;
# else
- unknown;
+ unknown;
# endif
- char const * archstr(luma::arch_t arch);
- char const * getenv(char const * envvar);
- char const * kernelstr(luma::kernel_t kernel);
- int strlen(char const * str);
- void dbgmsg(char const * msg);
- void initgfx();
- void msg(int pipe,char const * msg);
- void msgerr(char const * msg);
- void msgout(char const * msg);
- void setdispsrvproto();
- void termgfx();
+ 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);
+ void msgferr(char const * buf);
+ void msgfout(char const * buf);
+ };
}
# endif
diff --git a/include/luma/stdlibsock.hh b/include/luma/stdlibsock.hh
deleted file mode 100644
index 3224e09..0000000
--- a/include/luma/stdlibsock.hh
+++ /dev/null
@@ -1,3 +0,0 @@
-# if !defined(LUMA__HEADER__STDLIBSOCK)
-# define LUMA__HEADER__STDLIBSOCK
-# endif
diff --git a/include/luma/stdlibsock/gfx.hh b/include/luma/stdlibsock/gfx.hh
deleted file mode 100644
index f44ba34..0000000
--- a/include/luma/stdlibsock/gfx.hh
+++ /dev/null
@@ -1,13 +0,0 @@
-# if !defined(LUMA__HEADER__STDLIBSOCK__GFX)
-# define LUMA__HEADER__STDLIBSOCK__GFX
-# include <cstdint>
-# include <string>
-namespace luma {
- namespace stdlibsock {
- namespace gfx {
- std::uint8_t crtwin(std::basic_string<char> nm, std::uint16_t pos_x, std::uint16_t pos_y, std::uint16_t res_x, std::uint16_t res_y, bool flscrn);
- void destwin();
- }
- }
-}
-# endif
diff --git a/initgfx.cc b/initgfx.cc
deleted file mode 100644
index ee583c2..0000000
--- a/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::initgfx() {
- luma::dat.gfxisinit = true;
- // Determine if X should be used or if Wayland is da way.
- luma::setdispsrvproto();
- if(luma::dat.dispsrvproto == luma::dispsrvproto_t::x) {
- luma::dbgmsg("Creating X connection... ");
- luma::dat.xconn = xcb_connect(nullptr,nullptr);
- luma::dat.xscrn = xcb_setup_roots_iterator(xcb_get_setup(luma::dat.xconn)).data;
- luma::dat.xwin = xcb_generate_id(luma::dat.xconn);
- luma::dbgmsg("O.K.\n");
- }
- else {
- luma::dbgmsg("Creating Wayland connection... ");
- luma::dat.wldisp = wl_display_connect(nullptr);
- if(luma::dat.wldisp == nullptr) {
- luma::dbgmsg("Error\n");
- }
- else {
- luma::dbgmsg("O.K.\n");
- }
- }
- // Set data required by Vulkan.
- luma::dat.vkappinf.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
- luma::dat.vkappinf.pApplicationName = "Luma Standard Library";
- luma::dat.vkappinf.pEngineName = "Luma Standard Library";
- luma::dat.vkinstcrtinf.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
- luma::dat.vkinstcrtinf.pApplicationInfo = &luma::dat.vkappinf;
- luma::dat.vkinstcrtinf.enabledLayerCount = 0x0;
- luma::dbgmsg("Creating Vulkan instance... ");
- luma::dat.vkreslt = vkCreateInstance(&luma::dat.vkinstcrtinf,nullptr,&luma::dat.vkinst);
- if(luma::dat.vkreslt != VK_SUCCESS) {
- luma::dbgmsg("Error\n");
- }
- else {
- luma::dbgmsg("O.K.\n");
- }
- std::uint32_t extcount = 0x0;
- luma::dat.vkexts = std::vector<VkExtensionProperties>(extcount);
- ::vkEnumerateInstanceExtensionProperties(nullptr,&extcount,luma::dat.vkexts.data());
- luma::dbgmsg(std::basic_string<char> {std::to_string(extcount) + " Vulkan extensions supported.\n"}.c_str());
- luma::dbgmsg("The following Vulkan extensions are supported:\n");
- for(auto const & ext : luma::dat.vkexts) {
- luma::dbgmsg(ext.extensionName);
- }
- std::uint32_t devcount = 0x0;
- ::vkEnumeratePhysicalDevices(luma::dat.vkinst,&devcount,luma::dat.vkphysdevs.data());
- luma::dbgmsg(std::basic_string<char> {std::to_string(devcount) + " Vulkan-compatible device(s) found.\n"}.c_str());
-}
diff --git a/main.cc b/main.cc
deleted file mode 100644
index 9ba77f6..0000000
--- a/main.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-# include <fcntl.h>
-# include <luma/main.hh>
-# include <unistd.h>
-luma::dat_t luma::dat;
-int main(int argc, char * * argv) {
- if(argc < 0x2) {
- luma::msgerr("Missing argument \"file\".\n");
- ::_exit(0x1);
- }
- luma::msgout(luma::archstr(luma::arch));
- luma::msgout(luma::kernelstr(luma::kernel));
- if(!::access(argv[0x1],R_OK)) {
- int lumafile = ::open(argv[0x1],O_RDONLY);
- /*
- char16_t const * alphtokens {
- u'\u0061', // a
- u'\u0062', // b
- u'\u0063', // c
- u'\u0064', // d
- u'\u0065', // e
- u'\u0066', // f
- u'\u0067', // g
- u'\u0068', // h
- u'\u0069', // i
- u'\u006a', // j
- u'\u006b', // k
- u'\u006c', // l
- u'\u006d', // m
- u'\u006e', // n
- u'\u006f', // o
- u'\u0070', // p
- u'\u0071', // q
- u'\u0072', // r
- u'\u0073', // s
- u'\u0074', // t
- u'\u0075', // u
- u'\u0076', // v
- u'\u0077', // w
- u'\u0078', // x
- u'\u0079', // y
- u'\u007a' // z
- };
- char16_t const * alphtokens {
- u'\u0028', // (
- u'\u0029', // )
- u'\u002b', // +
- u'\u00d7', // ×
- u'\u00f7', // ÷
- u'\u2044', // ⁄
- u'\u2212', //
- u'\u221a', // −
- u'\u2329', // 〈
- u'\u232a' // 〉
- };
- char16_t const * alphtokens {
- u'\u0030', // 0
- u'\u0031', // 1
- u'\u0032', // 2
- u'\u0033', // 3
- u'\u0034', // 4
- u'\u0035', // 5
- u'\u0036', // 6
- u'\u0037', // 7
- u'\u0038', // 8
- u'\u0039', // 9
- u'\u218a', // ↊
- u'\u218b' // ↋
- };
- */
- while(lumafile) {
- luma::stdlibsock::gfx::crtwin("luma test",0x0,0x0,0x400,0x300,false);
- }
- }
- else {
- luma::msgerr("The file doesn't exist.\n");
- ::_exit(0x1);
- }
- ::_exit(0x0);
-}
diff --git a/msg.cc b/msg.cc
deleted file mode 100644
index 94ce824..0000000
--- a/msg.cc
+++ /dev/null
@@ -1,7 +0,0 @@
-# include <fcntl.h>
-# include <luma/main.hh>
-# include <unistd.h>
-void luma::msg(int pipe,char const * msg) {
- if(::write(pipe,msg,luma::strlen(msg)) > 0x0) {
- }
-}
diff --git a/msgerr.cc b/msgerr.cc
deleted file mode 100644
index b0f601b..0000000
--- a/msgerr.cc
+++ /dev/null
@@ -1,7 +0,0 @@
-# include <fcntl.h>
-# include <luma/main.hh>
-# include <unistd.h>
-void luma::msgerr(char const * msg) {
- int pipe = ::open("/dev/stderr",O_WRONLY);
- return luma::msg(pipe,msg);
-}
diff --git a/msgout.cc b/msgout.cc
deleted file mode 100644
index e26dcdd..0000000
--- a/msgout.cc
+++ /dev/null
@@ -1,7 +0,0 @@
-# include <fcntl.h>
-# include <luma/main.hh>
-# include <unistd.h>
-void luma::msgout(char const * msg) {
- int pipe = ::open("/dev/stdout",O_WRONLY);
- return luma::msg(pipe,msg);
-}
diff --git a/old/initgfx.cc b/old/initgfx.cc
new file mode 100644
index 0000000..ffaf1e5
--- /dev/null
+++ b/old/initgfx.cc
@@ -0,0 +1,52 @@
+# 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/isvkphysdevvalid.cc b/old/isvkphysdevvalid.cc
index 9a8c065..27a169b 100644
--- a/isvkphysdevvalid.cc
+++ b/old/isvkphysdevvalid.cc
@@ -1,5 +1,5 @@
# include <luma/main.hh>
# include <vulkan/vulkan.h>
//isVulkanPhysicalDeviceValid
-void luma::isvkphysdevvalid(VkPhysicalDevice & dev) {
+void luma::app_t::isvkphysdevvalid(VkPhysicalDevice & dev) {
}
diff --git a/old/setdispsrvproto.cc b/old/setdispsrvproto.cc
new file mode 100644
index 0000000..a423ccc
--- /dev/null
+++ b/old/setdispsrvproto.cc
@@ -0,0 +1,35 @@
+# 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/stdlibsock__gfx__crtwin.cc b/old/stdlibsock__gfx__crtwin.cc
new file mode 100644
index 0000000..8ef4325
--- /dev/null
+++ b/old/stdlibsock__gfx__crtwin.cc
@@ -0,0 +1,30 @@
+# 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
new file mode 100644
index 0000000..c2445e4
--- /dev/null
+++ b/old/stdlibsock__gfx__destwin.cc
@@ -0,0 +1,4 @@
+# include <luma/main.hh>
+void luma::app_t::stdlibsock__gfx__destwin() {
+
+}
diff --git a/old/termgfx.cc b/old/termgfx.cc
new file mode 100644
index 0000000..2897b13
--- /dev/null
+++ b/old/termgfx.cc
@@ -0,0 +1,13 @@
+# 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);
+ }
+}
diff --git a/setdispsrvproto.cc b/setdispsrvproto.cc
deleted file mode 100644
index 3cd2d59..0000000
--- a/setdispsrvproto.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-# include <luma/main.hh>
-void luma::setdispsrvproto() {
- luma::dat.dispsrvproto = luma::dispsrvproto_t::wayland;
-# if 0
- char const * envval = luma::getenv("LUMA__DISPSRVPROTO");
- if(envval != "") {
- if(envval == "x") {
- luma::dbgmsg("Setting the display server protocol to X.\n");
- luma::dat.dispsrvproto = luma::dispsrvproto_t::x;
- }
- else if(envval == "wayland") {
- luma::dbgmsg("Setting the display server protocol to Wayland.\n");
- luma::dat.dispsrvproto = luma::dispsrvproto_t::wayland;
- }
- else {
- //std::cerr << "$LUMA__DISPSRVPROTO is set to \"" + envval + "\", which is an unrecognized display server protocol.\n";
- }
- }
- else {
- luma::dbgmsg("Getting current display server protocol.\n");
- std::string xdgsesstype = std::getenv("XDG_SESSION_TYPE");
- if(xdgsesstype == "wayland") {
- luma::dbgmsg("It appears to be Wayland.\n");
- luma::dat.dispsrvproto = luma::dispsrvproto_t::wayland;
- }
- else if(xdgsesstype == "x11") {
- luma::dbgmsg("It appears to be X.\n");
- luma::dat.dispsrvproto = luma::dispsrvproto_t::x;
- }
- else {
- luma::dbgmsg("Error\n");
- }
- }
-# endif
-}
diff --git a/src/luma/app_t/app_t.cc b/src/luma/app_t/app_t.cc
new file mode 100644
index 0000000..0c311d6
--- /dev/null
+++ b/src/luma/app_t/app_t.cc
@@ -0,0 +1,79 @@
+# include <fcntl.h>
+# 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);
+//char8_t const * validtoks = "\t 2abcdefghijklmnopqrstuvwxyz0123456789#()*+<=>×÷↊↋−≠⋜⋝\n";
+ 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/archstr.cc b/src/luma/app_t/archstr.cc
index b07cb32..57b32dc 100644
--- a/archstr.cc
+++ b/src/luma/app_t/archstr.cc
@@ -1,5 +1,5 @@
# include <luma/main.hh>
-char const * luma::archstr(luma::arch_t arch) {
+char const * luma::app_t::archstr(luma::arch_t arch) noexcept {
char const * str = "";
switch(arch) {
default:
diff --git a/src/luma/app_t/arghandl.cc b/src/luma/app_t/arghandl.cc
new file mode 100644
index 0000000..74a63ed
--- /dev/null
+++ b/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/src/luma/app_t/dbgmsgf.cc b/src/luma/app_t/dbgmsgf.cc
new file mode 100644
index 0000000..fe0631c
--- /dev/null
+++ b/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/src/luma/app_t/exit.cc b/src/luma/app_t/exit.cc
new file mode 100644
index 0000000..8a975e6
--- /dev/null
+++ b/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/src/luma/app_t/getenv.cc b/src/luma/app_t/getenv.cc
new file mode 100644
index 0000000..2c1b3f4
--- /dev/null
+++ b/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/kernelstr.cc b/src/luma/app_t/kernelstr.cc
index 9b4aa0c..9b326bd 100644
--- a/kernelstr.cc
+++ b/src/luma/app_t/kernelstr.cc
@@ -1,5 +1,5 @@
# include <luma/main.hh>
-char const * luma::kernelstr(luma::kernel_t kernel) {
+char const * luma::app_t::kernelstr(luma::kernel_t kernel) noexcept {
char const * str = "";
switch(kernel) {
default:
diff --git a/src/luma/app_t/msgf.cc b/src/luma/app_t/msgf.cc
new file mode 100644
index 0000000..5cb6828
--- /dev/null
+++ b/src/luma/app_t/msgf.cc
@@ -0,0 +1,7 @@
+# include <luma/main.hh>
+# include <unistd.h>
+void luma::app_t::msgf(int pipe,char const * msg) {
+ if(::write(pipe,msg,this->strlen(msg)) < 0x0) {
+ // ???
+ }
+}
diff --git a/src/luma/app_t/msgferr.cc b/src/luma/app_t/msgferr.cc
new file mode 100644
index 0000000..4feb608
--- /dev/null
+++ b/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);
+}
diff --git a/src/luma/app_t/msgfout.cc b/src/luma/app_t/msgfout.cc
new file mode 100644
index 0000000..92556ce
--- /dev/null
+++ b/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);
+}
diff --git a/src/luma/app_t/strcmp.cc b/src/luma/app_t/strcmp.cc
new file mode 100644
index 0000000..ce8e082
--- /dev/null
+++ b/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/src/luma/app_t/strcut.cc b/src/luma/app_t/strcut.cc
new file mode 100644
index 0000000..233c47f
--- /dev/null
+++ b/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/strlen.cc b/src/luma/app_t/strlen.cc
index ef81b91..a4c9ba6 100644
--- a/strlen.cc
+++ b/src/luma/app_t/strlen.cc
@@ -1,5 +1,5 @@
# include <luma/main.hh>
-int luma::strlen(char const * str) {
+int luma::app_t::strlen(char const * str) noexcept {
int len = 0x0;
while(str[len] != '\0') {
++len;
diff --git a/src/main.cc b/src/main.cc
new file mode 100644
index 0000000..7bca331
--- /dev/null
+++ b/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/stdlibsock/gfx/crtwin.cc b/stdlibsock/gfx/crtwin.cc
deleted file mode 100644
index 884eb24..0000000
--- a/stdlibsock/gfx/crtwin.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-# include <cstdint>
-# 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>
-std::uint8_t luma::stdlibsock::gfx::crtwin(std::basic_string<char> nm,std::uint16_t pos_x,std::uint16_t pos_y,std::uint16_t res_x,std::uint16_t res_y,bool flscrn) {
- if(!luma::dat.gfxisinit) {
- luma::initgfx();
- }
- if(flscrn) {
- std::cerr << "Fullscreen is not supported yet!\n";
- }
- if(luma::dat.dispsrvproto == luma::dispsrvproto_t::wayland) {
- }
- else if(luma::dat.dispsrvproto == luma::dispsrvproto_t::x) {
- luma::dbgmsg("Creating X window... ");
- ::xcb_create_window(luma::dat.xconn,XCB_COPY_FROM_PARENT,luma::dat.xwin,luma::dat.xscrn->root,pos_y,pos_x,res_x,res_y,0xa,XCB_WINDOW_CLASS_INPUT_OUTPUT,luma::dat.xscrn->root_visual,0x0,nullptr);
- ::xcb_change_property(luma::dat.xconn,XCB_PROP_MODE_REPLACE,luma::dat.xwin,XCB_ATOM_WM_NAME,XCB_ATOM_STRING,0x8,nm.size(),nm.c_str());
- ::xcb_map_window(luma::dat.xconn,luma::dat.xwin);
- ::xcb_flush(luma::dat.xconn);
- luma::dbgmsg("O.K.\n");
- }
- ::sleep(0x6);
- luma::termgfx();
- return 0x0;
-}
diff --git a/stdlibsock/gfx/destwin.cc b/stdlibsock/gfx/destwin.cc
deleted file mode 100644
index 2ee8387..0000000
--- a/stdlibsock/gfx/destwin.cc
+++ /dev/null
@@ -1,4 +0,0 @@
-# include <luma/main.hh>
-void luma::stdlibsock::gfx::destwin() {
-
-}
diff --git a/termgfx.cc b/termgfx.cc
deleted file mode 100644
index 240c1b7..0000000
--- a/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::termgfx() {
- ::vkDestroyInstance(luma::dat.vkinst,nullptr);
- if(luma::dat.dispsrvproto == luma::dispsrvproto_t::x) {
- ::xcb_disconnect(luma::dat.xconn);
- }
- else if(luma::dat.dispsrvproto == luma::dispsrvproto_t::wayland) {
- ::wl_display_disconnect(luma::dat.wldisp);
- }
-}