Skip to content

Commit

Permalink
Use stack semantics for marshal_context.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kovalenko committed Oct 31, 2014
1 parent f60f1a0 commit 9b78189
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
10 changes: 4 additions & 6 deletions src/editors/xrManagedApi/core/PostProcessAnimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,16 @@ void PostProcessInfo::ColorMappingInterpolate::set(float value) { impl->cm_inter
String^ PostProcessInfo::ColorMappingGradient1::get() { return gcnew String(impl->cm_tex1.c_str()); }
void PostProcessInfo::ColorMappingGradient1::set(String^ value)
{
auto context = gcnew marshal_context();
auto tmpStr = context->marshal_as<const char*>(value);
marshal_context context;
auto tmpStr = context.marshal_as<const char*>(value);
impl->cm_tex1 = tmpStr;
delete context;
}
String^ PostProcessInfo::ColorMappingGradient2::get() { return gcnew String(impl->cm_tex2.c_str()); }
void PostProcessInfo::ColorMappingGradient2::set(String^ value)
{
auto context = gcnew marshal_context();
auto tmpStr = context->marshal_as<const char*>(value);
marshal_context context;
auto tmpStr = context.marshal_as<const char*>(value);
impl->cm_tex2 = tmpStr;
delete context;
}
PostProcessInfo::PostProcessInfo(::SPPInfo* impl) { this->impl = impl; }
PostProcessInfo::PostProcessInfo(::SPPInfo* impl, bool dontDestroy) : PostProcessInfo(impl)
Expand Down
15 changes: 6 additions & 9 deletions src/editors/xrManagedApi/core/fs/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,15 @@ void WriterBase::WriteString(const char* buffer) { impl->w_string(buffer); }
void WriterBase::WriteStringZ(const char* buffer) { impl->w_stringZ(buffer); }
void WriterBase::WriteString(String^ value)
{
auto context = gcnew marshal_context();
auto tmpStr = context->marshal_as<const char*>(value);
marshal_context context;
auto tmpStr = context.marshal_as<const char*>(value);
impl->w_string(tmpStr);
delete context;
}
void WriterBase::WriteStringZ(String^ value)
{
auto context = gcnew marshal_context();
auto tmpStr = context->marshal_as<const char*>(value);
marshal_context context;
auto tmpStr = context.marshal_as<const char*>(value);
impl->w_stringZ(tmpStr);
delete context;
}
void WriterBase::WriteColorF(ColorF value) { impl->w_fcolor((const Fcolor&)value); }
void WriterBase::WriteVector4F(Vector4F value) { impl->w_fvector4((const Fvector4&)value); }
Expand All @@ -69,10 +67,9 @@ void WriterBase::WriteScaledDirection(Vector3F value) { impl->w_sdir((const Fvec
void WriterBase::WriteString(String^ format, ... array<Object^>^ args)
{
auto str = String::Format(format, args);
auto context = gcnew marshal_context();
auto tmpStr = context->marshal_as<const char*>(str);
marshal_context context;
auto tmpStr = context.marshal_as<const char*>(str);
impl->w(tmpStr, xr_strlen(tmpStr));
delete context;
}
void WriterBase::OpenChunk(UInt32 type) { impl->open_chunk(type); }
void WriterBase::CloseChunk() { impl->close_chunk(); }
Expand Down

0 comments on commit 9b78189

Please sign in to comment.