-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include "../global.h" | ||
#include "../spimpl.h" | ||
|
||
namespace libscratchcpp | ||
{ | ||
|
||
class IEngine; | ||
class Target; | ||
class CompilerContextPrivate; | ||
|
||
/*! \brief The CompilerContext represents a context for a specific target which is used with the Compiler class. */ | ||
class LIBSCRATCHCPP_EXPORT CompilerContext | ||
{ | ||
public: | ||
CompilerContext(IEngine *engine, Target *target); | ||
CompilerContext(const CompilerContext &) = delete; | ||
virtual ~CompilerContext() { } | ||
|
||
IEngine *engine() const; | ||
Target *target() const; | ||
|
||
private: | ||
spimpl::unique_impl_ptr<CompilerContextPrivate> impl; | ||
}; | ||
|
||
} // namespace libscratchcpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <scratchcpp/dev/compilercontext.h> | ||
|
||
#include "compilercontext_p.h" | ||
|
||
using namespace libscratchcpp; | ||
|
||
/*! Constructs CompilerContext. */ | ||
CompilerContext::CompilerContext(IEngine *engine, Target *target) : | ||
impl(spimpl::make_unique_impl<CompilerContextPrivate>(engine, target)) | ||
{ | ||
} | ||
|
||
/*! Returns the engine of the project. */ | ||
IEngine *CompilerContext::engine() const | ||
{ | ||
return impl->engine; | ||
} | ||
|
||
/*! Returns the target of this context. */ | ||
Target *CompilerContext::target() const | ||
{ | ||
return impl->target; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "compilercontext_p.h" | ||
|
||
using namespace libscratchcpp; | ||
|
||
CompilerContextPrivate::CompilerContextPrivate(IEngine *engine, Target *target) : | ||
engine(engine), | ||
target(target) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
namespace libscratchcpp | ||
{ | ||
|
||
class IEngine; | ||
class Target; | ||
|
||
struct CompilerContextPrivate | ||
{ | ||
CompilerContextPrivate(IEngine *engine, Target *target); | ||
|
||
IEngine *engine = nullptr; | ||
Target *target = nullptr; | ||
}; | ||
|
||
} // namespace libscratchcpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <scratchcpp/dev/compilercontext.h> | ||
#include <enginemock.h> | ||
#include <targetmock.h> | ||
|
||
using namespace libscratchcpp; | ||
|
||
TEST(CompilerContextTest, Constructors) | ||
{ | ||
EngineMock engine; | ||
TargetMock target; | ||
CompilerContext ctx(&engine, &target); | ||
ASSERT_EQ(ctx.engine(), &engine); | ||
ASSERT_EQ(ctx.target(), &target); | ||
} |