2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
7 #include "native_client/src/include/portability.h"
9 #include "native_client/src/shared/platform/nacl_check.h"
10 #include "native_client/src/shared/platform/nacl_log.h"
12 #include "native_client/src/trusted/gio/gio_nacl_desc.h"
14 #include "native_client/src/trusted/desc/nacl_desc_base.h"
16 const struct GioVtbl kNaClGioNaClDescVtbl;
18 int NaClGioNaClDescCtor(struct NaClGioNaClDesc *self,
19 struct NaClDesc *wrapped) {
20 self->wrapped = NaClDescRef(wrapped);
21 NACL_VTBL(Gio, self) = &kNaClGioNaClDescVtbl;
25 static ssize_t NaClGioNaClDescRead(struct Gio *vself,
28 struct NaClGioNaClDesc *self = (struct NaClGioNaClDesc *) vself;
30 return (*NACL_VTBL(NaClDesc, self->wrapped)->
31 Read)(self->wrapped, buf, count);
34 static ssize_t NaClGioNaClDescWrite(struct Gio *vself,
37 struct NaClGioNaClDesc *self = (struct NaClGioNaClDesc *) vself;
39 return (*NACL_VTBL(NaClDesc, self->wrapped)->
40 Write)(self->wrapped, buf, count);
43 static off_t NaClGioNaClDescSeek(struct Gio *vself,
46 struct NaClGioNaClDesc *self = (struct NaClGioNaClDesc *) vself;
48 return (off_t) (*NACL_VTBL(NaClDesc, self->wrapped)->
49 Seek)(self->wrapped, (nacl_off64_t) offset, whence);
52 static int NaClGioNaClDescFlush(struct Gio *vself) {
53 UNREFERENCED_PARAMETER(vself);
57 static int NaClGioNaClDescClose(struct Gio *vself) {
58 struct NaClGioNaClDesc *self = (struct NaClGioNaClDesc *) vself;
60 NaClDescUnref(self->wrapped);
65 static void NaClGioNaClDescDtor(struct Gio *vself) {
66 struct NaClGioNaClDesc *self = (struct NaClGioNaClDesc *) vself;
68 if (NULL != self->wrapped) {
69 NaClDescUnref(self->wrapped);
72 NACL_VTBL(Gio, self) = NULL;
73 /* Gio base class has no Dtor */
76 const struct GioVtbl kNaClGioNaClDescVtbl = {