| Index: runtime/bin/filter.cc
|
| diff --git a/runtime/bin/filter.cc b/runtime/bin/filter.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c14b44fdeb02286279a2294d9f218f5a5aea54cf
|
| --- /dev/null
|
| +++ b/runtime/bin/filter.cc
|
| @@ -0,0 +1,76 @@
|
| +// Copyright (c) 2012, 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.
|
| +
|
| +#include "bin/filter.h"
|
| +#include "bin/dartutils.h"
|
| +
|
| +#include "include/dart_api.h"
|
| +
|
| +static const int kFilterPointerNativeField = 0;
|
| +
|
| +
|
| +void FUNCTION_NAME(Filter_CreateZLIB)(Dart_NativeArguments args) {
|
| + Dart_EnterScope();
|
| + Dart_Handle filter_obj = Dart_GetNativeArgument(args, 0);
|
| + Filter* filter = new ZLibFilter();
|
| + if (!filter->Init() ||
|
| + Dart_IsError(Filter::SetFilterPointerNativeField(filter_obj, filter))) {
|
| + OSError os_error(-1, "Failed to create ZLib filter", OSError::kUnknown);
|
| + Dart_Handle err = DartUtils::NewDartOSError(&os_error);
|
| + Dart_SetReturnValue(args, err);
|
| + } else {
|
| + Dart_SetReturnValue(args, Dart_True());
|
| + }
|
| + Dart_ExitScope();
|
| +}
|
| +
|
| +
|
| +void FUNCTION_NAME(Filter_Process)(Dart_NativeArguments args) {
|
| + Dart_EnterScope();
|
| + Dart_Handle filter_obj = Dart_GetNativeArgument(args, 0);
|
| + Filter* filter;
|
| + if (Dart_IsError(Filter::GetFilterPointerNativeField(filter_obj, &filter))) {
|
| + OSError os_error(-1, "Failed to get ZLib filter", OSError::kUnknown);
|
| + Dart_Handle err = DartUtils::NewDartOSError(&os_error);
|
| + Dart_SetReturnValue(args, err);
|
| + } else {
|
| + Dart_SetReturnValue(args, Dart_True());
|
| + }
|
| + Dart_ExitScope();
|
| +}
|
| +
|
| +
|
| +Dart_Handle Filter::SetFilterPointerNativeField(Dart_Handle filter,
|
| + Filter* filter_pointer) {
|
| + return Dart_SetNativeInstanceField(filter,
|
| + kFilterPointerNativeField,
|
| + (intptr_t)filter_pointer);
|
| +}
|
| +
|
| +
|
| +Dart_Handle Filter::GetFilterPointerNativeField(Dart_Handle filter,
|
| + Filter** filter_pointer) {
|
| + return Dart_GetNativeInstanceField(
|
| + filter,
|
| + kFilterPointerNativeField,
|
| + reinterpret_cast<intptr_t*>(filter_pointer));
|
| +}
|
| +
|
| +
|
| +ZLibFilter::~ZLibFilter() {
|
| + // FIXME: Change to ::End to be able to return status value?
|
| +}
|
| +
|
| +
|
| +bool ZLibFilter::Init() {
|
| + return true;
|
| +}
|
| +
|
| +
|
| +uint8_t* ZLibFilter::Process(uint8_t* data,
|
| + intptr_t length,
|
| + intptr_t& outputLength) {
|
| + return 0;
|
| +}
|
| +
|
|
|