Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: runtime/include/dart_api.h

Issue 9325022: Decode the Dart message into a Dart_CMessage structure before calling the native port callback (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from asiva@ Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/dart.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef INCLUDE_DART_API_H_ 5 #ifndef INCLUDE_DART_API_H_
6 #define INCLUDE_DART_API_H_ 6 #define INCLUDE_DART_API_H_
7 7
8 /** \mainpage Dart Embedding API Reference 8 /** \mainpage Dart Embedding API Reference
9 * 9 *
10 * Dart is a class-based programming language for creating structured 10 * Dart is a class-based programming language for creating structured
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 * 528 *
529 * Requires there to be a current isolate. 529 * Requires there to be a current isolate.
530 * 530 *
531 * \param port The destination port. 531 * \param port The destination port.
532 * \param object An object from the current isolate. 532 * \param object An object from the current isolate.
533 * 533 *
534 * \return True if the message was posted. 534 * \return True if the message was posted.
535 */ 535 */
536 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object); 536 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object);
537 537
538 // --- Message sending/receiving from native code ----
539
540 /**
541 * A Dart_CObject is used for representing Dart objects as native C
542 * data outside the Dart heap. These objects are totally detached from
543 * the Dart heap. Only a subset of the Dart objects have a
544 * representation as a Dart_CObject.
545 */
546 struct Dart_CObject {
547 enum Type {
548 kNull = 0,
549 kBool,
550 kInt32,
551 kDouble,
552 kString,
553 kArray,
554 kNumberOfTypes
555 };
556 Type type;
557 union {
558 bool as_bool;
559 int32_t as_int32;
560 double as_double;
561 char* as_string;
562 struct {
563 int length;
564 Dart_CObject** values;
565 } as_array;
566 } value;
567 };
568
569 /**
570 * Posts a message on some port. The message will contain the
571 * Dart_CObject object graph rooted in 'message'.
572 *
573 * While the message is being sent the state of the graph of
574 * Dart_CObject structures rooted in 'message' should not be accessed,
575 * as the message generation will make temporary modifications to the
576 * data. When the message has been sent the graph will be fully
577 * restored.
578 *
579 * \param port_id The destination port.
580 * \param message The message to send.
581 *
582 * \return True if the message was posted.
583 */
584 DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message);
585
538 /** 586 /**
539 * A native message handler. 587 * A native message handler.
540 * 588 *
541 * This handler is associated with a native port by calling 589 * This handler is associated with a native port by calling
542 * Dart_NewNativePort. 590 * Dart_NewNativePort.
591 *
592 * The message received is decoded into the message structure. The
593 * lifetime of the message data is controlled by the caller. All the
594 * data references from the message are allocated by the caller and
595 * will be reclaimed when returning to it.
543 */ 596 */
597
544 typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id, 598 typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id,
545 Dart_Port reply_port_id, 599 Dart_Port reply_port_id,
546 uint8_t* data); 600 Dart_CObject* message);
547 // TODO(turnidge): Make this function take more appropriate arguments.
548 601
549 /** 602 /**
550 * Creates a new native port. When messages are received on this 603 * Creates a new native port. When messages are received on this
551 * native port, then they will be dispatched to the provided native 604 * native port, then they will be dispatched to the provided native
552 * message handler. 605 * message handler.
553 * 606 *
554 * \param name The name of this port in debugging messages. 607 * \param name The name of this port in debugging messages.
555 * \param handler The C handler to run when messages arrive on the port. 608 * \param handler The C handler to run when messages arrive on the port.
556 * \param handle_concurrently Is it okay to process requests on this 609 * \param handle_concurrently Is it okay to process requests on this
557 * native port concurrently? 610 * native port concurrently?
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 // TODO(turnidge): Rename to Dart_LibrarySetNativeResolver? 1460 // TODO(turnidge): Rename to Dart_LibrarySetNativeResolver?
1408 1461
1409 // --- Profiling support ---- 1462 // --- Profiling support ----
1410 1463
1411 // External pprof support for gathering and dumping symbolic 1464 // External pprof support for gathering and dumping symbolic
1412 // information that can be used for better profile reports for 1465 // information that can be used for better profile reports for
1413 // dynamically generated code. 1466 // dynamically generated code.
1414 DART_EXPORT void Dart_InitPprofSupport(); 1467 DART_EXPORT void Dart_InitPprofSupport();
1415 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); 1468 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size);
1416 1469
1417 // --- Message sending/receiving from native code ----
1418
1419 /**
1420 * A Dart_CObject is used for representing Dart objects as native C
1421 * data outside the Dart heap. These objects are totally detached from
1422 * the Dart heap. Only a subset of the Dart objects have a
1423 * representation as a Dart_CObject.
1424 */
1425 struct Dart_CObject {
1426 enum Type {
1427 kNull = 0,
1428 kBool,
1429 kInt32,
1430 kDouble,
1431 kString,
1432 kArray,
1433 kNumberOfTypes
1434 };
1435 Type type;
1436 union {
1437 bool as_bool;
1438 int32_t as_int32;
1439 double as_double;
1440 char* as_string;
1441 struct {
1442 int length;
1443 Dart_CObject** values;
1444 } as_array;
1445 } value;
1446 };
1447
1448 /**
1449 * Posts a message on some port. The message will contain the
1450 * Dart_CObject object graph rooted in 'message'.
1451 *
1452 * While the message is being sent the state of the graph of
1453 * Dart_CObject structures rooted in 'message' should not be accessed,
1454 * as the message generation will make temporary modifications to the
1455 * data. When the message has been sent the graph will be fully
1456 * restored.
1457 *
1458 * \param port_id The destination port.
1459 * \param message The message to send.
1460 *
1461 * \return True if the message was posted.
1462 */
1463 DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message);
1464
1465 #endif // INCLUDE_DART_API_H_ 1470 #endif // INCLUDE_DART_API_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698