diff options
-rw-r--r-- | diheap/index.html | 85 | ||||
-rw-r--r-- | img/artix.png | bin | 14591 -> 0 bytes | |||
-rw-r--r-- | img/artix.svg | 22 | ||||
-rw-r--r-- | img/icon.ico | bin | 1406 -> 0 bytes | |||
-rw-r--r-- | index.html | 5 | ||||
-rw-r--r-- | moditos/index.html | 18 | ||||
-rw-r--r-- | prism/prism.css | 3 | ||||
-rw-r--r-- | prism/prism.js | 8 | ||||
-rw-r--r-- | projects/learning-rust/1.html | 69 | ||||
-rw-r--r-- | projects/learning-rust/index.html | 27 | ||||
-rw-r--r-- | vex/index.html | 33 |
11 files changed, 111 insertions, 159 deletions
diff --git a/diheap/index.html b/diheap/index.html deleted file mode 100644 index 8d0bc48..0000000 --- a/diheap/index.html +++ /dev/null @@ -1,85 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Drop-in Heap</title> - - <link rel="stylesheet" href="/style.css"> -</head> -<body> - <div class="page-body-border"><div class="page-body"> - <h1 class="page-body-top">Drop-in Heap</h1> - <div class="page-body-content"> - <table class="page-body-buttons" style="width: 20%; margin: 0px;"> - <tr><td><div class="link-button-border"><a class="link-button" href="/">Home</a></div></td></tr> - <tr><td><div class="link-button-border"><a class="link-button" href="https://git.jonsantmyer.com/diheap/">Git repository</a></div></td></tr> - <tr><td><div class="link-button-border"><a class="link-button" href="https://git.jonsantmyer.com/diheap/snapshot/diheap-1.0.tar.gz">Download (1.0 tar.gz)</a></div></td></tr> - <tr><td><div class="link-button-border"><a class="link-button" href="https://git.jonsantmyer.com/diheap/snapshot/diheap-1.0.zip">Download (1.0 zip)</a></div></td></tr> - </table> - <h3>Purpose</h3> - <p> - diheap was designed for the Modit Operating System. Therefore, it was created with the assumption that the linked libraries have direct access to memory and has no other dynamic allocation scheme. - Because of these constraints, the heap has an initial capacity as defined by the user through the "heap_create" function. To expand the heap, the user has to allocate the memory following it's bounds. - </p> - <h3>Design</h3> - <p> - A vast majority of the technical descriptions of how the heap works are in the header file. see <a href="https://git.jonsantmyer.com/diheap/tree/heap.h">heap.h</a> for more details. - </p><p> - diheap is a thread-unsafe double linked-list bucket heap allocator. It was written to allow for respectably fast variable size object allocations without external memory regions. - The heap information is stored in a single heap struct, which is created through heap_create. - </p><p> - When heap_create is called, the library creates a struct called a "crate", which stores the buckets used for heap allocation. Each crate is 4KiB in size, and can store an arbitrary ammount of buckets. - When the crate is out of buckets, another crate is appended to the last allocation and is linked to the previous crate. - </p><p> - Buckets act as both a pointer to allocated memory and a node in a doubly linked list. - Buckets store their neighbors, the address, size, and if the bucket is occupied. - The elements buckets store allows for checking the status of an arbitrary ammount of neighbors from any point in the linked list. - Buckets that don't have a memory address assigned to them are added to a free list, which lets the heap allocate more memory for itself. - When the freelist is drained, a new crate is created at the end of the address space and the new buckets are added to the freelist. - </p> - <h3>API</h3> - <p>diheap is designed to "drop in" to any project. I designed the interface to be independent of the system and operate without many quality of life features like dynamic memory and reference counting.</p> - - <//heap_create> - <p class="text-inset"><font color="green">int</font> heap_create(<font color="green">struct</font> heap <font color="red">*</font>heap, <font color="green">uintptr_t</font> at, <font color="green">size_t</font> len);</p> - <p>Populates the heap with the initial crate and bucket lists. Fills the fields in the provided heap object with the bucket lists and usage information.</p> - <p class="text-inset">heap</p><p style="display:inline-block;">Pointer to object defined at compile time.</p><br/> - <p class="text-inset">at</p><p style="display:inline-block;">Address allocated for heap to operate in</p><br/> - <p class="text-inset">len</p><p style="display:inline-block">Size of memory allocated for heap to operate in. Must be larger than MODIT_HEAP_CRATE_SIZE</p><br/> - <p class="text-inset">return</p><p style="display:inline-block">Success code. Anything that is not zero should be treated as an error code.</p><br/><br/><br/> - - <//heap_resize> - <p class="text-inset"><font color="green">void</font> heap_resize(<font color="green">struct</font> heap <font color="red">*</font>heap, <font color="green">size_t</font> newlen);</p> - <p>Marks the space appended by newlen as usable inside of the passed heap.</p> - <p class="text-inset">heap</p><p style="display:inline-block;">Pointer to heap object in which to resize.</p><br/> - <p class="text-inset">newlen</p><p style="display:inline-block">Size of memory appended to the heap allocation space. Because the heap cannot be relocated, this is the only way to expand it.</p><br/><br/><br/> - - <//heap_alloc> - <p class="text-inset"><font color="green">void</font> <font color="red">*</font>heap_alloc(<font color="green">struct</font> heap <font color="red">*</font>heap, <font color="green">size_t</font> size);</p> - <p>Looks for and assigns the best fitting empty block in heap memory. If the block is too large, the heap splits the block into a perfectly sized bucket and a spare bucket. The heap returns the perfectly sized bucket if possible.</p> - <p class="text-inset">heap</p><p style="display:inline-block;">Pointer to heap object in which to make the allocation</p><br/> - <p class="text-inset">size</p><p style="display:inline-block">Size of memory allocated in heap.</p><br/> - <p class="text-inset">return</p><p style="display:inline-block">Pointer to memory assigned by heap. If the heap has run out of memory, function returns <font color="purple">NULL</font></p><br/><br/><br/> - - <//heap_free> - <p class="text-inset"><font color="green">void</font> heap_free(<font color="green">struct</font> heap <font color="red">*</font>heap, <font color="green">void</font> <font color="red">*</font>ptr);</p> - <p>Looks for the bucket corresponding to the passed pointer and clears the taken flag bit. When two buckets are adjacent and free, they are merged.</p> - <p class="text-inset">heap</p><p style="display:inline-block;">Pointer to heap object in which to make the allocation</p><br/> - <p class="text-inset">size</p><p style="display:inline-block">Size of memory allocated in heap.</p><br/> - <p class="text-inset">return</p><p style="display:inline-block">Pointer to memory assigned by heap. If the heap has run out of memory, function returns <font color="purple">NULL</font></p> - - <h3>Building</h3> - <p>diheap can be built as either a static or linked library</p> - <p class="text-inset">NOTE: build instructions are written assuming linux with gcc</p> - <br/> - <p style="display:inline-block;">diheap is built using a makefile following GNU Make specifications. To build the library, simply call<p class="text-inset">make</p></p> - <p>By default, the makefile builds a shared library without debugging symbols. This can be changed with the following build flags:</p> - <p class="text-inset">SHARED</p><p style="display:inline-block"> Defines if the makefile should build a shared library.</p><p class="text-inset">default: 1</p><br/> - <p class="text-inset">STATIC</p><p style="display:inline-block"> Defines if the makefile should build a static library.</p><p class="text-inset">default: 0</p><br/> - <p class="text-inset">TEST</p><p style="display:inline-block"> Forces the makefile to build a shared library and test program. Said program automatically runs.</p><p class="text-inset">default: 0</p> - </div> - <p class="text-inset"> - LICENSE: MIT (c) 2021 Jon Santmyer (jon@jonsantmyer.com) - </p> - </div> -</body> -</html> diff --git a/img/artix.png b/img/artix.png Binary files differdeleted file mode 100644 index 02253fe..0000000 --- a/img/artix.png +++ /dev/null diff --git a/img/artix.svg b/img/artix.svg deleted file mode 100644 index 933d4bf..0000000 --- a/img/artix.svg +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" standalone="no"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" - "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> -<svg version="1.0" xmlns="http://www.w3.org/2000/svg" - width="150.000000pt" height="158.000000pt" viewBox="0 0 150.000000 158.000000" - preserveAspectRatio="xMidYMid meet"> -<metadata> -Created by potrace 1.16, written by Peter Selinger 2001-2019 -</metadata> -<g transform="translate(0.000000,158.000000) scale(0.100000,-0.100000)" -fill="#000000" stroke="none"> -<path d="M0 790 l0 -790 750 0 750 0 0 790 0 790 -750 0 -750 0 0 -790z m955 -310 c109 -228 202 -422 209 -430 26 -33 -44 25 -240 201 -113 101 -217 194 --231 205 l-25 22 21 128 c41 245 53 306 62 297 4 -4 96 -195 204 -423z m-388 --367 c234 -177 272 -208 272 -218 0 -9 -579 -358 -684 -412 l-43 -22 13 27 -c13 26 234 560 277 670 11 28 24 52 28 52 5 0 66 -44 137 -97z m650 -69 c-3 --3 -12 -4 -19 -1 -8 3 -5 6 6 6 11 1 17 -2 13 -5z m10 -166 c-3 -7 -5 -2 -5 -12 0 14 2 19 5 13 2 -7 2 -19 0 -25z m77 -120 c8 -18 48 -104 89 -190 l76 --158 -42 27 c-23 14 -95 62 -160 105 -107 72 -117 81 -105 96 8 9 36 47 62 85 -26 37 51 67 56 67 6 0 16 -15 24 -32z"/> -</g> -</svg> diff --git a/img/icon.ico b/img/icon.ico Binary files differdeleted file mode 100644 index 5769682..0000000 --- a/img/icon.ico +++ /dev/null @@ -32,7 +32,10 @@ <div class="window"> <div class="window-title"><h2 style="padding: 0px; margin: 0px;">Projects</h2></div> <div class="window-content"> - + <div> + <a class="link-button" href="projects/learning-rust">Learning Rust</a> + <p style="display: inline-block"> : Figuring out Rust in the best possible way: using it</p> + </div> </div> </div> </body> diff --git a/moditos/index.html b/moditos/index.html deleted file mode 100644 index 2485f54..0000000 --- a/moditos/index.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Jon Santmyer</title> - - <link rel="stylesheet" href="/style.css"> -</head> -<body> - <div class="page-body-border"><div class="page-body"> - <h1 class="page-body-top">Modit OS</h1> - <div class="page-body-content"> - <table class="page-body-buttons" style="width: 20%; margin: 0px;"> - <tr><td><div class="link-button-border"><a class="link-button" href="/">Home</a></div></td></tr> - <tr><td><div class="link-button-border"><a class="link-button" href="https://git.jonsantmyer.com/modit-slim">Git repository</a></div></td></tr> - </table> - </div></div> -</body> -</html> diff --git a/prism/prism.css b/prism/prism.css new file mode 100644 index 0000000..f6a8f91 --- /dev/null +++ b/prism/prism.css @@ -0,0 +1,3 @@ +/* PrismJS 1.29.0 +https://prismjs.com/download.html#themes=prism&languages=markup+clike+c+cpp+rust */ +code[class*=language-],pre[class*=language-]{color:#000;background:0 0;text-shadow:0 1px #fff;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#f5f2f0}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#999}.token.namespace{opacity:.7}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol,.token.tag{color:#905}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#690}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url{color:#9a6e3a;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.class-name,.token.function{color:#dd4a68}.token.important,.token.regex,.token.variable{color:#e90}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help} diff --git a/prism/prism.js b/prism/prism.js new file mode 100644 index 0000000..f7d9da5 --- /dev/null +++ b/prism/prism.js @@ -0,0 +1,8 @@ +/* PrismJS 1.29.0 +https://prismjs.com/download.html#themes=prism&languages=markup+clike+c+cpp+rust */ +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(e){var n=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,t=0,r={},a={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(n){return n instanceof i?new i(n.type,e(n.content),n.alias):Array.isArray(n)?n.map(e):n.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++t}),e.__id},clone:function e(n,t){var r,i;switch(t=t||{},a.util.type(n)){case"Object":if(i=a.util.objId(n),t[i])return t[i];for(var l in r={},t[i]=r,n)n.hasOwnProperty(l)&&(r[l]=e(n[l],t));return r;case"Array":return i=a.util.objId(n),t[i]?t[i]:(r=[],t[i]=r,n.forEach((function(n,a){r[a]=e(n,t)})),r);default:return n}},getLanguage:function(e){for(;e;){var t=n.exec(e.className);if(t)return t[1].toLowerCase();e=e.parentElement}return"none"},setLanguage:function(e,t){e.className=e.className.replace(RegExp(n,"gi"),""),e.classList.add("language-"+t)},currentScript:function(){if("undefined"==typeof document)return null;if("currentScript"in document)return document.currentScript;try{throw new Error}catch(r){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack)||[])[1];if(e){var n=document.getElementsByTagName("script");for(var t in n)if(n[t].src==e)return n[t]}return null}},isActive:function(e,n,t){for(var r="no-"+n;e;){var a=e.classList;if(a.contains(n))return!0;if(a.contains(r))return!1;e=e.parentElement}return!!t}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(e,n){var t=a.util.clone(a.languages[e]);for(var r in n)t[r]=n[r];return t},insertBefore:function(e,n,t,r){var i=(r=r||a.languages)[e],l={};for(var o in i)if(i.hasOwnProperty(o)){if(o==n)for(var s in t)t.hasOwnProperty(s)&&(l[s]=t[s]);t.hasOwnProperty(o)||(l[o]=i[o])}var u=r[e];return r[e]=l,a.languages.DFS(a.languages,(function(n,t){t===u&&n!=e&&(this[n]=l)})),l},DFS:function e(n,t,r,i){i=i||{};var l=a.util.objId;for(var o in n)if(n.hasOwnProperty(o)){t.call(n,o,n[o],r||o);var s=n[o],u=a.util.type(s);"Object"!==u||i[l(s)]?"Array"!==u||i[l(s)]||(i[l(s)]=!0,e(s,t,o,i)):(i[l(s)]=!0,e(s,t,null,i))}}},plugins:{},highlightAll:function(e,n){a.highlightAllUnder(document,e,n)},highlightAllUnder:function(e,n,t){var r={callback:t,container:e,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};a.hooks.run("before-highlightall",r),r.elements=Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)),a.hooks.run("before-all-elements-highlight",r);for(var i,l=0;i=r.elements[l++];)a.highlightElement(i,!0===n,r.callback)},highlightElement:function(n,t,r){var i=a.util.getLanguage(n),l=a.languages[i];a.util.setLanguage(n,i);var o=n.parentElement;o&&"pre"===o.nodeName.toLowerCase()&&a.util.setLanguage(o,i);var s={element:n,language:i,grammar:l,code:n.textContent};function u(e){s.highlightedCode=e,a.hooks.run("before-insert",s),s.element.innerHTML=s.highlightedCode,a.hooks.run("after-highlight",s),a.hooks.run("complete",s),r&&r.call(s.element)}if(a.hooks.run("before-sanity-check",s),(o=s.element.parentElement)&&"pre"===o.nodeName.toLowerCase()&&!o.hasAttribute("tabindex")&&o.setAttribute("tabindex","0"),!s.code)return a.hooks.run("complete",s),void(r&&r.call(s.element));if(a.hooks.run("before-highlight",s),s.grammar)if(t&&e.Worker){var c=new Worker(a.filename);c.onmessage=function(e){u(e.data)},c.postMessage(JSON.stringify({language:s.language,code:s.code,immediateClose:!0}))}else u(a.highlight(s.code,s.grammar,s.language));else u(a.util.encode(s.code))},highlight:function(e,n,t){var r={code:e,grammar:n,language:t};if(a.hooks.run("before-tokenize",r),!r.grammar)throw new Error('The language "'+r.language+'" has no grammar.');return r.tokens=a.tokenize(r.code,r.grammar),a.hooks.run("after-tokenize",r),i.stringify(a.util.encode(r.tokens),r.language)},tokenize:function(e,n){var t=n.rest;if(t){for(var r in t)n[r]=t[r];delete n.rest}var a=new s;return u(a,a.head,e),o(e,a,n,a.head,0),function(e){for(var n=[],t=e.head.next;t!==e.tail;)n.push(t.value),t=t.next;return n}(a)},hooks:{all:{},add:function(e,n){var t=a.hooks.all;t[e]=t[e]||[],t[e].push(n)},run:function(e,n){var t=a.hooks.all[e];if(t&&t.length)for(var r,i=0;r=t[i++];)r(n)}},Token:i};function i(e,n,t,r){this.type=e,this.content=n,this.alias=t,this.length=0|(r||"").length}function l(e,n,t,r){e.lastIndex=n;var a=e.exec(t);if(a&&r&&a[1]){var i=a[1].length;a.index+=i,a[0]=a[0].slice(i)}return a}function o(e,n,t,r,s,g){for(var f in t)if(t.hasOwnProperty(f)&&t[f]){var h=t[f];h=Array.isArray(h)?h:[h];for(var d=0;d<h.length;++d){if(g&&g.cause==f+","+d)return;var v=h[d],p=v.inside,m=!!v.lookbehind,y=!!v.greedy,k=v.alias;if(y&&!v.pattern.global){var x=v.pattern.toString().match(/[imsuy]*$/)[0];v.pattern=RegExp(v.pattern.source,x+"g")}for(var b=v.pattern||v,w=r.next,A=s;w!==n.tail&&!(g&&A>=g.reach);A+=w.value.length,w=w.next){var E=w.value;if(n.length>e.length)return;if(!(E instanceof i)){var P,L=1;if(y){if(!(P=l(b,A,e,m))||P.index>=e.length)break;var S=P.index,O=P.index+P[0].length,j=A;for(j+=w.value.length;S>=j;)j+=(w=w.next).value.length;if(A=j-=w.value.length,w.value instanceof i)continue;for(var C=w;C!==n.tail&&(j<O||"string"==typeof C.value);C=C.next)L++,j+=C.value.length;L--,E=e.slice(A,j),P.index-=A}else if(!(P=l(b,0,E,m)))continue;S=P.index;var N=P[0],_=E.slice(0,S),M=E.slice(S+N.length),W=A+E.length;g&&W>g.reach&&(g.reach=W);var z=w.prev;if(_&&(z=u(n,z,_),A+=_.length),c(n,z,L),w=u(n,z,new i(f,p?a.tokenize(N,p):N,k,N)),M&&u(n,w,M),L>1){var I={cause:f+","+d,reach:W};o(e,n,t,w.prev,A,I),g&&I.reach>g.reach&&(g.reach=I.reach)}}}}}}function s(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function u(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function c(e,n,t){for(var r=n.next,a=0;a<t&&r!==e.tail;a++)r=r.next;n.next=r,r.prev=n,e.length-=a}if(e.Prism=a,i.stringify=function e(n,t){if("string"==typeof n)return n;if(Array.isArray(n)){var r="";return n.forEach((function(n){r+=e(n,t)})),r}var i={type:n.type,content:e(n.content,t),tag:"span",classes:["token",n.type],attributes:{},language:t},l=n.alias;l&&(Array.isArray(l)?Array.prototype.push.apply(i.classes,l):i.classes.push(l)),a.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=" "+s+'="'+(i.attributes[s]||"").replace(/"/g,""")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'"'+o+">"+i.content+"</"+i.tag+">"},!e.document)return e.addEventListener?(a.disableWorkerMessageHandler||e.addEventListener("message",(function(n){var t=JSON.parse(n.data),r=t.language,i=t.code,l=t.immediateClose;e.postMessage(a.highlight(i,a.languages[r],r)),l&&e.close()}),!1),a):a;var g=a.util.currentScript();function f(){a.manual||a.highlightAll()}if(g&&(a.filename=g.src,g.hasAttribute("data-manual")&&(a.manual=!0)),!a.manual){var h=document.readyState;"loading"===h||"interactive"===h&&g&&g.defer?document.addEventListener("DOMContentLoaded",f):window.requestAnimationFrame?window.requestAnimationFrame(f):window.setTimeout(f,16)}return a}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); +Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup,Prism.hooks.add("wrap",(function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&/,"&"))})),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(a,e){var s={};s["language-"+e]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[e]},s.cdata=/^<!\[CDATA\[|\]\]>$/i;var t={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:s}};t["language-"+e]={pattern:/[\s\S]+/,inside:Prism.languages[e]};var n={};n[a]={pattern:RegExp("(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[^])*?(?=</__>)".replace(/__/g,(function(){return a})),"i"),lookbehind:!0,greedy:!0,inside:t},Prism.languages.insertBefore("markup","cdata",n)}}),Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(a,e){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp("(^|[\"'\\s])(?:"+a+")\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s'\">=]+(?=[\\s>]))","i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[e,"language-"+e],inside:Prism.languages[e]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup,Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.ssml=Prism.languages.xml,Prism.languages.atom=Prism.languages.xml,Prism.languages.rss=Prism.languages.xml; +Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/}; +Prism.languages.c=Prism.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),Prism.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),Prism.languages.insertBefore("c","string",{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},Prism.languages.c.string],char:Prism.languages.c.char,comment:Prism.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:"function"}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:Prism.languages.c}}}}),Prism.languages.insertBefore("c","function",{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete Prism.languages.c.boolean; +!function(e){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,n="\\b(?!<keyword>)\\w+(?:\\s*\\.\\s*\\w+)*\\b".replace(/<keyword>/g,(function(){return t.source}));e.languages.cpp=e.languages.extend("c",{"class-name":[{pattern:RegExp("(\\b(?:class|concept|enum|struct|typename)\\s+)(?!<keyword>)\\w+".replace(/<keyword>/g,(function(){return t.source}))),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),e.languages.insertBefore("cpp","string",{module:{pattern:RegExp('(\\b(?:import|module)\\s+)(?:"(?:\\\\(?:\r\n|[^])|[^"\\\\\r\n])*"|<[^<>\r\n]*>|'+"<mod-name>(?:\\s*:\\s*<mod-name>)?|:\\s*<mod-name>".replace(/<mod-name>/g,(function(){return n}))+")"),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),e.languages.insertBefore("cpp","keyword",{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:e.languages.cpp}}}}),e.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),e.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:e.languages.extend("cpp",{})}}),e.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},e.languages.cpp["base-clause"])}(Prism); +!function(e){for(var a="/\\*(?:[^*/]|\\*(?!/)|/(?!\\*)|<self>)*\\*/",t=0;t<2;t++)a=a.replace(/<self>/g,(function(){return a}));a=a.replace(/<self>/g,(function(){return"[^\\s\\S]"})),e.languages.rust={comment:[{pattern:RegExp("(^|[^\\\\])"+a),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:"attr-name",inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:"punctuation"},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:"symbol"},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:"punctuation"},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:"function"},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:"class-name"},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:"namespace"},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:"namespace",inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:"property"},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},e.languages.rust["closure-params"].inside.rest=e.languages.rust,e.languages.rust.attribute.inside.string=e.languages.rust.string}(Prism); diff --git a/projects/learning-rust/1.html b/projects/learning-rust/1.html new file mode 100644 index 0000000..840a968 --- /dev/null +++ b/projects/learning-rust/1.html @@ -0,0 +1,69 @@ +<!DOCTYPE html> +<html> +<head> + <title>1: Solar Systems</title> + + <link rel="stylesheet" href="/style.css"/> + <link rel="stylesheet" href="/prism/prism.css"/> + <script src="/prism/prism.js"></script> +</head> +<body> + <div class="window"> + <div class="window-title"><h2 style="padding: 0px; margin: 0px;">Learning Rust : Solar Systems</h2></div> + <i>How do I store non-owning references to collection members?</i> + <div class="window-content"> + <a class="link-button" href="/projects/learning-rust"><</a> + <p>I want to make a data-driven viewer for the solar system, as part of a game inspired by <a href="https://www.aurora2.pentarch.org/">Aurora 4x</a> but Rust is an entirely different beast from C.</p> + <p>I have prior experience writing systems like this, so I figured it would be as easy as:</p> + <pre><code class="language-rust"> +pub struct Orbital { + //Some optional non-owning reference to the parent orbital + mass : f64, + semi_major_axis : f64, + eccentricity : f64, + inclination : f64, + long_asc_node : f64, + argument_periapsis : f64, + mean_anomaly_epoch : f64 +} + </code></pre> + <p>The question then is: How do we store the reference to the parent orbital?</p> + <p>note: by parent orbital, I mean the orbital body that the given orbital body orbits.</p> + <p>In C, we would just store a pointer into the data of the owning container (i.e. a dynamic array).</p> + <p>I understand that the method above could cause problems with object lifetimes and dead references, but in this case we are assuming a static lifetime with a fixed-width container.</p> + <p>So my first instinct is to look in the Rust docs for a non-owning reference type.</p> + <p>I wasted about a day researching Rc's and RefCell's when I had a revelation; what I wanted was over-engineered. Instead of storing a reference to the parent orbital, I could just store an index into the system's orbital container. All I need to do to make this work is pass a borrowed ref to the system object to the orbital's update function.</p> + <p>But not every part of the update function needs the parent orbital's position, so I can split the update into two parts:</p> + <p>1: Update the orbital elements relative to the parent object</p> + <p>2: Use the parent orbital's position to transform the relative coordinates into absolute coordinates</p> + <p>So here's what I came up with.</p> + <pre><code class="language-rust"> +pub struct Orbital { + parent_index : usize, + //Temporary state variables for later update. + rel_pos : (f64, f64, f64) + //Orbital parameters + mass : f64, + semi_major_axis : f64, + eccentricity : f64, + inclination : f64, + long_asc_node : f64, + argument_periapsis : f64, + mean_anomaly_epoch : f64 +} +//... +impl Orbital { +//... + pub fn update_rel(&mut self) -> Orbital { + //... + } + + pub fn update(&self, &system : System) -> (f64, f64, f64) { + //... + } +} + </code></pre> + </div> + </div> +</body> +</html> diff --git a/projects/learning-rust/index.html b/projects/learning-rust/index.html new file mode 100644 index 0000000..5e0e9ba --- /dev/null +++ b/projects/learning-rust/index.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html> +<head> + <title>Learning Rust</title> + + <link rel="stylesheet" href="/style.css"> +</head> +<body> + <div class="window"> + <div class="window-title"><h2 style="padding: 0px; margin: 0px;">Learning Rust</h2></div> + <div class="window-content"> + <p>I am a long-time proponent of C. I have been using it for most of my life, and change is scary.</p> + <p>However, I also believe in broadening my skillset and learning new things.</p> + <p>This defines my dilemma. I want to learn something new, but I want to keep using C.</p> + <p>And then the US government decree'd that us C plebs should move on to rust</p> + <p>So without further adieu, as my first foray into "blogging", welcome to my attempt to document my journey into the Rust ecosystem</p> + </div> + </div> + <div class="window"> + <div class="window-title"></div> + <div class="window-content"> + <a class="link-button" href="1.html">1: Solar Systems</a> + <p style="display: inline-block"> : How do I store non-owning references to other objects?</p> + </div> + </div> +</body> +</html> diff --git a/vex/index.html b/vex/index.html deleted file mode 100644 index bb9a205..0000000 --- a/vex/index.html +++ /dev/null @@ -1,33 +0,0 @@ -<!DOCTYPE html> -<html> -<head> - <title>Vex (Multi-Dimension Vectors)</title> - - <link rel="stylesheet" href="/style.css"> -</head> -<body> - <div class="page-body-border"><div class="page-body"> - <h1 class="page-body-top">Multi-Dimension Vectors</h1> - <div class="page-body-content"> - <table class="page-body-buttons" style="width: 20%; margin: 0px;"> - <tr><td><div class="link-button-border"><a class="link-button" href="/">Home</a></div></td></tr> - <tr><td><div class="link-button-border"><a class="link-button" href="https://git.jonsantmyer.com/vex/">Git repository</a></div></td></tr> - <tr><td><div class="link-button-border"><a class="link-button" href="https://git.jonsantmyer.com/vex/plain/vex.hpp">Download (vex.hpp)</a></div></td></tr> - </table> - <h3>Purpose</h3> - <p> - vex was designed to be a single header drop in for handling object positions. Therefore, the logic and structures are contained in a single C++ header file. - </p> - <h3>Design</h3> - <p> - vectors of any dimension can be created by creating a class 'vec_dimd<T,D>' where T is a floating point or integral type, and D is an unsigned number greater than 1. - </p><p> - There are two pre-defined vector types, vec2 and vec3, which can be defined using the same type restrictions stated above. - </p> - </div> - <p class="text-inset"> - LICENSE: MIT (c) 2022 Jon Santmyer (jon@jonsantmyer.com) - </p> - </div> -</body> -</html> |