Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1356 | 1356 |
| 1357 // External pprof support for gathering and dumping symbolic | 1357 // External pprof support for gathering and dumping symbolic |
| 1358 // information that can be used for better profile reports for | 1358 // information that can be used for better profile reports for |
| 1359 // dynamically generated code. | 1359 // dynamically generated code. |
| 1360 DART_EXPORT void Dart_InitPprofSupport(); | 1360 DART_EXPORT void Dart_InitPprofSupport(); |
| 1361 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); | 1361 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); |
| 1362 | 1362 |
| 1363 // --- Message encoding/decoding ---- | 1363 // --- Message encoding/decoding ---- |
| 1364 | 1364 |
| 1365 /** | 1365 /** |
| 1366 * A memory allocation function. | |
| 1367 * | |
| 1368 * Allocate a new piece of memory or change the size (ra-allocates) of | |
| 1369 * a previously allocated piece of memory. | |
| 1370 * | |
| 1371 * \param ptr NULL for new allocation and pointer to a previously | |
| 1372 * allocated piece of memory for re-allocation. | |
| 1373 * \param old_size 0 for new allocation and size of previously allocated | |
| 1374 * piece of memory for re-allocation. | |
| 1375 * \param new_size | |
| 1376 * | |
| 1377 * \return Address of newly allocated or re-allocated piece of | |
| 1378 * memory of size new_size. NULL if allocation fails. | |
| 1379 */ | |
| 1380 typedef uint8_t* (*Allocator)(uint8_t* ptr, | |
| 1381 intptr_t old_size, | |
| 1382 intptr_t new_size); | |
| 1383 | |
| 1384 /** | |
| 1366 * A Dart_CObject is used for representing Dart objects as native C | 1385 * A Dart_CObject is used for representing Dart objects as native C |
| 1367 * data outside the Dart heap. These objects are totally detached from | 1386 * data outside the Dart heap. These objects are totally detached from |
| 1368 * the Dart heap. Only a subset of the Dart objects have a | 1387 * the Dart heap. Only a subset of the Dart objects have a |
| 1369 * representation as a Dart_CObject. | 1388 * representation as a Dart_CObject. |
| 1370 */ | 1389 */ |
| 1371 struct Dart_CObject { | 1390 struct Dart_CObject { |
| 1372 enum Type { | 1391 enum Type { |
| 1373 kNull = 0, | 1392 kNull = 0, |
| 1374 kBool, | 1393 kBool, |
| 1375 kInt32, | 1394 kInt32, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1388 int length; | 1407 int length; |
| 1389 Dart_CObject** values; | 1408 Dart_CObject** values; |
| 1390 } as_array; | 1409 } as_array; |
| 1391 } value; | 1410 } value; |
| 1392 }; | 1411 }; |
| 1393 | 1412 |
| 1394 /** | 1413 /** |
| 1395 * A Dart_CMessage is used for encoding and decoding messages from native code. | 1414 * A Dart_CMessage is used for encoding and decoding messages from native code. |
| 1396 */ | 1415 */ |
| 1397 struct Dart_CMessage { | 1416 struct Dart_CMessage { |
| 1398 Dart_CObject** message; | 1417 Dart_CObject* object; |
| 1418 intptr_t allocated_length; | |
| 1419 Dart_CObject** allocated; | |
|
siva
2012/02/01 01:48:36
Do we need the allocated and allocated_length fiel
Søren Gjesse
2012/02/01 12:12:23
We don't need it if we decide to handle the decodi
| |
| 1420 uint8_t* original_message; | |
| 1421 intptr_t original_message_length; | |
|
siva
2012/02/01 01:48:36
Do we need the original message and length etc. ov
Søren Gjesse
2012/02/01 12:12:23
The reason they are here is that if we allow for t
| |
| 1399 }; | 1422 }; |
| 1400 | 1423 |
| 1424 /** | |
| 1425 * Decodes a Dart message into a Dart_CMessage structure. | |
| 1426 * | |
| 1427 * \param message Pointer to the raw encoded message. | |
| 1428 * \param length Length of the raw encoded message. | |
| 1429 * \param allocator The memory allocation function to use to allocate | |
| 1430 * the Dart_CMessage structure and the Dart_CObject structures making | |
| 1431 * up the decoded message. If NULL is passed standard stdlib | |
| 1432 * malloc/realloc/free is used. | |
| 1433 */ | |
| 1434 | |
| 1435 DART_EXPORT Dart_CMessage* Dart_DecodeMessage(uint8_t* message, | |
| 1436 intptr_t length, | |
| 1437 Allocator allocator); | |
|
turnidge
2012/01/31 22:20:42
Do we need this to be a public api? If the Dart_N
siva
2012/02/01 01:48:36
I agree with Todd, the native message handler coul
Søren Gjesse
2012/02/01 12:12:23
Maybe we don't. We could start out with delivering
Søren Gjesse
2012/02/01 12:12:23
I am fine with this - we can always add embedder c
| |
| 1438 // TODO(sgjesse): Remove length parameter if that is part of the | |
| 1439 // message header. | |
| 1440 // TODO(sgjesse): Should this function have flags for: | |
| 1441 // Don't fill in allocated (caller uses zone like allocation) | |
| 1442 // Don't Never point into original_message for e.g. byte arrays. | |
| 1443 | |
| 1401 #endif // INCLUDE_DART_API_H_ | 1444 #endif // INCLUDE_DART_API_H_ |
| OLD | NEW |