Skip to content

Commit

Permalink
chore: working ios
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Oct 16, 2023
1 parent 11fb296 commit 51dc075
Show file tree
Hide file tree
Showing 38 changed files with 1,793 additions and 938 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@
//
// Created by Osei Fortune on 30/09/2020.
//
#import "canvas_native.h"
#import "canvas_ios.h"

#ifdef __OBJC__
#ifdef __cplusplus
extern "C" {
#endif

#import <Foundation/Foundation.h>

#import "canvas_native.h"
#import "canvas_ios.h"

//! Project version number for CanvasNative.

FOUNDATION_EXPORT double CanvasNativeVersionNumber;

//! Project version string for CanvasNative.
FOUNDATION_EXPORT const unsigned char CanvasNativeVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <CanvasNative/PublicHeader.h>

#ifdef __cplusplus
}
#endif

Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ struct ImageData *canvas_native_image_data_get_shared_instance(struct ImageData

struct ImageAsset *canvas_native_image_asset_create(void);

struct ImageAsset *canvas_native_image_asset_shared_clone(const struct ImageAsset *asset);
struct ImageAsset *canvas_native_image_asset_shared_clone(struct ImageAsset *asset);

bool canvas_native_image_asset_load_from_fd(struct ImageAsset *asset, int fd);

Expand Down Expand Up @@ -1633,8 +1633,8 @@ struct ContextAttributes *canvas_native_webgl_get_context_attributes(struct WebG

uint32_t canvas_native_webgl_get_error(struct WebGLState *state);

const struct WebGLExtension *canvas_native_webgl_get_extension(const char *name,
struct WebGLState *state);
struct WebGLExtension *canvas_native_webgl_get_extension(const char *name,
struct WebGLState *state);

struct WebGLFramebufferAttachmentParameter *canvas_native_webgl_get_framebuffer_attachment_parameter(uint32_t target,
uint32_t attachment,
Expand Down Expand Up @@ -1804,6 +1804,22 @@ void canvas_native_webgl_tex_image2d_image_none(int32_t target,
int32_t image_type,
struct WebGLState *state);

void canvas_native_webgl_tex_image2d_canvas2d(int32_t target,
int32_t level,
int32_t internalformat,
int32_t format,
int32_t image_type,
struct CanvasRenderingContext2D *canvas,
struct WebGLState *state);

void canvas_native_webgl_tex_image2d_webgl(int32_t target,
int32_t level,
int32_t _internalformat,
int32_t _format,
int32_t _image_type,
struct WebGLState *webgl,
struct WebGLState *state);

void canvas_native_webgl_tex_image2d(int32_t target,
int32_t level,
int32_t internalformat,
Expand All @@ -1826,6 +1842,14 @@ void canvas_native_webgl_tex_image2d_none(int32_t target,
int32_t image_type,
struct WebGLState *state);

void canvas_native_webgl_tex_image2d_image_asset(int32_t target,
int32_t level,
int32_t internalformat,
int32_t format,
int32_t image_type,
struct ImageAsset *image_asset,
struct WebGLState *state);

void canvas_native_webgl_tex_parameterf(uint32_t target,
uint32_t pname,
float param,
Expand Down Expand Up @@ -2667,4 +2691,10 @@ uintptr_t canvas_native_f32_buffer_mut_get_length(const struct F32Buffer *buffer

uintptr_t canvas_native_f32_buffer_get_length(const struct F32Buffer *buffer);

uintptr_t canvas_native_string_buffer_get_length(const struct StringBuffer *buffer);

char *canvas_native_string_buffer_get_value_at(const struct StringBuffer *buffer, uintptr_t index);

void canvas_native_string_buffer_destroy(struct StringBuffer *buffer);

#endif /* CANVAS_C_H */
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@
//
// Created by Osei Fortune on 30/09/2020.
//
#import "canvas_native.h"
#import "canvas_ios.h"

#ifdef __OBJC__
#ifdef __cplusplus
extern "C" {
#endif

#import <Foundation/Foundation.h>

#import "canvas_native.h"
#import "canvas_ios.h"

//! Project version number for CanvasNative.

FOUNDATION_EXPORT double CanvasNativeVersionNumber;

//! Project version string for CanvasNative.
FOUNDATION_EXPORT const unsigned char CanvasNativeVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <CanvasNative/PublicHeader.h>

#ifdef __cplusplus
}
#endif

Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ struct ImageData *canvas_native_image_data_get_shared_instance(struct ImageData

struct ImageAsset *canvas_native_image_asset_create(void);

struct ImageAsset *canvas_native_image_asset_shared_clone(const struct ImageAsset *asset);
struct ImageAsset *canvas_native_image_asset_shared_clone(struct ImageAsset *asset);

bool canvas_native_image_asset_load_from_fd(struct ImageAsset *asset, int fd);

Expand Down Expand Up @@ -1633,8 +1633,8 @@ struct ContextAttributes *canvas_native_webgl_get_context_attributes(struct WebG

uint32_t canvas_native_webgl_get_error(struct WebGLState *state);

const struct WebGLExtension *canvas_native_webgl_get_extension(const char *name,
struct WebGLState *state);
struct WebGLExtension *canvas_native_webgl_get_extension(const char *name,
struct WebGLState *state);

struct WebGLFramebufferAttachmentParameter *canvas_native_webgl_get_framebuffer_attachment_parameter(uint32_t target,
uint32_t attachment,
Expand Down Expand Up @@ -1804,6 +1804,22 @@ void canvas_native_webgl_tex_image2d_image_none(int32_t target,
int32_t image_type,
struct WebGLState *state);

void canvas_native_webgl_tex_image2d_canvas2d(int32_t target,
int32_t level,
int32_t internalformat,
int32_t format,
int32_t image_type,
struct CanvasRenderingContext2D *canvas,
struct WebGLState *state);

void canvas_native_webgl_tex_image2d_webgl(int32_t target,
int32_t level,
int32_t _internalformat,
int32_t _format,
int32_t _image_type,
struct WebGLState *webgl,
struct WebGLState *state);

void canvas_native_webgl_tex_image2d(int32_t target,
int32_t level,
int32_t internalformat,
Expand All @@ -1826,6 +1842,14 @@ void canvas_native_webgl_tex_image2d_none(int32_t target,
int32_t image_type,
struct WebGLState *state);

void canvas_native_webgl_tex_image2d_image_asset(int32_t target,
int32_t level,
int32_t internalformat,
int32_t format,
int32_t image_type,
struct ImageAsset *image_asset,
struct WebGLState *state);

void canvas_native_webgl_tex_parameterf(uint32_t target,
uint32_t pname,
float param,
Expand Down Expand Up @@ -2667,4 +2691,10 @@ uintptr_t canvas_native_f32_buffer_mut_get_length(const struct F32Buffer *buffer

uintptr_t canvas_native_f32_buffer_get_length(const struct F32Buffer *buffer);

uintptr_t canvas_native_string_buffer_get_length(const struct StringBuffer *buffer);

char *canvas_native_string_buffer_get_value_at(const struct StringBuffer *buffer, uintptr_t index);

void canvas_native_string_buffer_destroy(struct StringBuffer *buffer);

#endif /* CANVAS_C_H */
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
</data>
<key>Headers/CanvasNative.h</key>
<data>
Fpy7Hlc8UqNId8jgtgKz5mOFBCU=
/f1joB+88Yli7N3M7UJmfZD+wrM=
</data>
<key>Headers/canvas_ios.h</key>
<data>
KTxEWGEXbMkpqkl1jFw9IrlUXNk=
</data>
<key>Headers/canvas_native.h</key>
<data>
KjmIpBZrkmZPbZiPxYeDVFudctM=
kZAeynopf9HWpp2VwLjaus5M/hc=
</data>
<key>Info.plist</key>
<data>
Expand Down Expand Up @@ -94,7 +94,7 @@
<dict>
<key>hash2</key>
<data>
U94BOYW6ZUckumKy0f6esxE3QgCyRx/QAGTXLd+jBpU=
etIfFZplh+fbBvYN1m/bsCHh1B91DXsoX2FOvSfQ5Vw=
</data>
</dict>
<key>Headers/canvas_ios.h</key>
Expand All @@ -108,7 +108,7 @@
<dict>
<key>hash2</key>
<data>
W14HFr1pFaToaWIQbCgrX4F1bw4RkCQFUOi0DiyMlww=
odQ0lZFQBS/l6gW2trmXrYsj7pbov7rXinUgSLQNp0Q=
</data>
</dict>
<key>Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo</key>
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/canvas/platforms/ios/build.xcconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OTHER_LDFLAGS[sdk=*] = $(inherited) -framework CanvasNative -framework OpenGLES -framework GLKit
OTHER_LDFLAGS[sdk=*] = $(inherited) -framework Foundation -framework CanvasNative -framework OpenGLES -framework GLKit

HEADER_SEARCH_PATHS = $(inherited) "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/NativeScript.framework/Headers" "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/NativeScript.framework/Headers/include"

Expand Down
8 changes: 3 additions & 5 deletions packages/canvas/platforms/ios/src/NSOperationQueueWrapper.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#import <Foundation/Foundation.h>


#include <functional>
class NSOperationQueueWrapper {
public:
NSOperationQueueWrapper(bool currentQueue);
~NSOperationQueueWrapper();

void addOperation(void (*task)());
void addOperation(std::function<void()> task);

private:
NSOperationQueue *operationQueue;
void *operationQueue;
};
33 changes: 19 additions & 14 deletions packages/canvas/platforms/ios/src/NSOperationQueueWrapper.mm
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#import "NSOperationQueueWrapper.h"


#import <Foundation/Foundation.h>
#import "NSOperationQueueWrapper.h"
#include <Foundation/Foundation.h>

@interface NSOperationQueueWrapperObjC : NSObject
- (void)addOperation:(void (^)())task;
Expand All @@ -28,13 +25,10 @@ -(instancetype)initWithCurrentQueue {
return self;
}

- (void)dealloc {
// In ARC, there's no need to manually release
}
- (void)dealloc {}

- (void)addOperation:(void (^)())task {
NSBlockOperation* operation = [NSBlockOperation blockOperationWithBlock:^{
// Call the C++ task
task();
}];

Expand All @@ -51,18 +45,29 @@ - (NSOperationQueue*)getOperationQueue {
NSOperationQueueWrapper::NSOperationQueueWrapper(bool currentQueue) {
if (currentQueue) {
NSOperationQueueWrapperObjC* objcWrapper = [[NSOperationQueueWrapperObjC alloc] initWithCurrentQueue];
operationQueue = [objcWrapper getOperationQueue];

CFTypeRef ptr = (__bridge_retained CFTypeRef)objcWrapper;

operationQueue = (void*)ptr;
}else {
NSOperationQueueWrapperObjC* objcWrapper = [NSOperationQueueWrapperObjC init];
operationQueue = [objcWrapper getOperationQueue];
NSOperationQueueWrapperObjC* objcWrapper = [[NSOperationQueueWrapperObjC alloc] init];
CFTypeRef ptr = (__bridge_retained CFTypeRef)objcWrapper;
operationQueue = (void*)ptr;
}

}

NSOperationQueueWrapper::~NSOperationQueueWrapper() {}
NSOperationQueueWrapper::~NSOperationQueueWrapper() {
if(operationQueue != nullptr){
CFBridgingRelease(operationQueue);
operationQueue = nullptr;
}
}

void NSOperationQueueWrapper::addOperation(void (*task)()) {
NSOperationQueueWrapperObjC* queue = static_cast<NSOperationQueueWrapperObjC*>(operationQueue);
void NSOperationQueueWrapper::addOperation(std::function<void()> task) {

auto queue = (__bridge NSOperationQueueWrapperObjC*)(operationQueue);

[queue addOperation:^{
task();
}];
Expand Down
Loading

0 comments on commit 51dc075

Please sign in to comment.