Skip to content

Commit

Permalink
Remove unused JS global IDs (#6192)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyashton authored May 21, 2024
1 parent 57a1e00 commit 8ced795
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 63 deletions.
9 changes: 1 addition & 8 deletions src/js/core/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ namespace ccf::js::core
std::vector<std::pair<JSClassID, JSClassDef*>> classes{
{kv_class_id, &kv_class_def},
{kv_historical_class_id, &kv_historical_class_def},
{kv_map_handle_class_id, &kv_map_handle_class_def},
{node_class_id, &node_class_def},
{network_class_id, &network_class_def},
{rpc_class_id, &rpc_class_def},
{host_class_id, &host_class_def},
{consensus_class_id, &consensus_class_def},
{historical_class_id, &historical_class_def},
{historical_state_class_id, &historical_state_class_def}};
{kv_map_handle_class_id, &kv_map_handle_class_def}};
for (auto [class_id, class_def] : classes)
{
auto ret = JS_NewClass(rt, class_id, class_def);
Expand Down
1 change: 0 additions & 1 deletion src/js/extensions/ccf/consensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "ccf/base_endpoint_registry.h"
#include "js/checks.h"
#include "js/core/context.h"
#include "js/global_class_ids.h"

#include <quickjs/quickjs.h>

Expand Down
1 change: 0 additions & 1 deletion src/js/extensions/ccf/gov_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "ccf/version.h"
#include "js/core/context.h"
#include "js/global_class_ids.h"
#include "js/modules.h"
#include "node/rpc/jwt_management.h"

Expand Down
1 change: 0 additions & 1 deletion src/js/extensions/ccf/historical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "js/checks.h"
#include "js/core/context.h"
#include "js/extensions/ccf/kv_helpers.h"
#include "js/global_class_ids.h"
#include "kv/untyped_map.h"

namespace ccf::js::extensions
Expand Down
1 change: 0 additions & 1 deletion src/js/extensions/ccf/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "js/extensions/ccf/host.h"

#include "js/core/context.h"
#include "js/global_class_ids.h"

#include <quickjs/quickjs.h>

Expand Down
1 change: 0 additions & 1 deletion src/js/extensions/ccf/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "js/extensions/ccf/network.h"

#include "js/core/context.h"
#include "js/global_class_ids.h"
#include "node/network_state.h"

#include <quickjs/quickjs.h>
Expand Down
1 change: 0 additions & 1 deletion src/js/extensions/ccf/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "js/extensions/ccf/node.h"

#include "js/core/context.h"
#include "js/global_class_ids.h"
#include "node/rpc/gov_logging.h"

#include <quickjs/quickjs.h>
Expand Down
1 change: 0 additions & 1 deletion src/js/extensions/ccf/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "ccf/rpc_context.h"
#include "js/core/context.h"
#include "js/global_class_ids.h"

#include <quickjs/quickjs.h>

Expand Down
35 changes: 0 additions & 35 deletions src/js/global_class_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,9 @@ namespace ccf::js
JSClassID kv_class_id = 0;
JSClassID kv_historical_class_id = 0;
JSClassID kv_map_handle_class_id = 0;
JSClassID node_class_id = 0;
JSClassID network_class_id = 0;
JSClassID rpc_class_id = 0;
JSClassID host_class_id = 0;
JSClassID consensus_class_id = 0;
JSClassID historical_class_id = 0;
JSClassID historical_state_class_id = 0;

JSClassDef kv_map_handle_class_def = {};
JSClassDef kv_historical_map_handle_class_def = {};
JSClassDef node_class_def = {};
JSClassDef network_class_def = {};
JSClassDef rpc_class_def = {};
JSClassDef host_class_def = {};
JSClassDef consensus_class_def = {};
JSClassDef historical_class_def = {};
JSClassDef historical_state_class_def = {};

void register_class_ids()
{
Expand All @@ -36,26 +22,5 @@ namespace ccf::js

JS_NewClassID(&kv_map_handle_class_id);
kv_map_handle_class_def.class_name = "KV Map Handle";

JS_NewClassID(&node_class_id);
node_class_def.class_name = "Node";

JS_NewClassID(&network_class_id);
network_class_def.class_name = "Network";

JS_NewClassID(&rpc_class_id);
rpc_class_def.class_name = "RPC";

JS_NewClassID(&host_class_id);
host_class_def.class_name = "Host";

JS_NewClassID(&consensus_class_id);
consensus_class_def.class_name = "Consensus";

JS_NewClassID(&historical_class_id);
historical_class_def.class_name = "Historical";

JS_NewClassID(&historical_state_class_id);
historical_state_class_def.class_name = "HistoricalState";
}
}
13 changes: 0 additions & 13 deletions src/js/global_class_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,11 @@ namespace ccf::js
extern JSClassID kv_class_id;
extern JSClassID kv_historical_class_id;
extern JSClassID kv_map_handle_class_id;
extern JSClassID node_class_id;
extern JSClassID network_class_id;
extern JSClassID rpc_class_id;
extern JSClassID host_class_id;
extern JSClassID consensus_class_id;
extern JSClassID historical_class_id;
extern JSClassID historical_state_class_id;

extern JSClassDef kv_class_def;
extern JSClassDef kv_historical_class_def;
extern JSClassDef kv_map_handle_class_def;
extern JSClassDef kv_historical_map_handle_class_def;
extern JSClassDef node_class_def;
extern JSClassDef network_class_def;
extern JSClassDef rpc_class_def;
extern JSClassDef host_class_def;
extern JSClassDef consensus_class_def;
extern JSClassDef historical_class_def;
extern JSClassDef historical_state_class_def;

// Not thread-safe, must happen exactly once
Expand Down

0 comments on commit 8ced795

Please sign in to comment.