mirror of
https://github.com/Adamcake/Bolt.git
synced 2026-04-25 11:26:53 -04:00
repo: Cef->Browser naming
This commit is contained in:
@@ -3,7 +3,7 @@ libcef = custom_target('libcef', output: 'libcef.so', command: ['./cef/install.s
|
||||
meson.add_install_script('cef/install.sh')
|
||||
executable(
|
||||
'bolt',
|
||||
'src/main.cxx', 'src/cef/app.cxx',
|
||||
'src/main.cxx', 'src/browser/app.cxx',
|
||||
dependencies: [dependency('fmt'), dependency('tesseract'), dependency('x11')],
|
||||
include_directories: 'cef/dist',
|
||||
install: true,
|
||||
|
||||
72
src/browser/app.cxx
Normal file
72
src/browser/app.cxx
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "app.hxx"
|
||||
|
||||
Browser::App* resolve_app(cef_app_t* app) {
|
||||
return reinterpret_cast<Browser::App*>(reinterpret_cast<size_t>(app) - offsetof(Browser::App, cef_app));
|
||||
}
|
||||
|
||||
Browser::App* resolve_base(cef_base_ref_counted_t* base) {
|
||||
return reinterpret_cast<Browser::App*>(reinterpret_cast<size_t>(base) - (offsetof(Browser::App, cef_app) + offsetof(cef_app_t, base)));
|
||||
}
|
||||
|
||||
Browser::App::App() {
|
||||
this->cef_app.base.size = sizeof(cef_base_ref_counted_t);
|
||||
this->cef_app.base.add_ref = Browser::AddRef;
|
||||
this->cef_app.base.release = Browser::Release;
|
||||
this->cef_app.base.has_one_ref = Browser::HasOneRef;
|
||||
this->cef_app.base.has_at_least_one_ref = Browser::HasAnyRefs;
|
||||
this->cef_app.on_before_command_line_processing = Browser::OnBeforeCommandLineProcessing;
|
||||
this->cef_app.on_register_custom_schemes = Browser::OnRegisterCustomSchemes;
|
||||
this->cef_app.get_resource_bundle_handler = Browser::ResourceBundleHandler;
|
||||
this->cef_app.get_browser_process_handler = Browser::BrowserProcessHandler;
|
||||
this->cef_app.get_render_process_handler = Browser::RenderProcessHandler;
|
||||
this->refcount = 0;
|
||||
}
|
||||
|
||||
void Browser::App::Destroy() {
|
||||
// Any self-cleanup should be done here
|
||||
}
|
||||
|
||||
cef_app_t* Browser::App::app() {
|
||||
this->refcount += 1;
|
||||
return &this->cef_app;
|
||||
}
|
||||
|
||||
void Browser::AddRef(cef_base_ref_counted_t* app) {
|
||||
resolve_base(app)->refcount += 1;
|
||||
}
|
||||
|
||||
int Browser::Release(cef_base_ref_counted_t* app) {
|
||||
Browser::App* _app = resolve_base(app);
|
||||
_app->refcount -= 1;
|
||||
|
||||
if (_app->refcount == 0) {
|
||||
_app->Destroy();
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Browser::HasOneRef(cef_base_ref_counted_t* app) {
|
||||
return (resolve_base(app)->refcount == 1) ? 1 : 0;
|
||||
}
|
||||
|
||||
int Browser::HasAnyRefs(cef_base_ref_counted_t* app) {
|
||||
return (resolve_base(app)->refcount >= 1) ? 1 : 0;
|
||||
}
|
||||
|
||||
void Browser::OnBeforeCommandLineProcessing(cef_app_t*, const cef_string_t*, cef_command_line_t*) { }
|
||||
|
||||
void Browser::OnRegisterCustomSchemes(cef_app_t*, cef_scheme_registrar_t*) { }
|
||||
|
||||
cef_resource_bundle_handler_t* Browser::ResourceBundleHandler(cef_app_t*) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cef_browser_process_handler_t* Browser::BrowserProcessHandler(cef_app_t*) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cef_render_process_handler_t* Browser::RenderProcessHandler(cef_app_t*) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "include/capi/cef_app_capi.h"
|
||||
|
||||
namespace Cef {
|
||||
namespace Browser {
|
||||
struct App {
|
||||
cef_app_t cef_app;
|
||||
unsigned int refcount;
|
||||
@@ -1,72 +0,0 @@
|
||||
#include "app.hxx"
|
||||
|
||||
Cef::App* resolve_app(cef_app_t* app) {
|
||||
return reinterpret_cast<Cef::App*>(reinterpret_cast<size_t>(app) - offsetof(Cef::App, cef_app));
|
||||
}
|
||||
|
||||
Cef::App* resolve_base(cef_base_ref_counted_t* base) {
|
||||
return reinterpret_cast<Cef::App*>(reinterpret_cast<size_t>(base) - (offsetof(Cef::App, cef_app) + offsetof(cef_app_t, base)));
|
||||
}
|
||||
|
||||
Cef::App::App() {
|
||||
this->cef_app.base.size = sizeof(cef_base_ref_counted_t);
|
||||
this->cef_app.base.add_ref = Cef::AddRef;
|
||||
this->cef_app.base.release = Cef::Release;
|
||||
this->cef_app.base.has_one_ref = Cef::HasOneRef;
|
||||
this->cef_app.base.has_at_least_one_ref = Cef::HasAnyRefs;
|
||||
this->cef_app.on_before_command_line_processing = Cef::OnBeforeCommandLineProcessing;
|
||||
this->cef_app.on_register_custom_schemes = Cef::OnRegisterCustomSchemes;
|
||||
this->cef_app.get_resource_bundle_handler = Cef::ResourceBundleHandler;
|
||||
this->cef_app.get_browser_process_handler = Cef::BrowserProcessHandler;
|
||||
this->cef_app.get_render_process_handler = Cef::RenderProcessHandler;
|
||||
this->refcount = 0;
|
||||
}
|
||||
|
||||
void Cef::App::Destroy() {
|
||||
// Any self-cleanup should be done here
|
||||
}
|
||||
|
||||
cef_app_t* Cef::App::app() {
|
||||
this->refcount += 1;
|
||||
return &this->cef_app;
|
||||
}
|
||||
|
||||
void Cef::AddRef(cef_base_ref_counted_t* app) {
|
||||
resolve_base(app)->refcount += 1;
|
||||
}
|
||||
|
||||
int Cef::Release(cef_base_ref_counted_t* app) {
|
||||
Cef::App* _app = resolve_base(app);
|
||||
_app->refcount -= 1;
|
||||
|
||||
if (_app->refcount == 0) {
|
||||
_app->Destroy();
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Cef::HasOneRef(cef_base_ref_counted_t* app) {
|
||||
return (resolve_base(app)->refcount == 1) ? 1 : 0;
|
||||
}
|
||||
|
||||
int Cef::HasAnyRefs(cef_base_ref_counted_t* app) {
|
||||
return (resolve_base(app)->refcount >= 1) ? 1 : 0;
|
||||
}
|
||||
|
||||
void Cef::OnBeforeCommandLineProcessing(cef_app_t*, const cef_string_t*, cef_command_line_t*) { }
|
||||
|
||||
void Cef::OnRegisterCustomSchemes(cef_app_t*, cef_scheme_registrar_t*) { }
|
||||
|
||||
cef_resource_bundle_handler_t* Cef::ResourceBundleHandler(cef_app_t*) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cef_browser_process_handler_t* Cef::BrowserProcessHandler(cef_app_t*) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cef_render_process_handler_t* Cef::RenderProcessHandler(cef_app_t*) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include "cef/app.hxx"
|
||||
#include "browser/app.hxx"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
@@ -59,7 +59,7 @@ int main(int argc, char* argv[]) {
|
||||
settings.command_line_args_disabled = true;
|
||||
settings.uncaught_exception_stack_size = 16;
|
||||
|
||||
Cef::App cef_app;
|
||||
Browser::App cef_app;
|
||||
|
||||
// Initialize CEF
|
||||
exit_code = cef_initialize(&main_args, &settings, cef_app.app(), nullptr);
|
||||
|
||||
Reference in New Issue
Block a user