AVPKit
IBuffer.cpp
1 /*******************************************************************************
2  * Copyright (c) 2024, 2026, Olivier Ayache. All rights reserved.
3  *
4  * This file is part of AVPKit.
5  *
6  * AVPKit is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * AVPKit is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with AVPKit. If not, see <http://www.gnu.org/licenses/>.
18  *******************************************************************************/
19 
20 #include <com/avpkit/ferry/Logger.h>
21 #include <com/avpkit/ferry/IBuffer.h>
22 #include <com/avpkit/ferry/Buffer.h>
23 
24 #include <stdexcept>
25 
26 using namespace com::avpkit::ferry;
27 
28 VS_LOG_SETUP(VS_CPP_PACKAGE);
29 
30 namespace com { namespace avpkit { namespace ferry
31 {
32 
33  IBuffer :: IBuffer()
34  {
35  }
36 
37  IBuffer :: ~IBuffer()
38  {
39  }
40 
41  IBuffer*
42  IBuffer :: make(com::avpkit::ferry::RefCounted* requestor, int32_t bufferSize)
43  {
44  return Buffer::make(requestor, bufferSize);
45  }
46 
47  IBuffer*
48  IBuffer :: make(RefCounted* requestor, void * bufToWrap,
49  int32_t bufferSize,
50  FreeFunc freeFunc,
51  void * closure)
52  {
53  return Buffer::make(requestor, bufToWrap, bufferSize, freeFunc, closure);
54  }
55 
56 
57  IBuffer*
59  Type type, int32_t numElements, bool zero)
60  {
61  return Buffer::make(requestor, type, numElements, zero);
62  }
63 
64  int32_t
66  {
67  return Buffer::getTypeSize(type);
68  }
69 
70 }}}
static VS_API_FERRY Buffer * make(RefCounted *requestor, int32_t bufferSize)
Allocate a new buffer of at least bufferSize.
Definition: Buffer.cpp:91
Allows Java code to get data from a native buffers, and optionally modify native memory directly.
Definition: IBuffer.h:54
static IBuffer * make(RefCounted *requestor, void *bufToWrap, int32_t bufferSize, FreeFunc freeFunc, void *closure)
Allocate a new buffer by wrapping a native buffer.
Definition: IBuffer.cpp:48
static int32_t getTypeSize(Type type)
Returns the size, in bytes, of elements of given Type.
Definition: IBuffer.cpp:65
Parent of all Ferry objects – it mains reference counts in native code.
Definition: RefCounted.h:85
This library contains routines used by AVPKit libraries for "ferry"ing Java objects to and from nativ...
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...