[poincare] Init Poincare by creating a shared TreePool

This commit is contained in:
Léa Saviot
2018-08-30 10:53:06 +02:00
parent 4caf17258d
commit e9be5c6dbf
4 changed files with 11 additions and 6 deletions

View File

@@ -1,7 +1,11 @@
#include "apps_container_storage.h"
#include "global_preferences.h"
#include <poincare/init.h>
void ion_main(int argc, char * argv[]) {
// Initialize Poincare::TreePool::sharedPool
Poincare::init();
#if EPSILON_GETOPT
for (int i=1; i<argc; i++) {
if (argv[i][0] != '-' || argv[i][1] != '-') {

View File

@@ -33,6 +33,10 @@ objs += $(addprefix poincare/src/,\
vertical_offset_layout_node.o\
)
objs += $(addprefix poincare/src/,\
init.o\
)
objs += $(addprefix poincare/src/,\
absolute_value.o\
addition.o\

View File

@@ -20,7 +20,8 @@ class TreePool {
public:
static constexpr int NoNodeIdentifier = -1;
static TreePool * sharedPool();
static TreePool * sharedPool() { assert(SharedPool != nullptr); return SharedPool; }
void registerPool(TreePool * pool) { assert(SharedPool == nullptr); SharedPool = pool; }
// Node
TreeNode * node(int identifier) const {
@@ -128,6 +129,7 @@ private:
constexpr static int BufferSize = 32768;
constexpr static int MaxNumberOfNodes = BufferSize/sizeof(TreeNode);
constexpr static int MaxNumberOfStaticNodes = 200; // TODO: count how may are needed
static TreePool * SharedPool = nullptr;
// TreeNode
void discardTreeNode(TreeNode * node) {

View File

@@ -5,11 +5,6 @@
namespace Poincare {
TreePool * TreePool::sharedPool() {
static TreePool pool;
return &pool;
}
static void memmove32(uint32_t * dst, uint32_t * src, size_t len) {
if (src < dst && dst < src + len) {
/* Copy backwards to avoid overwrites */