@DTS Engineer I know this that swift::Bool is compatible with c++ bool. What I wanted to ask is that in the documentation it is mentioned that Swift exposes UnsafeMutablePointer to C++ (link).
Quote
Pointer types, like OpaquePointer, UnsafePointer, UnsafeMutablePointer, UnsafeRawPointer and UnsafeMutableRawPointer
UnQuote
I directly want to use them in c++ as swift::UnsafeMutablePointer.
If it's not true what documentation mean, then what is the manifestation for exposing these UnsafeMutablePointer?
Post
Replies
Boosts
Views
Activity
@DTS Engineer I got your point and i was able to use the pointer in that way.
public func ReturnInteger() -> UnsafeMutablePointer<Int32> {
withUnsafeMutablePointer(to: &value) {pointer in
return pointer
}
}
void
CppClass::GetIntegerPointer() noexcept
{
int32_t * x = (int32_t *)Interop::ReturnInteger();
// The above way works but when i am trying to directly use
// swift::UnsafeMutablePointer<int32_t> x = (int32_t *) Interop::ReturnInteger ();
// it gives build error that UnsafeMutablePointer not found .
}
But in the documentation it's mentioned that it is exposed to C++.
Quote
Pointer types, like OpaquePointer, UnsafePointer, UnsafeMutablePointer, UnsafeRawPointer and UnsafeMutableRawPointer
UnQuote
Can you Explain what does this mean?
@Claude31 I can't use class type as this Data instance is provided to me by the OS whenever my Completion is been called w.r.t Receive.
Now I want to use this data instance in C++. For which basically I create a wrapper class over this and pass it as Opaque to C++.
Code Snippet
class DataHolder {
init () {}
public var data_wrapper : Data?
}
func ReceiveHandler (_ pContent : Data? ) -> UnsafeMutablePointer {
// pContent is only valid inside scope of this function .
// Create a instance of wrapper class
var x = DataHolder.init ()
// Copy being created here.
x.data_wrapper = pContent
return Unmanaged.passRetained (x).toOpaque ()
}
Problem is copy creation each time which i want to prevent.
@DTS Engineer Thanks I got the clarity regarding the ARC. I have a usecase where I get a Data Object in the CallBack I Register during the receive call. I want to pass the same Data Object to C++ without creating a Copy and ensuring that it remains valid until i am done with my operations in C++. Is there a way for that?
Hi @DTS Engineer, withUnsafeBytes is Deprecated with data Now, is there any other alternative way to do this.
Also just wanted to confirm that within the closure the Pointer to the bytes will always remain valid and it's ARC will not be decremented any how?
Yes It's related to Active Directory. Here I am not referring to the FQDN of the interfaces through which we are connected to Internet.
Just like hostname which helps us to identify a machine in a network. We can use network-name (local domain name) which is assigned to a machine and doesn't depend on the
interfaces, which can be used as an alternative of an IP-address.
Fully Qualified Domain Name which i means is hostname + network name (local domain name) which can be used to communicate with a machine.
No, i require the local domain assigned to a machine, just like we have in Windows. Hostname is used to identify a machine in network. I am able to get the hostname, how can i get FQDN (Fully Qualified Domain Name) which will be consisting of hostname.networkname for Ex - macofficestudio is my host name and thread.solutions.com is my network name (local domain name) so FQDN becomes macofficestudio.thread.solutions.com.
How to get that ??