Skip to content

Commit

Permalink
feat: compile and running on macos works.
Browse files Browse the repository at this point in the history
  • Loading branch information
andycall committed Feb 16, 2024
1 parent 3cb9923 commit e385f7c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 16 deletions.
19 changes: 5 additions & 14 deletions bridge/core_rs/src/dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,21 @@ use std::ffi::{CString};
use webf_sys::executing_context::ExecutingContext;
use webf_sys::node::NodeMethods;

pub fn init_webf_dom(context: &ExecutingContext) {
pub fn init_webf_dom(context: &ExecutingContext){
let document = context.document();
let exception_state = context.create_exception_state();

let html_tag_name = CString::new("html");
let html_element = document.create_element(&html_tag_name.unwrap(), &exception_state).unwrap();
let html_element = document.create_element(&html_tag_name.unwrap(), &exception_state)?;

let _ = document.append_child(&html_element, &exception_state);
document.append_child(&html_element, &exception_state).unwrap();

let head_tag_name = CString::new("head");
let head_element = document.create_element(&head_tag_name.unwrap(), &exception_state).unwrap();
let _ = document.document_element().append_child(&head_element, &exception_state);
document.document_element().append_child(&head_element, &exception_state).unwrap();

let body_tag_name = CString::new("body");
let body_element = document.create_element(&body_tag_name.unwrap(), &exception_state).unwrap();
let _ = document.document_element().append_child(&body_element, &exception_state);

// let exception_state = unsafe {
// ExceptionState {
// ptr: webf__create_exception_state()
// }
// };
// document.createElement("1234", &exception_state);

// return document;
document.document_element().append_child(&body_element, &exception_state).unwrap();
}

22 changes: 20 additions & 2 deletions bridge/rusty_webf_sys/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,31 @@ pub struct ElementRustMethods {

impl RustMethods for ElementRustMethods {}

enum ElementType {
kHTMLDIVElement,
kHTMLAnchorElement,
kHTMLHeadElement,
kHTMLBodyElement,
kHTMLHTMLElement,
kHTMLImageElement,
kHTMLLinkElement,
kHTMLScriptElement,
kHTMLTemplateElement,
kHTMLUnknownElement,
kHTMLCanvasElement,
kHTMLWidgetElement,
kHTMLButtonElement,
kHTMLFormElement,
kHTMLInputElement,
kHTMLTextAreaElement
}

pub struct Element {
container_node: ContainerNode,
method_pointer: *const ElementRustMethods,
}

impl Element {
}
impl Element {}

pub trait ElementMethods: ContainerNodeMethods {}

Expand Down
1 change: 1 addition & 0 deletions scripts/build_darwin_dylib.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require('./tasks');
// Run tasks
series(
'compile-polyfill',
'compile-webf-core',
'generate-bindings-code',
'build-darwin-webf-lib',
)((err) => {
Expand Down
16 changes: 16 additions & 0 deletions scripts/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const paths = {
webf: resolveWebF('webf'),
bridge: resolveWebF('bridge'),
polyfill: resolveWebF('bridge/polyfill'),
rs_core: resolveWebF('bridge/core_rs'),
codeGen: resolveWebF('bridge/scripts/code_generator'),
thirdParty: resolveWebF('third_party'),
tests: resolveWebF('integration_tests'),
Expand Down Expand Up @@ -83,6 +84,21 @@ task('clean', () => {

const libOutputPath = join(TARGET_PATH, platform, 'lib');

task('compile-webf-core', done => {
let buildType = 'Debug';
if (process.env.WEBF_BUILD === 'Release') {
buildType = 'RelWithDebInfo';
}

execSync(`cargo build ${buildType == 'RelWithDebInfo' ? '--release' : ''}`, {
cwd: paths.rs_core,
env: process.env,
stdio: 'inherit'
});

done();
});

task('build-darwin-webf-lib', done => {
let externCmakeArgs = [];
let buildType = 'Debug';
Expand Down

0 comments on commit e385f7c

Please sign in to comment.