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

Unified Diff: runtime/bin/filter.cc

Issue 11198034: Introduce (private) ZLibFilter to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/filter.h ('k') | runtime/bin/filter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
+
« no previous file with comments | « runtime/bin/filter.h ('k') | runtime/bin/filter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698