Skip to content

Commit 27e6e02

Browse files
committed
Add namespaces to avoid symbol clashes
1 parent 8d6af65 commit 27e6e02

25 files changed

+103
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ OPT ?= -O3
2727

2828
PREFIX ?= /usr/local
2929

30-
CXXFLAGS ?= -g $(OPT) -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++0x -fPIC
30+
CXXFLAGS ?= -g $(OPT) -Wall -Wextra -Woverloaded-virtual -pedantic -std=c++17 -fPIC
3131
CXXFLAGS += -Iinclude -Ithird_party/md5 -Ithird_party/json -Ithird_party/rapidyaml/rapidyaml/src/ -Ithird_party/rapidyaml/rapidyaml/ext/c4core/src/
3232
CFLAGS ?= -g $(OPT) -Wall -Wextra -pedantic -std=c99 -fPIC
3333
CFLAGS += -Iinclude

core/ast.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ limitations under the License.
2929
#include "lexer.h"
3030
#include "unicode.h"
3131

32+
namespace jsonnet::internal {
33+
3234
enum ASTType {
3335
AST_APPLY,
3436
AST_APPLY_BRACE,
@@ -1092,4 +1094,6 @@ auto binary_map = build_binary_map();
10921094

10931095
} // namespace
10941096

1097+
} // namespace jsonnet::internal
1098+
10951099
#endif // JSONNET_AST_H

core/desugarer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ limitations under the License.
2525
#include "pass.h"
2626
#include "string_utils.h"
2727

28+
namespace jsonnet::internal {
29+
2830
static const Fodder EF; // Empty fodder.
2931

3032
static const LocationRange E; // Empty.
@@ -1011,3 +1013,5 @@ void jsonnet_desugar(Allocator *alloc, AST *&ast, std::map<std::string, VmExt> *
10111013
Desugarer desugarer(alloc);
10121014
desugarer.desugarFile(ast, tlas);
10131015
}
1016+
1017+
} // namespace jsonnet::internal

core/desugarer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ limitations under the License.
2323
#include "ast.h"
2424
#include "vm.h"
2525

26+
namespace jsonnet::internal {
27+
2628
/** Translate the AST to remove syntax sugar.
2729
* \param alloc Allocator for making new identifiers / ASTs.
2830
* \param ast The AST to change.
@@ -37,4 +39,6 @@ void jsonnet_desugar(Allocator *alloc, AST *&ast, std::map<std::string, VmExt> *
3739
*/
3840
DesugaredObject *makeStdlibAST(Allocator *alloc, std::string filename);
3941

42+
} // namespace jsonnet::internal
43+
4044
#endif

core/formatter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ limitations under the License.
2424
#include "string_utils.h"
2525
#include "unicode.h"
2626

27+
namespace jsonnet::internal {
28+
2729
static std::string unparse_id(const Identifier *id)
2830
{
2931
return encode_utf8(id->name);
@@ -2318,3 +2320,5 @@ std::string jsonnet_fmt(AST *ast, Fodder &final_fodder, const FmtOpts &opts)
23182320
}
23192321
return ss.str();
23202322
}
2323+
2324+
} // namespace jsonnet::internal

core/formatter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ limitations under the License.
1919

2020
#include "ast.h"
2121

22+
namespace jsonnet::internal {
23+
2224
struct FmtOpts {
2325
char stringStyle;
2426
char commentStyle;
@@ -51,4 +53,6 @@ struct FmtOpts {
5153
*/
5254
std::string jsonnet_fmt(AST *ast, Fodder &final_fodder, const FmtOpts &opts);
5355

56+
} // namespace jsonnet::internal
57+
5458
#endif // JSONNET_PARSER_H

core/lexer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ limitations under the License.
2424
#include "static_error.h"
2525
#include "unicode.h"
2626

27+
namespace jsonnet::internal {
28+
2729
static const std::vector<std::string> EMPTY;
2830

2931
/** Is the char whitespace (excluding \n). */
@@ -878,3 +880,5 @@ std::string jsonnet_unlex(const Tokens &tokens)
878880
}
879881
return ss.str();
880882
}
883+
884+
} // namespace jsonnet::internal

core/lexer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ limitations under the License.
2929
#include "static_error.h"
3030
#include "unicode.h"
3131

32+
namespace jsonnet::internal {
33+
3234
/** Whitespace and comments.
3335
*
3436
* "Fodder" (as in cannon fodder) implies this data is expendable.
@@ -406,4 +408,6 @@ Tokens jsonnet_lex(const std::string &filename, const char *input);
406408

407409
std::string jsonnet_unlex(const Tokens &tokens);
408410

411+
} // namespace jsonnet::internal
412+
409413
#endif // JSONNET_LEXER_H

core/lexer_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
#include <list>
2020
#include "gtest/gtest.h"
2121

22+
namespace jsonnet::internal {
2223
namespace {
2324

2425
void testLex(const char* name, const char* input, const std::list<Token>& tokens,
@@ -342,3 +343,4 @@ TEST(Lexer, TestComments)
342343
}
343344

344345
} // namespace
346+
} // namespace jsonnet::internal

core/libjsonnet.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ extern "C" {
3636
#include "static_analysis.h"
3737
#include "vm.h"
3838

39+
namespace {
40+
using ::jsonnet::internal::Allocator;
41+
using ::jsonnet::internal::AST;
42+
using ::jsonnet::internal::FmtOpts;
43+
using ::jsonnet::internal::Fodder;
44+
using ::jsonnet::internal::jsonnet_lex;
45+
using ::jsonnet::internal::RuntimeError;
46+
using ::jsonnet::internal::StaticError;
47+
using ::jsonnet::internal::Tokens;
48+
using ::jsonnet::internal::VmExt;
49+
using ::jsonnet::internal::VmNativeCallback;
50+
using ::jsonnet::internal::VmNativeCallbackMap;
51+
} // namespace
52+
3953
static void memory_panic(void)
4054
{
4155
fputs("FATAL ERROR: a memory allocation error occurred.\n", stderr);

0 commit comments

Comments
 (0)