diff --git a/fugg-client/src/client.cpp b/fugg-client/src/client.cpp index 7d930c2..8f170fb 100644 --- a/fugg-client/src/client.cpp +++ b/fugg-client/src/client.cpp @@ -68,12 +68,12 @@ void before_main_loop() { void after_main_loop() { // std::string test; - auto& music_properties = fugg::module_ref>(0x00034f7c); - auto& item_properties = fugg::module_ref>(0x00035194); + // auto& music_properties = fugg::module_ref>(0x00034f7c); + // auto& item_properties = fugg::module_ref>(0x00035194); - for(auto& item : item_properties) { - std::cout << item.some_string->c_str() << std::endl; - } + // for(auto& item : item_properties) { + // std::cout << item.some_string->c_str() << std::endl; + // } // auto& item_properties = fugg::module_ref>(0x00035194); // std::cout << "Expecting " << reinterpret_cast(fugg::wasm::kMemory.address_of(0x00035194)) << std::endl; diff --git a/fugg-core/src/stl.h b/fugg-core/src/stl.h index feee882..3ab87e5 100644 --- a/fugg-core/src/stl.h +++ b/fugg-core/src/stl.h @@ -20,24 +20,32 @@ namespace fugg { } }; + struct RawVector { + uintptr_t begin; + uintptr_t end; + uintptr_t end_capacity; + }; + template struct RawUniquePointer { - T* ptr; + uintptr_t ptr; }; template struct RawHashTable { - RawUniquePointer bucket_list; + RawUniquePointer bucket_list; + uintptr_t first_node; + size_t capacity; + float unknown; }; - template struct RawBasicString { - T* data; + uintptr_t data; size_t size; size_t cap; }; static_assert( - sizeof(RawBasicString) == sizeof(std::string), + sizeof(RawBasicString) == sizeof(std::string), "RawBasicString needs to have same size of std::string" ); @@ -70,11 +78,7 @@ namespace fugg { // A class that facilitates handling vectors that are allocated in a module. template class Vector { - struct RawVector { - uintptr_t begin; - uintptr_t end; - uintptr_t end_capacity; - }; + using RawVector = detail::RawVector; ModulePointer begin_; ModulePointer end_; @@ -107,7 +111,7 @@ namespace fugg { template class BasicString { - using value_type = T; + using RawBasicString = detail::RawBasicString; struct __long { ModulePointer data; @@ -115,11 +119,11 @@ namespace fugg { size_t cap; }; - enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? - (sizeof(__long) - 1)/sizeof(value_type) : 2}; + enum {__min_cap = (sizeof(__long) - 1) / sizeof(T) > 2 ? + (sizeof(__long) - 1) / sizeof(T) : 2}; struct __short { - value_type data[__min_cap]; - struct : detail::__padding + T data[__min_cap]; + struct : detail::__padding { unsigned char size; }; @@ -130,12 +134,6 @@ namespace fugg { __short __s; }; - struct RawBasicString { - uintptr_t data; - size_t size; - size_t cap; - }; - public: detail::ArrowProxy> operator->() { // Copy the data to the stack. @@ -143,8 +141,6 @@ namespace fugg { // If the string is using the __long representation, we need to // change the pointer to pointer into the module memory. auto is_small = -1 < (char)__s.size; - - // std::cout << "Short version of string has size " << (int)__s.size << std::endl; if(!is_small) { temp.data = __l.data.as_pointer(); @@ -162,4 +158,45 @@ namespace fugg { using String = BasicString; + template + class HashTable { + // struct __hash_node_base { + // using node_base_pointer = uintptr_t; + // using __first_node = __hash_node_base; + + // node_base_pointer next; + // }; + + // struct __hash_node : public __hash_node_base { + // typedef T __node_value_type; + + // size_t __hash_; + // __node_value_type __value_; + // }; + + + // using __node_pointer = __hash_node_base::node_base_pointer; + // using __node_base_type = __hash_node_base; + // using __next_pointer = __node_pointer; + + // using RawUniquePointer = detail::RawUniquePointer; + // using BucketList = RawUniquePointer<__next_pointer[]>; + // using __first_node = __hash_node_base::__first_node; + + // BucketList bucketlist; + // __first_node first; + + + + // typedef T* _NodePtr; + // typedef __hash_node_types<_NodePtr> type; + // typedef typename __make_hash_node_types::type _NodeTypes; + // typedef typename _NodeTypes::__next_pointer __next_pointer; + // typedef unique_ptr<__next_pointer[]> __bucket_list; + // __bucket_list __bucket_list_; + + // ModulePointer< + // RawUniquePointer bucket_list; + + }; } \ No newline at end of file