This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/bindings.rs | |
#[link(name = "gui", kind = "static")] | |
extern "C" { | |
pub fn register_button(engine: *mut c_void, button: *mut c_void); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/engine.rs | |
use std::ffi::c_void; | |
use std::os::raw::c_char; | |
use crate::bindings::{engine_factory, register_button, AbstractButtonBinding}; | |
use crate::Button; | |
pub struct Engine { | |
ptr: *mut c_void | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/main.rs | |
mod button; | |
mod engine; | |
mod bindings; | |
use button::Button; | |
pub struct CounterButton { | |
count: i32 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main.cpp | |
#include <GUI/engine.hpp> | |
#include "CounterButton.hpp" | |
int main() { | |
// Instantiate the hypothetical engine | |
Engine engine(); | |
// Instantiate the button | |
auto * counter = new CounterButton(); | |
// Adds button to the view | |
engine.addButton(counter); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Point { | |
x: f64, | |
y: f64, | |
z: f64, | |
} | |
impl Point { | |
pub fn mid_point(&self, other: &Point) -> Point { | |
Point { | |
x: (self.x + other.x) / 2.0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from numpy.random import uniform, randint | |
from typing import Tuple, List, Set | |
class Agent: | |
def __init__(self, x: float, y: float, contamined: bool): | |
self.__x: float = x | |
self.__y: float = y | |
self.__contamined: bool = False | |
self.__days_contamined: int = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function forEach(arr, func) { | |
const len = arr.length; | |
for(let i = 0; i < len; ++i) func(arr[i]) | |
} | |
const l = [1,2,3,4,5]; | |
function logTimes2(x) { | |
console.log(x*2); | |
} |