diff options
Diffstat (limited to 'Source/Library')
-rw-r--r-- | Source/Library/Common/String.class.cpp | 20 | ||||
-rw-r--r-- | Source/Library/Common/String.class.h | 5 | ||||
-rw-r--r-- | Source/Library/Interface/VirtualTerminal.iface.h | 4 | ||||
-rw-r--r-- | Source/Library/Userland/Binding/VirtualTerminal.class.h | 11 | ||||
-rw-r--r-- | Source/Library/Userland/Start.cpp | 3 | ||||
-rw-r--r-- | Source/Library/Userland/Syscall/RessourceCaller.class.h | 11 | ||||
-rw-r--r-- | Source/Library/Userland/common.h | 1 |
7 files changed, 53 insertions, 2 deletions
diff --git a/Source/Library/Common/String.class.cpp b/Source/Library/Common/String.class.cpp index d8913d9..c217807 100644 --- a/Source/Library/Common/String.class.cpp +++ b/Source/Library/Common/String.class.cpp @@ -49,6 +49,26 @@ String String::number(s32int number) { return ret; } +String String::unserialize(u32int w) { + u32int* a = (u32int*)w; + String ret; + ret.m_length = a[0]; + ret.m_string = (WChar*)Mem::alloc(a[0] * sizeof(WChar)); + for (u32int i = 0; i < a[0]; i++) { + ret[i] = a[i + 1]; + } + return ret; +} + +u32int String::serialize() { + u32int* x = (u32int*)Mem::mkXchgSpace((m_length + 1) * sizeof(u32int)); + x[0] = m_length; + for (u32int i = 0; i < m_length; i++) { + x[i + 1] = m_string[i]; + } + return (u32int)x; +} + String::String(const char* string, u8int encoding) { m_string = 0; m_length = 0; diff --git a/Source/Library/Common/String.class.h b/Source/Library/Common/String.class.h index 3e50d35..5db9858 100644 --- a/Source/Library/Common/String.class.h +++ b/Source/Library/Common/String.class.h @@ -9,6 +9,9 @@ class String : public BasicString<WChar> { static String hex(u32int number); static String number(s32int number); + static String unserialize(u32int w); + u32int serialize(); + String(const char* string, u8int encoding = UE_UTF8); String() : BasicString<WChar>() {} String(const String &other) : BasicString<WChar> (other) {} @@ -34,7 +37,7 @@ class String : public BasicString<WChar> { String operator+ (const String &other) const { return concat(other); } String operator+ (const char* other) const { return concat(other); } String operator+ (WChar other) const { return concat(other); } - + s64int toInt() const; //Convert from DEC u64int toInt16() const; //Convert from HEX diff --git a/Source/Library/Interface/VirtualTerminal.iface.h b/Source/Library/Interface/VirtualTerminal.iface.h index 661162f..1525b6c 100644 --- a/Source/Library/Interface/VirtualTerminal.iface.h +++ b/Source/Library/Interface/VirtualTerminal.iface.h @@ -4,5 +4,9 @@ #define VT_IFACE_OBJTYPE 0x10 #define VT_IFACE_PUT 0x01 #define VT_IFACE_WRITEHEX 0x02 +#define VT_IFACE_WRITEDEC 0x03 +#define VT_IFACE_WRITE 0x04 + +#define VT_IFACE_READLINE 0x05 #endif diff --git a/Source/Library/Userland/Binding/VirtualTerminal.class.h b/Source/Library/Userland/Binding/VirtualTerminal.class.h index a7bb4c2..67683b8 100644 --- a/Source/Library/Userland/Binding/VirtualTerminal.class.h +++ b/Source/Library/Userland/Binding/VirtualTerminal.class.h @@ -2,6 +2,7 @@ #include <VirtualTerminal.iface.h> +#include <String.class.h> #include <WChar.class.h> class VirtualTerminal : public RessourceCaller { @@ -15,6 +16,16 @@ class VirtualTerminal : public RessourceCaller { void writeHex(u32int number) { doCall(VT_IFACE_WRITEHEX, number); } + void writeDec(s64int number) { + doCall(VT_IFACE_WRITEDEC, (number >> 32), number); + } + void write(String s) { + Serialized a = s.serialize(); + doCall(VT_IFACE_WRITE, a); + } + String readLine() { + return String::unserialize(doCall(VT_IFACE_READLINE)); + } void put(WChar c) { doCall(VT_IFACE_PUT, c); diff --git a/Source/Library/Userland/Start.cpp b/Source/Library/Userland/Start.cpp index e185189..639210f 100644 --- a/Source/Library/Userland/Start.cpp +++ b/Source/Library/Userland/Start.cpp @@ -18,7 +18,7 @@ extern "C" void start() { ((void (*)(void))*call)(); } - heap.create(0x40000000, 0x00100000, 0x00003000); //Initially create a 1M heap with 12ko index + heap.create(0x40000000, 0x00100000, 0x00004000); //Initially create a 1M heap with 16ko index u32int r = main(); //Call static destructors @@ -32,4 +32,5 @@ extern "C" void start() { namespace Mem { void* alloc (u32int sz) { return heap.alloc(sz); } void free(void* ptr) { heap.free(ptr); } + void* mkXchgSpace (u32int sz) { return alloc(sz); } } diff --git a/Source/Library/Userland/Syscall/RessourceCaller.class.h b/Source/Library/Userland/Syscall/RessourceCaller.class.h index 3ad8900..3602ef0 100644 --- a/Source/Library/Userland/Syscall/RessourceCaller.class.h +++ b/Source/Library/Userland/Syscall/RessourceCaller.class.h @@ -2,6 +2,17 @@ #define DEF_RESSOURCECALLER_CLASS_H #include <Syscall/Syscall.wtf.h> +#include <common.h> + +class Serialized { + private: + u32int m_value; + + public: + Serialized(u32int v) : m_value(v) {} + ~Serialized() { Mem::free( (void*)m_value); } + operator u32int () { return m_value; } +}; class RessourceCaller { private: diff --git a/Source/Library/Userland/common.h b/Source/Library/Userland/common.h index 3508513..6257841 100644 --- a/Source/Library/Userland/common.h +++ b/Source/Library/Userland/common.h @@ -10,6 +10,7 @@ namespace Mem { void* alloc(u32int); void free(void*); + void* mkXchgSpace(u32int sz); } //Standard implemenations of operator new/delete |