some unfinished code...

This commit is contained in:
Kirill Zhumarin 2024-06-01 12:57:41 +00:00
parent 2f6017fb84
commit 2dd1f4a9db
21 changed files with 1024 additions and 84 deletions

201
package-lock.json generated
View file

@ -12,6 +12,9 @@
"@solidjs/router": "^0.13.3",
"bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3",
"date-fns": "^3.6.0",
"highlight.js": "^11.9.0",
"sass": "^1.77.1",
"solid-bootstrap": "^1.0.20",
"solid-js": "^1.8.11"
},
@ -1317,6 +1320,18 @@
"node": ">=4"
}
},
"node_modules/anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
"dependencies": {
"normalize-path": "^3.0.0",
"picomatch": "^2.0.4"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/babel-plugin-jsx-dom-expressions": {
"version": "0.37.20",
"resolved": "https://registry.npmjs.org/babel-plugin-jsx-dom-expressions/-/babel-plugin-jsx-dom-expressions-0.37.20.tgz",
@ -1357,6 +1372,17 @@
"@babel/core": "^7.0.0"
}
},
"node_modules/binary-extensions": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
"integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/bootstrap": {
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.3.tgz",
@ -1390,6 +1416,17 @@
}
]
},
"node_modules/braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dependencies": {
"fill-range": "^7.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/browserslist": {
"version": "4.23.0",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz",
@ -1456,6 +1493,29 @@
"node": ">=4"
}
},
"node_modules/chokidar": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
"integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
"glob-parent": "~5.1.2",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
"readdirp": "~3.6.0"
},
"engines": {
"node": ">= 8.10.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
@ -1482,6 +1542,15 @@
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="
},
"node_modules/date-fns": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz",
"integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/kossnocorp"
}
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@ -1570,11 +1639,21 @@
"node": ">=0.8.0"
}
},
"node_modules/fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dependencies": {
"to-regex-range": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
@ -1593,6 +1672,17 @@
"node": ">=6.9.0"
}
},
"node_modules/glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dependencies": {
"is-glob": "^4.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/globals": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
@ -1611,12 +1701,63 @@
"node": ">=4"
}
},
"node_modules/highlight.js": {
"version": "11.9.0",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.9.0.tgz",
"integrity": "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==",
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/html-entities": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz",
"integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==",
"dev": true
},
"node_modules/immutable": {
"version": "4.3.6",
"resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.6.tgz",
"integrity": "sha512-Ju0+lEMyzMVZarkTn/gqRpdqd5dOPaz1mCZ0SH3JV6iFw81PldE/PEB1hWVEA288HPt4WXW8O7AWxB10M+03QQ=="
},
"node_modules/is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"dependencies": {
"binary-extensions": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-glob": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
"dependencies": {
"is-extglob": "^2.1.1"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"engines": {
"node": ">=0.12.0"
}
},
"node_modules/is-what": {
"version": "4.1.16",
"resolved": "https://registry.npmjs.org/is-what/-/is-what-4.1.16.tgz",
@ -1713,12 +1854,31 @@
"integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==",
"dev": true
},
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/picocolors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz",
"integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==",
"dev": true
},
"node_modules/picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/postcss": {
"version": "8.4.38",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz",
@ -1747,6 +1907,17 @@
"node": "^10 || ^12 || >=14"
}
},
"node_modules/readdirp": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
"dependencies": {
"picomatch": "^2.2.1"
},
"engines": {
"node": ">=8.10.0"
}
},
"node_modules/regenerator-runtime": {
"version": "0.14.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
@ -1787,6 +1958,22 @@
"fsevents": "~2.3.2"
}
},
"node_modules/sass": {
"version": "1.77.1",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.77.1.tgz",
"integrity": "sha512-OMEyfirt9XEfyvocduUIOlUSkWOXS/LAt6oblR/ISXCTukyavjex+zQNm51pPCOiFKY1QpWvEH1EeCkgyV3I6w==",
"dependencies": {
"chokidar": ">=3.0.0 <4.0.0",
"immutable": "^4.0.0",
"source-map-js": ">=0.6.2 <2.0.0"
},
"bin": {
"sass": "sass.js"
},
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
@ -1903,7 +2090,6 @@
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
"integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
@ -1929,6 +2115,17 @@
"node": ">=4"
}
},
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dependencies": {
"is-number": "^7.0.0"
},
"engines": {
"node": ">=8.0"
}
},
"node_modules/update-browserslist-db": {
"version": "1.0.16",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz",

View file

@ -19,6 +19,9 @@
"@solidjs/router": "^0.13.3",
"bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3",
"date-fns": "^3.6.0",
"highlight.js": "^11.9.0",
"sass": "^1.77.1",
"solid-bootstrap": "^1.0.20",
"solid-js": "^1.8.11"
}

