fix refactored code.

This commit is contained in:
Jordan 2024-03-13 10:26:37 -07:00
parent cc317d0d24
commit 9f641ffbf7
6 changed files with 78 additions and 55 deletions

View File

@ -3,11 +3,12 @@ name: LibDartOpenMVG
description: |
Dart bindings for the OpenMVG library.
output: 'lib/libdart_openmvg_generated.dart'
compiler-opts: '-I/usr/include -L /usr/lib/ -lpng'
headers:
entry-points:
- 'src/frame.h'
- 'src/image.h'
include-directives:
- 'src/frame.h'
- 'src/image.h'
preamble: |
// ignore_for_file: always_specify_types

View File

@ -25,50 +25,22 @@ class LibDartOpenMVG {
lookup)
: _lookup = lookup;
ffi.Pointer<ImageResult> image_result_new(
ffi.Pointer<u_char> arg0,
int data_len,
ffi.Pointer<FILE> make_buffer(
ffi.Pointer<ffi.Uint8> arg0,
int arg1,
) {
return _image_result_new(
return _make_buffer(
arg0,
data_len,
arg1,
);
}
late final _image_result_newPtr = _lookup<
late final _make_bufferPtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<ImageResult> Function(
ffi.Pointer<u_char>, ffi.Size)>>('image_result_new');
late final _image_result_new = _image_result_newPtr.asFunction<
ffi.Pointer<ImageResult> Function(ffi.Pointer<u_char>, int)>();
ffi.Pointer<ImageResult> image_result_new_error(
int error_t,
) {
return _image_result_new_error(
error_t,
);
}
late final _image_result_new_errorPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ImageResult> Function(ffi.Int)>>(
'image_result_new_error');
late final _image_result_new_error = _image_result_new_errorPtr
.asFunction<ffi.Pointer<ImageResult> Function(int)>();
int image_result_free(
ffi.Pointer<ImageResult> arg0,
) {
return _image_result_free(
arg0,
);
}
late final _image_result_freePtr =
_lookup<ffi.NativeFunction<ffi.Int Function(ffi.Pointer<ImageResult>)>>(
'image_result_free');
late final _image_result_free = _image_result_freePtr
.asFunction<int Function(ffi.Pointer<ImageResult>)>();
ffi.Pointer<FILE> Function(
ffi.Pointer<ffi.Uint8>, ffi.Size)>>('make_buffer');
late final _make_buffer = _make_bufferPtr
.asFunction<ffi.Pointer<FILE> Function(ffi.Pointer<ffi.Uint8>, int)>();
ffi.Pointer<Frame> new_frame_from_handle(
ffi.Pointer<FILE> arg0,
@ -115,6 +87,51 @@ class LibDartOpenMVG {
ffi.Pointer<Frame> Function(
ffi.Pointer<ffi.Uint8>, int, int, int, int)>();
ffi.Pointer<ImageResult> image_result_new(
ffi.Pointer<u_char> arg0,
int data_len,
) {
return _image_result_new(
arg0,
data_len,
);
}
late final _image_result_newPtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<ImageResult> Function(
ffi.Pointer<u_char>, ffi.Size)>>('image_result_new');
late final _image_result_new = _image_result_newPtr.asFunction<
ffi.Pointer<ImageResult> Function(ffi.Pointer<u_char>, int)>();
ffi.Pointer<ImageResult> image_result_new_error(
int arg0,
) {
return _image_result_new_error(
arg0,
);
}
late final _image_result_new_errorPtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ImageResult> Function(ffi.Int)>>(
'image_result_new_error');
late final _image_result_new_error = _image_result_new_errorPtr
.asFunction<ffi.Pointer<ImageResult> Function(int)>();
int image_result_free(
ffi.Pointer<ImageResult> arg0,
) {
return _image_result_free(
arg0,
);
}
late final _image_result_freePtr =
_lookup<ffi.NativeFunction<ffi.Int Function(ffi.Pointer<ImageResult>)>>(
'image_result_free');
late final _image_result_free = _image_result_freePtr
.asFunction<int Function(ffi.Pointer<ImageResult>)>();
ffi.Pointer<ImageResult> archimedes_get_image_data(
ffi.Pointer<Frame> arg0,
) {
@ -244,6 +261,8 @@ final class _IO_codecvt extends ffi.Opaque {}
final class _IO_wide_data extends ffi.Opaque {}
typedef Frame = _Frame;
final class _ImageResult extends ffi.Struct {
external ffi.Pointer<u_char> data;
@ -257,4 +276,3 @@ final class _ImageResult extends ffi.Struct {
typedef u_char = __u_char;
typedef __u_char = ffi.UnsignedChar;
typedef ImageResult = _ImageResult;
typedef Frame = _Frame;

View File

@ -93,7 +93,6 @@ set_target_properties(${LIBDART_OPENMVG}
OUTPUT_NAME ${LIBDART_OPENMVG}
)
target_link_options(${LIBDART_OPENMVG} PRIVATE "-Wl,-Bstatic")
target_link_options(${LIBDART_OPENMVG} PRIVATE "-Wl,-Bdynamic")
add_executable(

View File

@ -1,14 +1,5 @@
#include "frame.h"
const Frame *new_frame_from_handle(FILE *stream, int w, int h, int depth)
{
Frame *f = (Frame *)malloc(sizeof(Frame));
f->stream = stream;
f->w = w;
f->h = h;
f->depth = depth;
return f;
}
FILE *make_buffer(const uint8_t *data, const size_t data_len)
{
@ -29,10 +20,20 @@ FILE *make_buffer(const uint8_t *data, const size_t data_len)
return file;
}
_FFI_PLUGIN
const Frame *
new_frame_from_data(const uint8_t *data, const size_t data_len, int w, int h, int depth)
const Frame *new_frame_from_data(const uint8_t *data, const size_t data_len, int w, int h, int depth)
{
FILE *buf = make_buffer(data, data_len);
return new_frame_from_handle(buf, w, h, depth);
}
const Frame *new_frame_from_handle(FILE *stream, int w, int h, int depth)
{
Frame *f = (Frame *)malloc(sizeof(Frame));
f->stream = stream;
f->w = w;
f->h = h;
f->depth = depth;
return f;
}

View File

@ -15,6 +15,6 @@ FILE *make_buffer(const uint8_t *, const size_t);
_FFI_PLUGIN
const Frame *new_frame_from_handle(FILE *, int, int, int);
_FFI_PLUGIN
const Frame *
new_frame_from_data(const uint8_t *, const size_t, int, int, int);
const Frame *new_frame_from_data(const uint8_t *, const size_t, int, int, int);

View File

@ -34,6 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <error.h>
#include <png.h>
#if defined(__cplusplus)
@ -42,8 +43,11 @@ extern "C" {
auto png_sig_cm = png_sig_cmp;
}
#endif // __cplusplus
#define error_t int
#ifdef __cplusplus
class StreamedView : openMVG::sfm::View {