Skip to content

Commit df1bc5c

Browse files
authored
Replace cJSON value by our own. (#3837)
1 parent 3e0150e commit df1bc5c

File tree

25 files changed

+65
-61
lines changed

25 files changed

+65
-61
lines changed

CodeFormatter/CodeFormatterManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void CodeFormatterManager::Save()
8686
{
8787
wxFileName config_file{ clStandardPaths::Get().GetUserDataDir(), "code-formatters.json" };
8888
config_file.AppendDir("config");
89-
JSON root{ cJSON_Array };
89+
JSON root{JsonType::Array};
9090
auto arr = root.toElement();
9191
for (auto fmtr : m_formatters) {
9292
arr.arrayAppend(fmtr->ToJSON());

CodeLite/JSON.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
#include "clFontHelper.h"
3030
#include "fileutils.h"
3131

32-
#include <stdlib.h>
33-
#include <wx/dynarray.h>
34-
#include <wx/ffile.h>
3532
#include <wx/filename.h>
3633

3734
JSON::JSON(const wxString& text)
@@ -50,12 +47,12 @@ JSON::JSON(JSONItem item)
5047
{
5148
}
5249

53-
JSON::JSON(int type)
50+
JSON::JSON(JsonType type)
5451
: m_json(NULL)
5552
{
56-
if (type == cJSON_Array)
53+
if (type == JsonType::Array)
5754
m_json = cJSON_CreateArray();
58-
else if (type == cJSON_NULL)
55+
else if (type == JsonType::Null)
5956
m_json = cJSON_CreateNull();
6057
else
6158
m_json = cJSON_CreateObject();

CodeLite/JSON.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ class WXDLLIMPEXP_CL JSONItem
258258

259259
//////////////////////////////////////////////////////////////////////////
260260
//////////////////////////////////////////////////////////////////////////
261+
enum class JsonType
262+
{
263+
Array,
264+
Null,
265+
Object,
266+
};
261267

262268
class WXDLLIMPEXP_CL JSON
263269
{
@@ -266,11 +272,12 @@ class WXDLLIMPEXP_CL JSON
266272
wxString _errorString;
267273

268274
public:
269-
JSON(int type);
270-
JSON(const wxString& text);
271-
JSON(const wxFileName& filename);
272-
JSON(JSONItem item);
273-
JSON(cJSON* json);
275+
explicit JSON(JsonType type);
276+
explicit JSON(const wxString& text);
277+
explicit JSON(const wxFileName& filename);
278+
explicit JSON(JSONItem item);
279+
explicit JSON(cJSON* json);
280+
274281
virtual ~JSON();
275282

276283
void save(const wxFileName& fn) const;

CodeLite/LSP/InitializeRequest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ JSONItem LSP::InitializeRequest::ToJSON(const wxString& name) const
1717
json.append(params);
1818
params.addProperty("processId", GetProcessId());
1919
if (GetRootUri().IsEmpty()) {
20-
JSON nullItem(cJSON_NULL);
20+
JSON nullItem(JsonType::Null);
2121
JSONItem nullObj = nullItem.toElement();
2222
params.append(nullObj);
2323
(void)nullItem.release(); // don't delete it on destruction, it is now owned by 'params'

CodeLite/cl_config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ clConfig::clConfig(const wxString& filename)
7070
if (!m_filename.DirExists()) {
7171
m_filename.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
7272
}
73-
m_root = std::make_unique<JSON>(cJSON_Object);
73+
m_root = std::make_unique<JSON>(JsonType::Object);
7474
}
7575

7676
// Load the "Recent Items" cache

DebugAdapterClient/clDapSettingsStore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void clDapSettingsStore::Save(const wxFileName& path)
6060
if(!path.IsOk()) {
6161
return;
6262
}
63-
JSON root(cJSON_Array);
63+
JSON root(JsonType::Array);
6464
for(const auto& vt : m_entries) {
6565
root.toElement().arrayAppend(vt.second.To());
6666
}

LiteEditor/app.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ bool CodeLiteApp::IsSingleInstance(const wxCmdLineParser& m_parser)
868868
bool dummy;
869869
client.ConnectRemote("127.0.0.1", SINGLE_INSTANCE_PORT, dummy);
870870

871-
JSON json(cJSON_Object);
871+
JSON json(JsonType::Object);
872872
json.toElement().addProperty("args", files);
873873

874874
long lineNumber(0);

Plugin/ColoursAndFontsManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ LexerConf::Ptr_t ColoursAndFontsManager::GetLexer(const wxString& lexerName, con
382382
void ColoursAndFontsManager::Save(const wxFileName& lexer_json)
383383
{
384384
bool for_export = lexer_json.IsOk();
385-
JSON root(cJSON_Array);
385+
JSON root(JsonType::Array);
386386
JSONItem element = root.toElement();
387387
for (const auto& [_, lexers] : m_lexersMap) {
388388
for (const auto& lexer : lexers) {
@@ -578,7 +578,7 @@ wxFileName ColoursAndFontsManager::GetConfigFile() const
578578
void ColoursAndFontsManager::SaveGlobalSettings(bool notify)
579579
{
580580
// save the global settings
581-
JSON root(cJSON_Object);
581+
JSON root(JsonType::Object);
582582
root.toElement().addProperty("m_globalTheme", m_globalTheme);
583583
wxFileName fnSettings = GetConfigFile();
584584
root.save(fnSettings.GetFullPath());
@@ -1162,7 +1162,7 @@ bool ColoursAndFontsManager::ExportThemesToFile(const wxFileName& outputFile, co
11621162
M.insert(names.Item(i).Lower());
11631163
}
11641164

1165-
JSON root(cJSON_Array);
1165+
JSON root(JsonType::Array);
11661166
JSONItem arr = root.toElement();
11671167
std::vector<LexerConf::Ptr_t> Lexers;
11681168
for (const auto& lexer : m_allLexers) {

Plugin/FileSystemWorkspace/clFileSystemWorkspaceConfig.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ bool clFileSystemWorkspaceSettings::Save(const wxFileName& filename, const wxFil
372372
localWorkspace.AppendDir(".codelite");
373373
}
374374
localWorkspace.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
375-
JSON root_local(cJSON_Object);
376-
JSON root_shared(cJSON_Object);
375+
JSON root_local(JsonType::Object);
376+
JSON root_shared(JsonType::Object);
377377
378378
JSONItem itemLocal = root_local.toElement();
379379
JSONItem itemShared = root_shared.toElement();

Plugin/Keyboard/clKeyboardBindingConfig.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ clKeyboardBindingConfig& clKeyboardBindingConfig::Load()
5757

5858
clKeyboardBindingConfig& clKeyboardBindingConfig::Save()
5959
{
60-
JSON root(cJSON_Object);
60+
JSON root(JsonType::Object);
6161
JSONItem mainObj = root.toElement();
6262

6363
// set the version

0 commit comments

Comments
 (0)