1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

[mujs] init maps

This commit is contained in:
Witold Filipczyk 2023-04-16 16:24:45 +02:00
parent 27bd4a529b
commit 992ebdee2d
3 changed files with 80 additions and 0 deletions
src/ecmascript

View File

@ -24,6 +24,14 @@ attr_save_in_map(void *m, void *node, void *value)
(*mapa)[node] = value;
}
void *
attr_create_new_map(void)
{
std::map<void *, void *> *mapa = new std::map<void *, void *>;
return (void *)mapa;
}
void *
attr_create_new_attrs_map(void)
{

View File

@ -8,10 +8,27 @@ extern "C" {
struct mjs_xhr;
extern void *map_attrs;
extern void *map_attributes;
extern void *map_rev_attributes;
extern void *map_collections;
extern void *map_rev_collections;
extern void *map_doctypes;
extern void *map_elements;
extern void *map_privates;
extern void *map_form_elements;
extern void *map_elements_form;
extern void *map_form;
extern void *map_rev_form;
extern void *map_forms;
extern void *map_rev_forms;
extern void *map_inputs;
extern void *map_nodelist;
extern void *map_rev_nodelist;
void attr_save_in_map(void *m, void *node, void *value);
void *attr_create_new_attrs_map(void);
void *attr_create_new_map(void);
void *attr_find_in_map(void *m, void *node);
@ -20,6 +37,7 @@ void attr_erase_from_map(void *m, void *node);
void attr_clear_map(void *m);
void attr_clear_map_str(void *m);
void delete_map_str(void *m);
void attr_delete_map(void *m);
void *attr_create_new_requestHeaders_map(void);
void *attr_create_new_responseHeaders_map(void);

View File

@ -24,6 +24,7 @@
#include "document/renderer.h"
#include "document/view.h"
#include "ecmascript/ecmascript.h"
#include "ecmascript/libdom/mujs/mapa.h"
#include "ecmascript/mujs.h"
#include "ecmascript/mujs/console.h"
#include "ecmascript/mujs/document.h"
@ -64,12 +65,65 @@
static void
mujs_init(struct module *xxx)
{
map_attrs = attr_create_new_map();
map_attributes = attr_create_new_map();
map_rev_attributes = attr_create_new_map();
map_collections = attr_create_new_map();
map_rev_collections = attr_create_new_map();
map_doctypes = attr_create_new_map();
map_elements = attr_create_new_map();
map_privates = attr_create_new_map();
map_form_elements = attr_create_new_map();
map_elements_form = attr_create_new_map();
map_form = attr_create_new_map();
map_rev_form = attr_create_new_map();
map_forms = attr_create_new_map();
map_rev_forms = attr_create_new_map();
map_inputs = attr_create_new_map();
map_nodelist = attr_create_new_map();
map_rev_nodelist = attr_create_new_map();
//js_module_init_ok = spidermonkey_runtime_addref();
}
static void
mujs_done(struct module *xxx)
{
attr_clear_map(map_attrs);
attr_clear_map(map_attributes);
attr_clear_map(map_rev_attributes);
attr_clear_map(map_collections);
attr_clear_map(map_rev_collections);
attr_clear_map(map_doctypes);
attr_clear_map(map_elements);
attr_clear_map(map_privates);
attr_clear_map(map_form_elements);
attr_clear_map(map_elements_form);
attr_clear_map(map_form);
attr_clear_map(map_rev_form);
attr_clear_map(map_forms);
attr_clear_map(map_rev_forms);
attr_clear_map(map_inputs);
attr_clear_map(map_nodelist);
attr_clear_map(map_rev_nodelist);
attr_delete_map(map_attrs);
attr_delete_map(map_attributes);
attr_delete_map(map_rev_attributes);
attr_delete_map(map_collections);
attr_delete_map(map_rev_collections);
attr_delete_map(map_doctypes);
attr_delete_map(map_elements);
attr_delete_map(map_privates);
attr_delete_map(map_form_elements);
attr_delete_map(map_elements_form);
attr_delete_map(map_form);
attr_delete_map(map_rev_form);
attr_delete_map(map_forms);
attr_delete_map(map_rev_forms);
attr_delete_map(map_inputs);
attr_delete_map(map_nodelist);
attr_delete_map(map_rev_nodelist);
// if (js_module_init_ok)
// spidermonkey_runtime_release();
}