Files
sdk/runtime/vm/dart_api_impl.h
T
turnidge@google.com a31b5a59f7 Start using UNWRAP_NONNULL to check inputs to dart api functions.
Improve a few error messages.

Lots of testing.
Review URL: http://codereview.chromium.org//8528018

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1712 260f80e4-7a28-3924-810f-c04153c831b5
2011-11-21 19:09:51 +00:00

73 lines
2.4 KiB
C++

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef VM_DART_API_IMPL_H_
#define VM_DART_API_IMPL_H_
#include "vm/allocation.h"
#include "vm/object.h"
namespace dart {
class ApiState;
class LocalHandle;
class PersistentHandle;
#define DARTSCOPE(isolate) \
ASSERT(isolate != NULL); \
Zone zone(isolate); \
HANDLESCOPE(isolate); \
class Api : AllStatic {
public:
// Creates a new local handle.
static Dart_Handle NewLocalHandle(const Object& object);
// Unwraps the raw object from the handle.
static RawObject* UnwrapHandle(Dart_Handle object);
// Unwraps a raw Type from the handle. The handle will be null if
// the object was not of the requested Type.
#define DECLARE_UNWRAP(Type) \
static const Type& Unwrap##Type##Handle(Dart_Handle object);
CLASS_LIST_NO_OBJECT(DECLARE_UNWRAP)
#undef DECLARE_UNWRAP
// Validates and converts the passed in handle as a local handle.
static LocalHandle* UnwrapAsLocalHandle(const ApiState& state,
Dart_Handle object);
// Validates and converts the passed in handle as a persistent handle.
static PersistentHandle* UnwrapAsPersistentHandle(const ApiState& state,
Dart_Handle object);
// Gets the handle used to designate successful return.
static Dart_Handle Success();
// Generates a handle used to designate an error return.
static Dart_Handle Error(const char* format, ...);
// Generates an error handle from an unhandled exception.
static Dart_Handle ErrorFromException(const Object& obj);
// Gets a handle to Null.
static Dart_Handle Null();
// Gets a handle to True.
static Dart_Handle True();
// Gets a handle to False
static Dart_Handle False();
// Allocates space in the local zone.
static uword Allocate(intptr_t size);
// Reallocates space in the local zone.
static uword Reallocate(uword ptr, intptr_t old_size, intptr_t new_size);
};
} // namespace dart.
#endif // VM_DART_API_IMPL_H_