mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-10 22:19:46 +08:00
Semi runs
This commit is contained in:
parent
e831bc75c6
commit
f25abb0b26
49
v2/internal/ffenestri/README.md
Normal file
49
v2/internal/ffenestri/README.md
Normal file
File diff suppressed because one or more lines are too long
@ -51,6 +51,7 @@ BOOL yes(id self, SEL cmd)
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Debug works like sprintf but mutes if the global debug flag is true
|
// Debug works like sprintf but mutes if the global debug flag is true
|
||||||
// Credit: https://stackoverflow.com/a/20639708
|
// Credit: https://stackoverflow.com/a/20639708
|
||||||
void Debug(char *message, ... ) {
|
void Debug(char *message, ... ) {
|
||||||
@ -66,6 +67,12 @@ void Debug(char *message, ... ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void messageHandler(id self, SEL cmd, id contentController, id msg) {
|
||||||
|
// TODO: Pass message to callback in application object
|
||||||
|
Debug("TODO: Process message");
|
||||||
|
}
|
||||||
|
|
||||||
extern void messageFromWindowCallback(const char *);
|
extern void messageFromWindowCallback(const char *);
|
||||||
typedef void (*ffenestriCallback)(const char *);
|
typedef void (*ffenestriCallback)(const char *);
|
||||||
|
|
||||||
@ -684,12 +691,7 @@ void Run(void *applicationPointer, int argc, char **argv) {
|
|||||||
class_addProtocol(delegateClass, objc_getProtocol("NSTouchBarProvider"));
|
class_addProtocol(delegateClass, objc_getProtocol("NSTouchBarProvider"));
|
||||||
class_addMethod(delegateClass, s("applicationShouldTerminateAfterLastWindowClosed:"), (IMP) yes, "c@:@");
|
class_addMethod(delegateClass, s("applicationShouldTerminateAfterLastWindowClosed:"), (IMP) yes, "c@:@");
|
||||||
// TODO: add userContentController:didReceiveScriptMessage
|
// TODO: add userContentController:didReceiveScriptMessage
|
||||||
class_addMethod(delegateClass, s("userContentController:didReceiveScriptMessage:"),
|
class_addMethod(delegateClass, s("userContentController:didReceiveScriptMessage:"), (IMP) messageHandler,
|
||||||
(IMP)(^(id self, SEL cmd, id contentController, id msg) {
|
|
||||||
// const char *m = (const char *)msg(msg(message, s("body")), s("UTF8String"));
|
|
||||||
// Debug("*** didReceiveScriptMessage: %p", message);
|
|
||||||
Debug("Hi!");
|
|
||||||
}),
|
|
||||||
"v@:@@");
|
"v@:@@");
|
||||||
objc_registerClassPair(delegateClass);
|
objc_registerClassPair(delegateClass);
|
||||||
|
|
||||||
@ -736,38 +738,49 @@ void Run(void *applicationPointer, int argc, char **argv) {
|
|||||||
// We want to evaluate the internal code plus runtime before the assets
|
// We want to evaluate the internal code plus runtime before the assets
|
||||||
const char *temp = concat(invoke, app->bindings);
|
const char *temp = concat(invoke, app->bindings);
|
||||||
const char *internalCode = concat(temp, (const char*)&runtime);
|
const char *internalCode = concat(temp, (const char*)&runtime);
|
||||||
Debug("Internal code: %s", internalCode);
|
// Debug("Internal code: %s", internalCode);
|
||||||
free((void*)temp);
|
free((void*)temp);
|
||||||
|
|
||||||
// Evaluate internal code
|
// Loop over assets
|
||||||
msg(wkwebview, s("evaluateJavaScript:completionHandler:"),
|
int index = 1;
|
||||||
msg(c("NSString"), s("stringWithUTF8String:"), (char*)internalCode), ^(id result, void *error) {
|
while(1) {
|
||||||
|
// Get next asset pointer
|
||||||
|
const unsigned char *asset = assets[index];
|
||||||
|
|
||||||
Debug("Result: %p", result);
|
// If we have no more assets, break
|
||||||
Debug("Error: %p", error);
|
if (asset == 0x00) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
temp = concat(internalCode, asset);
|
||||||
|
free((void*)internalCode);
|
||||||
|
internalCode = temp;
|
||||||
|
index++;
|
||||||
|
};
|
||||||
|
|
||||||
|
Debug("MOAE: %s", internalCode);
|
||||||
|
|
||||||
|
// Evaluate internal code
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
// TODO: WORK OUT WHY EXECUTING THE INTERNAL CODE BLOWS THE APP UP
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
msg(wkwebview,
|
||||||
|
s("evaluateJavaScript:completionHandler:"),
|
||||||
|
msg(c("NSString"), s("stringWithUTF8String:"), (char*)internalCode),
|
||||||
|
^() {
|
||||||
|
|
||||||
|
// Debug("Result: %p", result);
|
||||||
|
// Debug("Error: %p", error);
|
||||||
// Free internalCode memory
|
// Free internalCode memory
|
||||||
free((void*)internalCode);
|
// free((void*)internalCode);
|
||||||
/*
|
/*
|
||||||
if( error != NULL) {
|
if( error != NULL) {
|
||||||
Debug("Error message: %s", error);
|
Debug("Error message: %s", error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// Loop over assets
|
Debug("DO I CARE?");
|
||||||
int index = 0;
|
|
||||||
while(1) {
|
|
||||||
// Get next asset pointer
|
|
||||||
const unsigned char *asset = assets[index];
|
|
||||||
|
|
||||||
// If we have no more assets, break
|
|
||||||
if (asset == 0x00) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sync eval the asset
|
|
||||||
ExecJS(app, (char*)asset);
|
|
||||||
index++;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user