View file

@ -1,25 +0,0 @@
import logo from './logo.svg';
import styles from './App.module.css';
function App() {
return (
<div class={styles.App}>
<header class={styles.header}>
<img src={logo} class={styles.logo} alt="logo" />
<p>
Edit <code>src/App.jsx</code> and save to reload.
</p>
<a
class={styles.link}
href="https://github.com/solidjs/solid"
target="_blank"
rel="noopener noreferrer"
>
Learn Solid
</a>
</header>
</div>
);
}
export default App;

View file

@ -1,33 +0,0 @@
.App {
text-align: center;
}
.logo {
animation: logo-spin infinite 20s linear;
height: 40vmin;
pointer-events: none;
}
.header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.link {
color: #b318f0;
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View file

@ -1,11 +1,8 @@
import { createEffect } from 'solid-js';
import { A, useMatch } from "@solidjs/router";
import { Container } from 'solid-bootstrap';
import { Navbar } from 'solid-bootstrap';
import { Nav } from 'solid-bootstrap';
import { NavDropdown } from 'solid-bootstrap';
import { Breadcrumb } from 'solid-bootstrap'
import { resolveURL } from '~/utils';
@ -21,8 +18,8 @@ function HeaderLink(props) {
function Header() {
return (
<Navbar expand="lg" class="bg-body-tertiary">
<Container fluid>
<Navbar.Brand href="#home">Dev Tools</Navbar.Brand>
<Container xxl>
<Navbar.Brand href="/">Dev Tools</Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav">
<Nav class="me-auto">

View file

@ -0,0 +1,38 @@
function SwilibCoverageValue(props) {
if (props.value == null)
return <td></td>;
if (props.value == 100) {
return (
<td class="text-center" title={`Function present on all models in ${props.platform}`}>
<i class="bi bi-check-circle-fill text-success"></i>
</td>
);
} else if (props.value == 0) {
return (
<td class="text-center" title={`Function missing on all models in ${props.platform}`}>
<i class="bi bi-x-circle-fill text-danger"></i>
</td>
);
} else if (props.value >= 90) {
return (
<td class="text-center" title={`Function present on ${props.value}% models in ${props.platform}`}>
<span class="badge small rounded-pill bg-success">{props.value.toFixed(0)}%</span>
</td>
);
} else if (props.value >= 50) {
return (
<td class="text-center" title={`Function present on ${props.value}% models in ${props.platform}`}>
<span class="badge small rounded-pill bg-warning text-dark">{props.value.toFixed(0)}%</span>
</td>
);
} else {
return (
<td class="text-center" title={`Function present on ${props.value}% models in ${props.platform}`}>
<span class="badge small rounded-pill bg-danger">{props.value.toFixed(0)}%</span>
</td>
);
}
}
export default SwilibCoverageValue;

View file

@ -0,0 +1,16 @@
import { SwiFlags } from '~/swilib';
function SwilibEntryBadges(props) {
let badges = [];
if ((props.value & SwiFlags.FROM_PATCH))
badges.push(<span class="badge small rounded-pill bg-danger" title="Function from patch. Don't use in the ELF's!">PATCH</span>);
if ((props.value & SwiFlags.BUILTIN))
badges.push(<span class="badge small rounded-pill bg-info" title="Built-in function from ELFLoader.">LOADER</span>);
if ((props.value & SwiFlags.THUMB))
badges.push(<span class="badge small rounded-pill bg-warning" title="Function alias for THUMB patches. Don't use in ELF's!">THUMB</span>);
if ((props.value & SwiFlags.STUB))
badges.push(<span class="badge small rounded-pill bg-warning" title="This SWI-call is used by the phone OS. Don't use in ELF's!">STUB</span>);
return badges;
}
export default SwilibEntryBadges;

View file

@ -0,0 +1,20 @@
function SwilibEntryName(props) {
if (!props.signature)
return <small class="text-muted">Unused.</small>;
let m = props.signature.trim().match(/^(.*?)\s+([*]+)?([\w\d]+)\s*\((.+?)?\)$/is);
if (m) {
return (
<>
<small class="text-muted">
{m[1]}&nbsp;{m[2] || ""}
</small>
<span class="text-primary">{m[3]}</span>
<span class="text-muted">({m[4] != "" && m[4] != "void" ? "…" : "void"})</span>
</>
);
}
return props.signature;
}
export default SwilibEntryName;

View file

@ -0,0 +1,12 @@
import { SwiType } from '~/swilib';
function SwilibEntryType(props) {
switch (props.value) {
case SwiType.FUNCTION: return <i class="bi bi-c-circle-fill text-muted"></i>;
case SwiType.POINTER: return <i class="bi bi-arrow-up-right-circle text-muted"></i>;
case SwiType.VALUE: return <i class="bi bi-info-circle text-muted"></i>;
}
return <i class="bi bi-x-circle"></i>;
}
export default SwilibEntryType;

View file

@ -0,0 +1,16 @@
import { SwiFlags } from '~/swilib';
function SwilibEntryWarnings(props) {
let badges = [];
if ((props.value & SwiFlags.FROM_PATCH))
badges.push(<span class="text-danger"><i class="bi bi-exclamation-triangle"></i> Function from patch. Don't use in ELF's!</span>);
if ((props.value & SwiFlags.BUILTIN))
badges.push(<span class="text-info"><i class="bi bi-info-circle"></i> Built-in function from ELFLoader.</span>);
if ((props.value & SwiFlags.THUMB))
badges.push(<span class="text-warning"><i class="bi bi-exclamation-triangle"></i> Function alias for THUMB patches. Don't use in ELF's!</span>);
if ((props.value & SwiFlags.STUB))
badges.push(<span class="text-warning"><i class="bi bi-exclamation-triangle"></i> This SWI-call is used by the phone OS. Don't use in ELF's!</span>);
return badges.length ? <div {...props}>{badges}</div> : <></>;
}
export default SwilibEntryWarnings;

View file

@ -0,0 +1,23 @@
function SwilibPhonesTabs(props) {
return (
<div class="d-flex justify-content-between">
<For each={props.phones}>{(phone) =>
<a
class="text-center text-decoration-none"
classList={{
'fw-bold': props.selectedPhone == phone
}}
href={`/swilib/phone/?model=${phone}`}
title={`Swilib info for ${phone}`}
>
<small>{phone.split("v")[0]}</small><br />
<sup class="text-muted">
v{phone.split("v")[1]}
</sup>
</a>
}</For>
</div>
);
}
export default SwilibPhonesTabs;

View file

@ -0,0 +1,21 @@
import { createSignal } from "solid-js";
function TableSortButton(props) {
let [sorted, setSorted] = createSignal(false);
let changeSort = (e) => {
e.preventDefault();
let sortValue = (props.value == 'ASC' ? 'DESC' : 'ASC');
setSorted(true);
props.onChange(sortValue);
};
return (
<span class="table-sort-btn" onClick={changeSort}>
{props.children}
{sorted() ? (props.value == 'ASC' ? ' ▴ ' : ' ▾ ') : ''}
</span>
);
}
export default TableSortButton;

7
src/hljs.js Normal file
View file

@ -0,0 +1,7 @@
import hljs from 'highlight.js/lib/core';
import hljsLangC from 'highlight.js/lib/languages/c';
import 'highlight.js/styles/github.css';
hljs.registerLanguage('c', hljsLangC);
export default hljs;

View file

@ -1,13 +0,0 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

View file

@ -5,12 +5,16 @@ import { Router, Route, Navigate } from "@solidjs/router";
import App from './pages/App';
import 'bootstrap/dist/css/bootstrap.min.css';
import "bootstrap-icons/font/bootstrap-icons.css";
import './index.scss';
const Swilib = lazy(() => import("./pages/Swilib"));
const SwilibPhone = lazy(() => import("./pages/SwilibPhone"));
let dispose = render(() => (
<Router root={App} base={import.meta.env.BASE_URL}>
<Route path="/swilib" component={Swilib} />
<Route path="/swilib/phone" component={SwilibPhone} />
</Router>
), document.getElementById('root'));

23
src/index.scss Normal file
View file

@ -0,0 +1,23 @@
body {
overflow-y: scroll;
}
.table-sticky-header {
thead {
position: sticky;
top: -1px;
}
thead {
box-shadow: 0px 1px 0px var(--bs-table-border-color);
}
th {
background-color: var(--bs-tertiary-bg);
}
}
.table-sort-btn {
cursor: pointer;
user-select: none;
}

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 166 155.3"><path d="M163 35S110-4 69 5l-3 1c-6 2-11 5-14 9l-2 3-15 26 26 5c11 7 25 10 38 7l46 9 18-30z" fill="#76b3e1"/><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="27.5" y1="3" x2="152" y2="63.5"><stop offset=".1" stop-color="#76b3e1"/><stop offset=".3" stop-color="#dcf2fd"/><stop offset="1" stop-color="#76b3e1"/></linearGradient><path d="M163 35S110-4 69 5l-3 1c-6 2-11 5-14 9l-2 3-15 26 26 5c11 7 25 10 38 7l46 9 18-30z" opacity=".3" fill="url(#a)"/><path d="M52 35l-4 1c-17 5-22 21-13 35 10 13 31 20 48 15l62-21S92 26 52 35z" fill="#518ac8"/><linearGradient id="b" gradientUnits="userSpaceOnUse" x1="95.8" y1="32.6" x2="74" y2="105.2"><stop offset="0" stop-color="#76b3e1"/><stop offset=".5" stop-color="#4377bb"/><stop offset="1" stop-color="#1f3b77"/></linearGradient><path d="M52 35l-4 1c-17 5-22 21-13 35 10 13 31 20 48 15l62-21S92 26 52 35z" opacity=".3" fill="url(#b)"/><linearGradient id="c" gradientUnits="userSpaceOnUse" x1="18.4" y1="64.2" x2="144.3" y2="149.8"><stop offset="0" stop-color="#315aa9"/><stop offset=".5" stop-color="#518ac8"/><stop offset="1" stop-color="#315aa9"/></linearGradient><path d="M134 80a45 45 0 00-48-15L24 85 4 120l112 19 20-36c4-7 3-15-2-23z" fill="url(#c)"/><linearGradient id="d" gradientUnits="userSpaceOnUse" x1="75.2" y1="74.5" x2="24.4" y2="260.8"><stop offset="0" stop-color="#4377bb"/><stop offset=".5" stop-color="#1a336b"/><stop offset="1" stop-color="#1a336b"/></linearGradient><path d="M114 115a45 45 0 00-48-15L4 120s53 40 94 30l3-1c17-5 23-21 13-34z" fill="url(#d)"/></svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -1,7 +1,4 @@
import { Container } from 'solid-bootstrap';
import { Row } from 'solid-bootstrap';
import { Col } from 'solid-bootstrap';
import { Spinner } from 'solid-bootstrap';
import Header from '~/components/Header';
@ -9,7 +6,7 @@ function App(props) {
return (
<>
<Header />
<Container fluid className="p-2">
<Container xxl class="p-2">
{props.children}
</Container>
</>

View file

@ -1,5 +1,298 @@
import { on, createResource, createSignal, createMemo, createEffect } from "solid-js";
import { format as dateFormat } from 'date-fns';
import { Form } from 'solid-bootstrap';
import { Spinner } from 'solid-bootstrap';
import { Button } from 'solid-bootstrap';
import { Modal } from 'solid-bootstrap';
import { getPlatformByPhone, formatId } from '~/swilib';
import hljs from '~/hljs';
import TableSortButton from '~/components/TableSortButton';
import SwilibEntryType from "~/components/Swilib/SwilibEntryType";
import SwilibEntryBadges from "~/components/Swilib/SwilibEntryBadges";
import SwilibEntryWarnings from "~/components/Swilib/SwilibEntryWarnings";
import SwilibEntryName from "~/components/Swilib/SwilibEntryName";
import SwilibCoverageValue from "~/components/Swilib/SwilibCoverageValue";
import SwilibPhonesTabs from "~/components/Swilib/SwilibPhonesTabs";
/*
TODO:
1. group by categories
2. show function brief by click
3. per-model table + errors
4. patterns table
5. files for RE
*/
function SwilibEntryCoverageMatrix(props) {
let phonesByPlatform = {};
let supportedByPhone = {};
let maxPhonesCnt = 0;
for (let phone in props.functionsByPhone) {
let platform = getPlatformByPhone(phone);
phonesByPlatform[platform] = phonesByPlatform[platform] || [];
phonesByPlatform[platform].push(phone);
supportedByPhone[phone] = props.functionsByPhone[phone].includes(props.id);
maxPhonesCnt = Math.max(maxPhonesCnt, phonesByPlatform[platform].length);
}
return (
<table class="table table-bordered table-hover" style="width: auto">
<tbody>
<For each={["ELKA", "NSG", "X75", "SG"]}>{(platform) =>
<tr>
<th>{platform}</th>
<For each={phonesByPlatform[platform]}>{(phone) =>
<td>
<Show when={supportedByPhone[phone]}>
<div class="text-success">
<i class="bi bi-check-circle-fill"></i> {phone}
</div>
</Show>
<Show when={!supportedByPhone[phone]}>
<div class="text-danger">
<i class="bi bi-x-circle-fill"></i> {phone}
</div>
</Show>
</td>
}</For>
<Show when={phonesByPlatform[platform].length < maxPhonesCnt}>
<td colspan={10}></td>
</Show>
</tr>
}</For>
</tbody>
</table>
);
}
function SwilibEntryInfo(props) {
let [showModal, setShowModal] = createSignal(true);
return (
<Modal size="lg" centered show={showModal()} onHide={() => setShowModal(false)} onExited={props.onHide}>
<Modal.Header closeButton>
<Modal.Title>
<b>ID:</b> {formatId(props.entry.id)}, <b>offset:</b> {formatId(props.entry.id * 4)}
&nbsp;&nbsp;
<SwilibEntryBadges value={props.entry.flags} />
</Modal.Title>
</Modal.Header>
<Modal.Body>
<div innerHTML={hljs.highlight(props.entry.name || "/* Unused */", { language: 'c' }).value}></div>
<SwilibEntryWarnings value={props.entry.flags} class="my-3" />
<Show when={props.entry.aliases.length > 0}>
<div class="my-3">
<span class="text-muted">
<i class="bi bi-info-square"></i> Old names:
</span>
{' '} {props.entry.aliases.join(', ')}
</div>
</Show>
<Show when={props.entry.name}>
<div class="mt-3">
<SwilibEntryCoverageMatrix id={props.entry.id} functionsByPhone={props.functionsByPhone} />
</div>
</Show>
</Modal.Body>
</Modal>
);
}
function SwilibTableRow(props) {
return (
<>
<tr
style="cursor: pointer"
onClick={() => props.onOpenEntryInfo(props.entry)}
>
<td classList={{ 'text-muted': props.entry.name == null }}>
{formatId(props.entry.id)}
</td>
<td classList={{ 'text-muted': props.entry.name == null }}>
<div class="d-flex justify-content-between align-items-center">
<div>
<SwilibEntryType value={props.entry.type} />
&nbsp;&nbsp;
<SwilibEntryName signature={props.entry.name} />
</div>
<SwilibEntryBadges value={props.entry.flags} />
</div>
<Show when={props.showOldNames}>
{props.entry.aliases.map((aliasName) =>
<div>
<i class="bi bi-info-square"></i>
&nbsp;&nbsp;
<small class="text-muted">Old name:</small>
&nbsp;
<small>{aliasName}</small>
</div>
)}
</Show>
</td>
<SwilibCoverageValue value={props.entry.coverage[1]} platform="ELKA" />
<SwilibCoverageValue value={props.entry.coverage[2]} platform="NSG" />
<SwilibCoverageValue value={props.entry.coverage[3]} platform="X75" />
<SwilibCoverageValue value={props.entry.coverage[4]} platform="SG" />
</tr>
</>
);
}
function SwilibTable(props) {
let [tableIdSort, setTableIdSort] = createSignal('ASC');
let [isHidden, setIsHidden] = createSignal(false);
let [entryInfo, setEntryInfo] = createSignal(false);
let functions = createMemo(() => {
let sortAsc = tableIdSort() == 'ASC';
props.functions.sort((a, b) => sortAsc ? a.id - b.id : b.id - a.id);
return props.functions;
}, [], { equals: () => false });
createEffect(on(props.collapseSignal, (needCollapse) => setIsHidden(needCollapse), { defer: true }));
let onOpenEntryInfo = (entry) => {
setEntryInfo(entry);
};
return (
<div>
<h4 onClick={() => setIsHidden(!isHidden())} style={{ cursor: 'pointer' }}>
<i class={`bi ${isHidden() ? 'bi-plus-square' : 'bi-dash-square'}`}></i> {' '}
{props.file}
</h4>
<table class="table table-bordered table-hover table-sticky-header test" style="width: 100%; max-width: 900px" hidden={isHidden()}>
<thead class="thead-dark">
<tr>
<th class="text-center">
<TableSortButton value={tableIdSort()} onChange={setTableIdSort}>
<small>ID</small>
</TableSortButton>
</th>
<th style="width:100%">
<small>Function</small>
</th>
<th class="text-center">
<small>ELKA</small>
</th>
<th class="text-center">
<small>NSG</small>
</th>
<th class="text-center">
<small>X75</small>
</th>
<th class="text-center">
<small>SG</small>
</th>
</tr>
</thead>
<tbody>
<For each={functions()}>{(row) =>
<SwilibTableRow
entry={row}
onOpenEntryInfo={onOpenEntryInfo}
showOldNames={props.showOldNames}
/>
}</For>
</tbody>
</table>
<Show when={entryInfo()}>
<SwilibEntryInfo
file={props.file}
entry={entryInfo()}
functionsByPhone={props.functionsByPhone}
onHide={() => setEntryInfo(false)}
/>
</Show>
</div>
);
}
async function swilibFetcher(params) {
let url = params.groupByFile ? '/functions-summary-by-file.json' : '/functions-summary.json';
return (await fetch(`http://localhost:4000${url}`)).json();
}
function Swilib() {
return <div>ololo</div>;
let [groupByFile, setGroupByFile] = createSignal(false);
let [apiResult] = createResource(() => ({ groupByFile: groupByFile() }), swilibFetcher);
let [globalCollapsed, setGlobalCollapsed] = createSignal(false);
let [showOldNames, setShowOldNames] = createSignal(true);
let [phonesList, setPhonesList] = createSignal([]);
createEffect(() => {
if (apiResult()) {
setPhonesList(Object.keys(apiResult().functionsByPhone));
}
});
return <>
<div class="mb-3">
<div class="mb-2">
<SwilibPhonesTabs phones={phonesList()} />
</div>
<div class="d-flex justify-content-start">
<div class="align-self-center me-3">
<Form.Check
type="checkbox"
id="group-by-c-header"
label="Group by C-header"
checked={groupByFile()}
onChange={(e) => setGroupByFile(e.target.checked)}
/>
</div>
<div class="align-self-center me-3">
<Form.Check
type="checkbox"
id="show-old-names"
label="Show old names"
checked={showOldNames()}
onChange={(e) => setShowOldNames(e.target.checked)}
/>
</div>
<Button variant="outline-primary" onClick={() => setGlobalCollapsed(!globalCollapsed())}>
<Show when={!globalCollapsed()}>
<i class="bi bi-eye-slash"></i> Collapse all
</Show>
<Show when={globalCollapsed()}>
<i class="bi bi-eye"></i> Expand all
</Show>
</Button>
</div>
</div>
<Show when={apiResult.loading}>
<Spinner animation="border" role="status">
<span className="visually-hidden">Loading...</span>
</Spinner>
</Show>
<Show when={apiResult.error}>
<div class="alert alert-danger" role="alert">
Can't load data from the server. Please, reload the page.
</div>
</Show>
<Show when={!apiResult.loading && !apiResult.error}>
<div class="alert alert-info" role="alert">
Next free ID: <b>{apiResult().nextId.toString(16).padStart(3, '0').toUpperCase()}</b>,
last update: <b>{dateFormat(new Date(apiResult().timestamp), 'yyyy-MM-dd HH:mm')}</b>
</div>
<For each={Object.keys(apiResult().files)}>{(file, id) =>
<SwilibTable
collapseSignal={globalCollapsed}
file={file}
functions={apiResult().files[file]}
functionsByPhone={apiResult().functionsByPhone}
showOldNames={showOldNames()}
/>
}</For>
</Show>
</>;
}
export default Swilib;

315
src/pages/SwilibPhone.jsx Normal file
View file

@ -0,0 +1,315 @@
import { createResource, createSignal, createMemo, createEffect, on } from 'solid-js';
import { useSearchParams } from '@solidjs/router';
import { Spinner } from 'solid-bootstrap';
import { Form } from 'solid-bootstrap';
import { Button } from 'solid-bootstrap';
import { Badge } from 'solid-bootstrap';
import { getPlatformByPhone, formatId, SwiFlags } from '~/swilib';
import TableSortButton from '~/components/TableSortButton';
import SwilibEntryType from "~/components/Swilib/SwilibEntryType";
import SwilibEntryBadges from "~/components/Swilib/SwilibEntryBadges";
import SwilibEntryWarnings from "~/components/Swilib/SwilibEntryWarnings";
import SwilibEntryName from "~/components/Swilib/SwilibEntryName";
function getRowColor(swilib, entry) {
if (swilib.errors[entry.id])
return 'table-danger';
if (entry.name == null)
return '';
if ((entry.flags & SwiFlags.BUILTIN))
return 'table-info';
if (swilib.values[entry.id] == null)
return 'table-warning';
return '';
}
function SwilibTableRow(props) {
return (
<>
<tr class={getRowColor(props.swilib, props.entry)}>
<td classList={{ 'text-muted': props.entry.name == null }}>
{formatId(props.entry.id)}
</td>
<td classList={{ 'text-muted': props.entry.name == null }} hidden={!props.showEntryOffset}>
{formatId(props.entry.id * 4)}
</td>
<td classList={{ 'text-muted': props.entry.name == null }}>
<div class="d-flex justify-content-between align-items-center">
<div>
<SwilibEntryType value={props.entry.type} />
&nbsp;&nbsp;
<SwilibEntryName signature={props.entry.name} />
</div>
<SwilibEntryBadges value={props.entry.flags} />
</div>
<Show when={props.showOldNames}>
{props.entry.aliases.map((aliasName) =>
<div>
<i class="bi bi-info-square"></i>
&nbsp;&nbsp;
<small class="text-muted">Old name:</small>
&nbsp;
<small>{aliasName}</small>
</div>
)}
</Show>
<Show when={props.swilib.errors[props.entry.id]}>
<div class="text-danger">
<i class="bi bi-exclamation-triangle"></i> {props.swilib.errors[props.entry.id]}
</div>
</Show>
</td>
<td classList={{ 'text-muted': props.entry.name == null }}>
<Show when={props.swilib.values[props.entry.id] != null}>
{props.swilib.values[props.entry.id].toString(16).padStart(8, '0').toUpperCase()}
</Show>
</td>
</tr>
</>
);
}
function SwilibTable(props) {
let [tableIdSort, setTableIdSort] = createSignal('ASC');
let [isHidden, setIsHidden] = createSignal(false);
let functions = createMemo(() => {
let sortAsc = tableIdSort() == 'ASC';
let newFunctions = [...props.functions];
newFunctions.sort((a, b) => sortAsc ? a.id - b.id : b.id - a.id);
if (props.filterByType == 'errors') {
newFunctions = newFunctions.filter((entry) => props.swilib.errors[entry.id]);
} else if (props.filterByType == 'errors-plus-missing') {
newFunctions = newFunctions.filter((entry) => props.swilib.errors[entry.id] || props.swilib.values[entry.id] == null);
}
return newFunctions;
});
createEffect(on(props.collapseSignal, (needCollapse) => setIsHidden(needCollapse), { defer: true }));
return (
<div hidden={functions().length == 0}>
<h4 onClick={() => setIsHidden(!isHidden())} style={{ cursor: 'pointer' }}>
<i class={`bi ${isHidden() ? 'bi-plus-square' : 'bi-dash-square'}`}></i> {' '}
{props.file}
</h4>
<table class="table table-bordered table-hover table-sticky-header test" style="width: 100%; max-width: 900px" hidden={isHidden()}>
<thead class="thead-dark">
<tr>
<th class="text-center">
<TableSortButton value={tableIdSort()} onChange={setTableIdSort}>
<small>ID</small>
</TableSortButton>
</th>
<th class="text-center" hidden={!props.showEntryOffset}>
<small>OFF</small>
</th>
<th style="width:100%">
<small>Function</small>
</th>
<th class="text-center">
<small>Value</small>
</th>
</tr>
</thead>
<tbody>
<For each={functions()}>{(row) =>
<SwilibTableRow
entry={row}
showOldNames={props.showOldNames}
showEntryOffset={props.showEntryOffset}
swilib={props.swilib}
/>
}</For>
</tbody>
</table>
</div>
);
}
function SwilibStatistic(props) {
let errorsCnt = 0;
let missingCnt = 0;
let goodCnt = 0;
let totalCnt = props.swilib.values.length;
for (let id = 0; id < totalCnt; id++) {
if (props.swilib.errors[id]) {
errorsCnt++;
} else if (props.swilib.missing.includes(id)) {
missingCnt++;
} else {
goodCnt++;
}
}
let calcPct = (v) => (v / totalCnt * 100).toFixed(0);
return (
<div class="mb-3">
<Badge title="Good functions." bg="success fs-6">OK: {goodCnt} | {calcPct(goodCnt)}%</Badge>
{' '}
<Badge title="Bad functions." bg="danger fs-6">BAD: {errorsCnt} | {calcPct(errorsCnt)}%</Badge>
{' '}
<Badge title="Missing functions." bg="warning text-dark fs-6">MISS: {missingCnt}| {calcPct(missingCnt)}%</Badge>
</div>
);
}
async function swilibFetcher(params) {
let [swilib, summary] = await Promise.all([
(await fetch(`http://localhost:4000/functions-phone-${params.model}.json`)).json(),
(await fetch(`http://localhost:4000/functions-${params.groupByFile ? 'summary-by-file' : 'summary'}.json`)).json(),
]);
return { swilib, summary };
}
function SwilibPhone() {
let [searchParams] = useSearchParams();
let [groupByFile, setGroupByFile] = createSignal(false);
let [globalCollapsed, setGlobalCollapsed] = createSignal(false);
let [showOldNames, setShowOldNames] = createSignal(true);
let [showEntryOffset, setShowEntryOffset] = createSignal(false);
let [showOriginalSymbol, setShowOriginalSymbol] = createSignal(false);
let [filterByType, setFilterByType] = createSignal('all');
let [apiResult] = createResource(() => ({ model: searchParams.model, groupByFile: groupByFile() }), swilibFetcher);
let showBadFunctions = () => {
setFilterByType('errors');
};
return (
<>
<div class="d-flex justify-content-start mb-3">
<div class="align-self-center me-3">
<Form.Check
type="checkbox"
id="group-by-c-header"
label="Group by C-header"
checked={groupByFile()}
onChange={(e) => setGroupByFile(e.target.checked)}
/>
</div>
<div class="align-self-center me-3">
<Form.Check
type="checkbox"
id="show-old-names"
label="Show old names"
checked={showOldNames()}
onChange={(e) => setShowOldNames(e.target.checked)}
/>
</div>
<div class="align-self-center me-3">
<Form.Check
type="checkbox"
id="show-offsets"
label="Show offsets"
checked={showEntryOffset()}
onChange={(e) => setShowEntryOffset(e.target.checked)}
/>
</div>
<div class="align-self-center me-3">
<Form.Check
type="checkbox"
id="show-original-sym"
label="Show names in .VKP"
checked={showOriginalSymbol()}
onChange={(e) => setShowOriginalSymbol(e.target.checked)}
/>
</div>
<Button variant="outline-primary" onClick={() => setGlobalCollapsed(!globalCollapsed())}>
<Show when={!globalCollapsed()}>
<i class="bi bi-eye-slash"></i> Collapse all
</Show>
<Show when={globalCollapsed()}>
<i class="bi bi-eye"></i> Expand all
</Show>
</Button>
</div>
<div class="d-flex flex-row mb-3">
<span class="me-3"><i class="bi bi-funnel"></i> Show functions:</span>
<Form.Check
inline
type="radio"
id="filter-type-all"
name="filter-type"
label="All"
value="all"
checked={filterByType() == 'all'}
onChange={(e) => e.target.checked && setFilterByType(e.target.value)}
/>
<Form.Check
inline
type="radio"
class="text-danger"
id="filter-type-errors"
name="filter-type"
label="With errors"
value="errors"
checked={filterByType() == 'errors'}
onChange={(e) => e.target.checked && setFilterByType(e.target.value)}
/>
<Form.Check
inline
type="radio"
class="text-danger"
id="filter-type-errors-missing"
name="filter-type"
label="With errors + missing"
value="errors-plus-missing"
checked={filterByType() == 'errors-plus-missing'}
onChange={(e) => e.target.checked && setFilterByType(e.target.value)}
/>
</div>
<Show when={apiResult.loading}>
<Spinner animation="border" role="status">
<span className="visually-hidden">Loading...</span>
</Spinner>
</Show>
<Show when={apiResult.error}>
<div class="alert alert-danger" role="alert">
Can't load data from the server. Please, reload the page.
</div>
</Show>
<Show when={!apiResult.loading && !apiResult.error}>
<Show when={Object.keys(apiResult().swilib.errors).length > 0}>
<div class="alert alert-danger" role="alert">
Swilib has <b>{Object.keys(apiResult().swilib.errors).length}</b> fatal errors!!!
<Button variant="outline-danger ms-3" size="sm" onClick={showBadFunctions} hidden={filterByType() == 'errors'}>
Show bad functions
</Button>
</div>
</Show>
<SwilibStatistic swilib={apiResult().swilib} />
<For each={Object.keys(apiResult().summary.files)}>{(file) =>
<SwilibTable
collapseSignal={globalCollapsed}
filterByType={filterByType()}
file={file}
functions={apiResult().summary.files[file]}
showOldNames={showOldNames()}
showEntryOffset={showEntryOffset()}
swilib={apiResult().swilib}
/>
}</For>
</Show>
</>
);
}
export default SwilibPhone;

30
src/swilib.js Normal file
View file

@ -0,0 +1,30 @@
export const SwiType = {
EMPTY: 0,
FUNCTION: 1,
POINTER: 2,
VALUE: 3,
};
export const SwiFlags = {
BUILTIN: 1 << 0,
FROM_PATCH: 1 << 1,
THUMB: 1 << 2,
STUB: 1 << 3,
HALF_BUILTIN: 1 << 4,
};
export function formatId(id) {
return id.toString(16).padStart(3, '0').toUpperCase();
}
export function getPlatformByPhone(phone) {
let m = phone.match(/^(.*?)(?:v|sw)([\d+_]+)$/i);
let model = m[1];
if (/^(EL71|EL71C|E71C|E71|CL61|M72|C1F0)$/i.test(model))
return "ELKA";
if (/^(C81|S75|SL75|S68|S7C)$/i.test(model))
return "NSG";
if (/^(CX75|ME75|CF75|M75|C75|C72)$/i.test(model))
return "X75";
return "SG";
}