Skip to content

Instantly share code, notes, and snippets.

View zbraniecki's full-sized avatar

Zibi Braniecki zbraniecki

View GitHub Profile
@zbraniecki
zbraniecki / README.md
Last active April 7, 2024 04:42
Rust <--> C/C++ FFI for newbies

As Gecko is moving toward more Rust code, the cases where Rust and C code interoperate will become more common.

This document is an attempt to ease the learning curve for engineers facing it for the first time. It assumes no prior experience with cross-language C interfaces (called FFI).

It also assumes that Rust code is already built into Gecko. If you need help with that, read Introducing Rust code in Firefox.

What can you transfer across the fence

@zbraniecki
zbraniecki / PlatformIntlApple.cpp
Last active February 7, 2024 01:26
Hermes ICU4X
// https://github.com/facebook/hermes/blob/main/lib/Platform/Intl/PlatformIntlApple.mm#L319-L353
vm::CallResult<std::vector<std::u16string>> canonicalizeLocaleList(
vm::Runtime &runtime,
const std::vector<std::u16string> &locales) {
// 1. If locales is undefined, then
// a. Return a new empty List
// Not needed, this validation occurs closer to VM in 'normalizeLocales'.
// 2. Let seen be a new empty List.
std::vector<std::u16string> seen;
@zbraniecki
zbraniecki / sizes.txt
Last active April 17, 2023 21:21
ICU4X 1.2 Segmentation (utf16) sizes
╭────┬────────────────────────┬──────┬─────────┬────────────────╮
│ # │ name │ type │ size │ modified │
├────┼────────────────────────┼──────┼─────────┼────────────────┤
│ 0 │ ar-icu4c-line.txt │ file │ 22.7 KB │ 3 hours ago │
│ 1 │ ar-icu4c-word.txt │ file │ 48.6 KB │ 3 hours ago │
│ 2 │ ar-icu4x-line-utf8.txt │ file │ 23.8 KB │ 3 hours ago │
│ 3 │ ar-icu4x-line.txt │ file │ 22.9 KB │ 3 hours ago │
│ 4 │ ar-icu4x-word-utf8.txt │ file │ 50.5 KB │ 3 hours ago │
│ 5 │ ar-icu4x-word.txt │ file │ 48.6 KB │ 3 hours ago │
│ 6 │ ar.txt │ file │ 35.1 KB │ 3 hours ago │
@zbraniecki
zbraniecki / background.js
Created August 27, 2017 07:05
selectTab extension
browser.commands.onCommand.addListener(async (command) => {
let num = parseInt(command.substr(9, 10)) - 1;
let tabs = await browser.tabs.query({currentWindow: true});
if (tabs.length < num) {
return;
}
browser.tabs.update(tabs[num].id, {active: true});
});
@zbraniecki
zbraniecki / test.js
Last active November 8, 2022 03:57
Localizable Manifest Options Size Comparison
const fs = require('fs');
const display = false;
const pretty = false;
let input = {
"title": {
"display": "Lorem Ipsum",
},
@zbraniecki
zbraniecki / results.txt
Created November 2, 2022 05:51
ICU4X Result<(), _> cases
/Users/zibi/projects/icu4x〉rg 'Result<\(\)' -g "!{ffi/**}" -g "!{coverage/**}" ./ 11/02/2022 08:50:06 AM
./components/collections/src/codepointinvlist/cpinvlist.rs
864: fn test_serde_with_postcard_roundtrip() -> Result<(), postcard::Error> {
./components/collections/src/codepointtrie/cptrie.rs
996: fn test_serde_with_postcard_roundtrip() -> Result<(), postcard::Error> {
./components/list/src/provider.rs
274: ) -> Result<(), DataError> {
@zbraniecki
zbraniecki / init.vim
Created November 17, 2021 15:42
nvim 0.6 config 2021-11-17
call plug#begin('~/.vim/plugged')
" Collection of common configurations for the Nvim LSP client
Plug 'neovim/nvim-lspconfig'
" Completion framework
Plug 'hrsh7th/nvim-cmp', { 'branch': 'main' }
" LSP completion source for nvim-cmp
Plug 'hrsh7th/cmp-nvim-lsp', { 'branch': 'main' }
@zbraniecki
zbraniecki / structure.txt
Last active December 15, 2021 05:42
ICU4X Licenses (Dec 2021)
## Current Library Structure in the repo
//
├─ components/
│ ├─ component1/
│ │ ├─ src/
│ ├─ component2/
│ │ ├─ src/
│ │ ├─ data/
│ │ │ ├─ from_unicode/
@zbraniecki
zbraniecki / zibi.ts
Created February 1, 2021 16:41
MF2.0 Data Model
// Changed NumberLiteral to be a float+precision
// Added Variant::default
// Separated Arguments and Options on a FunctionReference
// Added KeyValuePair used in FunctionReference and maybe in MessageReference
// Added optional MessageReference if we decide to go for it
export type Message = MessageValue;
export type MessageValue = Single | Multi;
@zbraniecki
zbraniecki / datetime.cpp
Created January 25, 2021 01:07
FFI for ICU4X example
class DateTimeFormat {
public:
Result<DateTimeFormat, ()> tryNew(string aLocale, options aOptions);
string format(date aDate);
protected:
DateTimeFormat(string aLocale, ffi::DateTimeFormatData aData);
UniquePtr<ffi::DateTimeFormatData> mData;
};