Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit be87e38

Browse files
committed
libfoundation: Add MCStringCreateWithBSTR()
`BSTR` is a string type used by COM, Automation and Interop functions in the Windows API.
1 parent 09a6592 commit be87e38

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

libfoundation/include/foundation.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,6 +2145,11 @@ MC_DLLEXPORT bool MCStringCreateWithPascalString(const unsigned char* pascal_str
21452145
MC_DLLEXPORT bool MCStringCreateWithSysString(const char *sys_string, MCStringRef &r_string);
21462146
#endif
21472147

2148+
#if defined(__WINDOWS__)
2149+
// Create a string from a Windows BSTR
2150+
MC_DLLEXPORT bool MCStringCreateWithBSTR(const BSTR p_bstr, MCStringRef& r_string);
2151+
#endif
2152+
21482153
// Creates a string from existing strings. The first variant exists to provide
21492154
// an optimised implementation in the (very common) case of only two strings.
21502155
MC_DLLEXPORT bool MCStringCreateWithStrings(MCStringRef& r_string, MCStringRef p_one, MCStringRef p_two);

libfoundation/src/foundation-string.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6820,6 +6820,23 @@ __MCStringCreateWithStrings(MCStringRef& r_string, bool p_has_separator, unichar
68206820
return t_success;
68216821
}
68226822

6823+
////////////////////////////////////////////////////////////////////////
6824+
6825+
#if defined(__WINDOWS__)
6826+
6827+
MC_DLLEXPORT_DEF bool
6828+
MCStringCreateWithBSTR(const BSTR p_bstr,
6829+
MCStringRef& r_string)
6830+
{
6831+
return MCStringCreateWithChars(p_bstr,
6832+
SysStringLen(p_bstr),
6833+
r_string);
6834+
}
6835+
6836+
#endif /*__WINDOWS__*/
6837+
6838+
////////////////////////////////////////////////////////////////////////
6839+
68236840
MC_DLLEXPORT_DEF
68246841
bool
68256842
MCStringCreateWithStrings(MCStringRef& r_string, MCStringRef p_one, MCStringRef p_two)

0 commit comments

Comments
 (0)