Discussion:
[dart-misc] What exactly is the Dart_Handle type?
Benjamin Summerton (@def-pri-pub)
2016-10-04 18:06:58 UTC
Permalink
I've been a little interested lately in doing some Dart native development,
and everywhere I've seen this `Dart_Handle` type. When poking through
through the source, this is all that I could find on it
<https://github.com/dart-lang/sdk/blob/12f86594ecc32d7fa0c513fcc960d9adaee13428/runtime/include/dart_api.h#L251>.
Which is just a typdef to a `_Dart_Handle *`, which I couldn't find
anything else on in the SDK repo.

So my question is the title of the topic: "What exactly is the Dart_Handle
type?"
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Michael Francis
2016-10-04 18:12:44 UTC
Permalink
Dart_Handle is a reference to a Dart Object. To use the Dart_Handle you
will need to use the other methods found in dart_api.h
Starting about line number 1361 you will begin to see functions that
translate a Dart_Handle to c types.
Post by Benjamin Summerton (@def-pri-pub)
I've been a little interested lately in doing some Dart native
development, and everywhere I've seen this `Dart_Handle` type. When poking
through through the source, this is all that I could find on it
<https://github.com/dart-lang/sdk/blob/12f86594ecc32d7fa0c513fcc960d9adaee13428/runtime/include/dart_api.h#L251>.
Which is just a typdef to a `_Dart_Handle *`, which I couldn't find
anything else on in the SDK repo.
So my question is the title of the topic: "What exactly is the Dart_Handle
type?"
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'William Hesse' via Dart Misc
2016-10-04 19:50:10 UTC
Permalink
To be more clear about the purpose of Dart_Handle:

Because Dart has a garbage-collected heap of objects, and the garbage
collector can move objects around, you can't keep pointers to objects in
C++ code that could be interrupted by garbage collections. So you allocate
Dart_Handles, which are a bunch of places THAT THE GC KNOWS ABOUT holding
pointers to objects. That way, when the GC moves an object, it updates the
pointer in that place (that Dart_Handle). So your C++ code, but more
importantly the Dart embedding API calls that your code makes, can grab the
object pointer out of that handle and do stuff with it (but reloading the
pointer from the handle any time a GC could have happened).

The Dart_Handles that the GC knows about can be created in various ways: in
Zones, as permanent handles, etc. You can't just make one using 'new'.
The memory management of the handles has to be done more carefully and
explicitly, and they aren't GCd, since their reason for existing is to be a
C++ pointer that isn't touched by the GC, that points to a Dart object
pointer.
Post by Michael Francis
Dart_Handle is a reference to a Dart Object. To use the Dart_Handle you
will need to use the other methods found in dart_api.h
Starting about line number 1361 you will begin to see functions that
translate a Dart_Handle to c types.
Post by Benjamin Summerton (@def-pri-pub)
I've been a little interested lately in doing some Dart native
development, and everywhere I've seen this `Dart_Handle` type. When poking
through through the source, this is all that I could find on it
<https://github.com/dart-lang/sdk/blob/12f86594ecc32d7fa0c513fcc960d9adaee13428/runtime/include/dart_api.h#L251>.
Which is just a typdef to a `_Dart_Handle *`, which I couldn't find
anything else on in the SDK repo.
So my question is the title of the topic: "What exactly is the
Dart_Handle type?"
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
William Hesse
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Continue reading on narkive:
Loading...