-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* migrate cppcli support from https://github.com/iit-reacts/djinni/tree/iit * migrate csharp unit tests to be configured by cmake entirely * rename `--cpp-optional-header` from `<optional>` to `"optional"` because otherwise the command is broken on powershell * replace file(READ ...) with file(STRINGS ...) in Djinni.cmake because it is shorter * fix missing header <stdexcept> that the MSVC compiler complained about. Co-authored-by: Leandro Freitas <freitass@gmail.com> Co-authored-by: Harald <harald.achitz@gmail.com>
- Loading branch information
1 parent
df858bd
commit 35fdcac
Showing
36 changed files
with
1,548 additions
and
61 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
build/* | ||
.DS_Store | ||
*.pyc | ||
.idea/ | ||
cmake-build-debug/ | ||
check_install_root/ |
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,23 @@ | ||
// | ||
// Copyright 2021 cross-language-cpp | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#pragma once | ||
|
||
#ifdef _DEBUG | ||
#define ASSERT(condition, ...) ::System::Diagnostics::Debug::Assert(condition, ##__VA_ARGS__) | ||
#else | ||
#define ASSERT(condition, ...) // This macro will completely evaporate in Release. | ||
#endif |
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,70 @@ | ||
// | ||
// Copyright 2021 cross-language-cpp | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#pragma once | ||
|
||
#include "Assert.hpp" | ||
|
||
template <typename T> | ||
ref struct AutoPtr { | ||
AutoPtr() : _ptr(0) {} | ||
AutoPtr(T* ptr) : _ptr(ptr) {} | ||
AutoPtr(AutoPtr<T>% right) : _ptr(right.Release()) {} | ||
|
||
~AutoPtr() { | ||
delete _ptr; | ||
_ptr = 0; | ||
} | ||
!AutoPtr() { | ||
//ASSERT(0 == _ptr); | ||
delete _ptr; | ||
} | ||
T* operator->() { | ||
if (0 == _ptr) { | ||
throw gcnew System::ObjectDisposedException(System::String::Empty); | ||
} | ||
|
||
return _ptr; | ||
} | ||
|
||
T* GetPointer() { | ||
return _ptr; | ||
} | ||
T& GetRef() { | ||
if (0 == _ptr) { | ||
throw gcnew System::ObjectDisposedException(System::String::Empty); | ||
} | ||
|
||
return *_ptr; | ||
} | ||
T* Release() { | ||
T* released = _ptr; | ||
_ptr = 0; | ||
return released; | ||
} | ||
void Reset() { | ||
Reset(0); | ||
} | ||
void Reset(T* ptr) { | ||
if (ptr != _ptr) { | ||
delete _ptr; | ||
_ptr = ptr; | ||
} | ||
} | ||
|
||
private: | ||
T* _ptr; | ||
}; |
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,33 @@ | ||
// | ||
// Copyright 2021 cross-language-cpp | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#include "Error.hpp" | ||
|
||
namespace djinni { | ||
|
||
void ThrowUnimplemented(const char *, const char * msg) { | ||
throw gcnew System::NotImplementedException(msclr::interop::marshal_as<System::String^>(msg)); | ||
} | ||
|
||
void ThrowNativeExceptionFromCurrent(const char *) { | ||
try { | ||
throw; | ||
} catch (const std::exception & e) { | ||
throw gcnew System::Exception(msclr::interop::marshal_as<System::String^>(e.what())); | ||
} | ||
} | ||
|
||
} |
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,38 @@ | ||
// | ||
// Copyright 2021 cross-language-cpp | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#pragma once | ||
|
||
#include <msclr\marshal_cppstd.h> | ||
|
||
namespace djinni { | ||
|
||
// Throws an exception for an unimplemented method call. | ||
void ThrowUnimplemented(const char * ctx, const char * msg); | ||
|
||
// Helper function for exception translation. Do not call directly! | ||
void ThrowNativeExceptionFromCurrent(const char * ctx); | ||
|
||
} | ||
|
||
#define DJINNI_UNIMPLEMENTED(msg) \ | ||
::djinni::ThrowUnimplemented(__FUNCTION__, msg); \ | ||
return nullptr; // Silence warning C4715: not all control paths return a value | ||
|
||
#define DJINNI_TRANSLATE_EXCEPTIONS() \ | ||
catch (const std::exception&) { \ | ||
::djinni::ThrowNativeExceptionFromCurrent(__FUNCTION__); \ | ||
} |
Oops, something went wrong.