diff --git a/Gemfile b/Gemfile index d3d8457..7e517b0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,9 @@ source 'https://rubygems.org' -gem 'github-pages', '~> 192' +# to pull in latest versions: +# $ bundle update -gem 'bundler', '~> 1.16' +gem 'programming-pages', '~> 0.5' + +gem 'bundler', '~> 2.0' gem 'rake', '~> 12.0' diff --git a/Gemfile.lock b/Gemfile.lock index 7b085d6..294a83f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GEM remote: https://rubygems.org/ specs: - activesupport (4.2.10) + activesupport (4.2.11.1) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.5.2) + addressable (2.6.0) public_suffix (>= 2.0.2, < 4.0) coffee-script (2.4.1) coffee-script-source @@ -15,38 +15,38 @@ GEM colorator (1.1.0) commonmarker (0.17.13) ruby-enum (~> 0.5) - concurrent-ruby (1.1.3) + concurrent-ruby (1.1.5) dnsruby (1.61.2) addressable (~> 2.5) em-websocket (0.5.1) eventmachine (>= 0.12.9) http_parser.rb (~> 0.6.0) - ethon (0.11.0) + ethon (0.12.0) ffi (>= 1.3.0) eventmachine (1.2.7) execjs (2.7.0) faraday (0.15.4) multipart-post (>= 1.2, < 3) - ffi (1.9.25) + ffi (1.11.1) forwardable-extended (2.6.0) - gemoji (3.0.0) - github-pages (192) - activesupport (= 4.2.10) - github-pages-health-check (= 1.8.1) - jekyll (= 3.7.4) + gemoji (3.0.1) + github-pages (198) + activesupport (= 4.2.11.1) + github-pages-health-check (= 1.16.1) + jekyll (= 3.8.5) jekyll-avatar (= 0.6.0) jekyll-coffeescript (= 1.1.1) jekyll-commonmark-ghpages (= 0.1.5) jekyll-default-layout (= 0.1.4) - jekyll-feed (= 0.10.0) + jekyll-feed (= 0.11.0) jekyll-gist (= 1.5.0) - jekyll-github-metadata (= 2.9.4) + jekyll-github-metadata (= 2.12.1) jekyll-mentions (= 1.4.1) jekyll-optional-front-matter (= 0.3.0) jekyll-paginate (= 1.1.0) jekyll-readme-index (= 0.2.0) jekyll-redirect-from (= 0.14.0) - jekyll-relative-links (= 0.5.3) + jekyll-relative-links (= 0.6.0) jekyll-remote-theme (= 0.3.1) jekyll-sass-converter (= 1.5.2) jekyll-seo-tag (= 2.5.0) @@ -66,28 +66,28 @@ GEM jekyll-theme-tactile (= 0.1.1) jekyll-theme-time-machine (= 0.1.1) jekyll-titles-from-headings (= 0.5.1) - jemoji (= 0.10.1) + jemoji (= 0.10.2) kramdown (= 1.17.0) liquid (= 4.0.0) listen (= 3.1.5) mercenary (~> 0.3) minima (= 2.5.0) - nokogiri (>= 1.8.2, < 2.0) + nokogiri (>= 1.8.5, < 2.0) rouge (= 2.2.1) terminal-table (~> 1.4) - github-pages-health-check (1.8.1) + github-pages-health-check (1.16.1) addressable (~> 2.3) dnsruby (~> 1.60) octokit (~> 4.0) - public_suffix (~> 2.0) + public_suffix (~> 3.0) typhoeus (~> 1.3) - html-pipeline (2.9.1) + html-pipeline (2.11.0) activesupport (>= 2) nokogiri (>= 1.4) http_parser.rb (0.6.0) i18n (0.9.5) concurrent-ruby (~> 1.0) - jekyll (3.7.4) + jekyll (3.8.5) addressable (~> 2.4) colorator (~> 1.0) em-websocket (~> 0.5) @@ -105,21 +105,21 @@ GEM jekyll-coffeescript (1.1.1) coffee-script (~> 2.2) coffee-script-source (~> 1.11.1) - jekyll-commonmark (1.2.0) + jekyll-commonmark (1.3.1) commonmarker (~> 0.14) - jekyll (>= 3.0, < 4.0) + jekyll (>= 3.7, < 5.0) jekyll-commonmark-ghpages (0.1.5) commonmarker (~> 0.17.6) jekyll-commonmark (~> 1) rouge (~> 2) jekyll-default-layout (0.1.4) jekyll (~> 3.0) - jekyll-feed (0.10.0) + jekyll-feed (0.11.0) jekyll (~> 3.3) jekyll-gist (1.5.0) octokit (~> 4.2) - jekyll-github-metadata (2.9.4) - jekyll (~> 3.1) + jekyll-github-metadata (2.12.1) + jekyll (~> 3.4) octokit (~> 4.0, != 4.4.0) jekyll-mentions (1.4.1) html-pipeline (~> 2.3) @@ -131,7 +131,7 @@ GEM jekyll (~> 3.0) jekyll-redirect-from (0.14.0) jekyll (~> 3.3) - jekyll-relative-links (0.5.3) + jekyll-relative-links (0.6.0) jekyll (~> 3.3) jekyll-remote-theme (0.3.1) jekyll (~> 3.5) @@ -185,9 +185,9 @@ GEM jekyll-seo-tag (~> 2.0) jekyll-titles-from-headings (0.5.1) jekyll (~> 3.3) - jekyll-watch (2.1.2) + jekyll-watch (2.2.1) listen (~> 3.0) - jemoji (0.10.1) + jemoji (0.10.2) gemoji (~> 3.0) html-pipeline (~> 2.2) jekyll (~> 3.0) @@ -198,38 +198,40 @@ GEM rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) mercenary (0.3.6) - mini_portile2 (2.3.0) + mini_portile2 (2.4.0) minima (2.5.0) jekyll (~> 3.5) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) minitest (5.11.3) - multipart-post (2.0.0) - nokogiri (1.8.5) - mini_portile2 (~> 2.3.0) - octokit (4.13.0) + multipart-post (2.1.1) + nokogiri (1.10.3) + mini_portile2 (~> 2.4.0) + octokit (4.14.0) sawyer (~> 0.8.0, >= 0.5.3) pathutil (0.16.2) forwardable-extended (~> 2.6) - public_suffix (2.0.5) - rake (12.3.1) + programming-pages (0.5.20) + github-pages (= 198) + public_suffix (3.1.0) + rake (12.3.2) rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) + rb-inotify (0.10.0) + ffi (~> 1.0) rouge (2.2.1) ruby-enum (0.7.2) i18n ruby_dep (1.5.0) - rubyzip (1.2.2) - safe_yaml (1.0.4) - sass (3.7.2) + rubyzip (1.2.3) + safe_yaml (1.0.5) + sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sawyer (0.8.1) - addressable (>= 2.3.5, < 2.6) - faraday (~> 0.8, < 1.0) + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) thread_safe (0.3.6) @@ -237,15 +239,15 @@ GEM ethon (>= 0.9.0) tzinfo (1.2.5) thread_safe (~> 0.1) - unicode-display_width (1.4.0) + unicode-display_width (1.6.0) PLATFORMS ruby DEPENDENCIES - bundler (~> 1.16) - github-pages (~> 192) + bundler (~> 2.0) + programming-pages (~> 0.5) rake (~> 12.0) BUNDLED WITH - 1.16.2 + 2.0.1 diff --git a/README.md b/README.md index 2f996a8..4e06998 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ > unofficial documentation of the jai programming language
> https://pixeldroid.github.io/jailang/ -Jai is a computer programming language being developed by Jonathan Blow and team at [Thekla, Inc.][thekla-web]. +Jai is a computer programming language being developed by Jonathan Blow and team at [Thekla, Inc.][thekla-web] This site attempts to form a searchable language reference out of the hours and hours of video information presented by Jonathan Blow on his youtube channel: [A Programming Language for Games]. diff --git a/Rakefile b/Rakefile index 6d81f59..586b7f8 100644 --- a/Rakefile +++ b/Rakefile @@ -18,7 +18,7 @@ def exec_with_echo(cmd) end def fail(message) - abort("✘ #{message}") + abort("‼ #{message}") end def try(cmd, failure_message) @@ -70,6 +70,14 @@ def update_project_version(config_file, new_value) write_yaml(config_file, config) end +def time_to_seconds(time) + counts = time.split(':') + fail('too many time components, expected 3 or fewer (h:m:s, m:s, or s)') unless counts.length <= 3 + + seconds = [1, 60, 3600].take(counts.length).reverse + accumulator = counts.map.with_index { |v,i| v.to_i * seconds[i] } + accumulator.reduce(:+) +end [ # no files to clean .. yet @@ -134,3 +142,11 @@ task :set_version, [:v] do |t, args| puts "[#{t.name}] task completed, #{PROJECT} updated to #{project_version}" end + +desc [ + "converts h:m:s or m:s to seconds for youtube time marks", +].join("\n") +task :time, [:t] do |t, args| + fail('please provide a time string as h:m:s') unless (args.t && args.t.length > 0) + puts "t=#{time_to_seconds(args.t)}" +end diff --git a/art/composition.svg b/art/composition.svg new file mode 100644 index 0000000..5cdc000 --- /dev/null +++ b/art/composition.svg @@ -0,0 +1,82 @@ + + + + + + + diff --git a/art/composition.xcf b/art/composition.xcf new file mode 100644 index 0000000..6d88a8a Binary files /dev/null and b/art/composition.xcf differ diff --git a/art/shapes.xcf b/art/shapes.xcf new file mode 100644 index 0000000..cc8987f Binary files /dev/null and b/art/shapes.xcf differ diff --git a/art/shapes_filled.svg b/art/shapes_filled.svg new file mode 100644 index 0000000..8161deb --- /dev/null +++ b/art/shapes_filled.svg @@ -0,0 +1,53 @@ + + + + + + + diff --git a/art/shapes_outline.svg b/art/shapes_outline.svg new file mode 100644 index 0000000..82f570b --- /dev/null +++ b/art/shapes_outline.svg @@ -0,0 +1,83 @@ + + + + + + + diff --git a/art/usage.svg b/art/usage.svg new file mode 100644 index 0000000..96f061c --- /dev/null +++ b/art/usage.svg @@ -0,0 +1,58 @@ + + + + + + + diff --git a/art/usage.xcf b/art/usage.xcf new file mode 100644 index 0000000..e25cab9 Binary files /dev/null and b/art/usage.xcf differ diff --git a/docs/_config.yml b/docs/_config.yml index 6d6b3d9..f1a2390 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -3,22 +3,22 @@ project: name: jailang owner: pixeldroid repo: https://github.com/pixeldroid/jailang - version: 2 + version: '3' collections: overview: output: true permalink: "/:collection/:path/" title: Overview tab-order: 1 - features: + reference: output: true permalink: "/:collection/:path/" - title: Features + title: Reference tab-order: 2 - stdlib: + modules: output: true permalink: "/:collection/:path/" - title: StdLib + title: Modules tab-order: 3 examples: output: true @@ -29,6 +29,7 @@ code_indent: " " highlighter: rouge include: - "#*.md" +- "_*.md" # built-in types, fields, and procedures start with underscore kramdown: footnote_backlink: '⮌' permalink: pretty @@ -37,4 +38,5 @@ sass: plugins: - jemoji - jekyll-remote-theme +#theme: programming-pages remote_theme: pixeldroid/programming-pages diff --git a/docs/_data/icons/custom.yml b/docs/_data/icons/custom.yml index 7ace405..46169ac 100644 --- a/docs/_data/icons/custom.yml +++ b/docs/_data/icons/custom.yml @@ -7,7 +7,6 @@ ## - path ## - # Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome # License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) # @@ -15,3 +14,34 @@ external-link: viewbox: '0 0 1792 1536' path: 'M1408 928v320q0 119-84.5 203.5T1120 1536H288q-119 0-203.5-84.5T0 1248V416q0-119 84.5-203.5T288 128h704q14 0 23 9t9 23v64q0 14-9 23t-23 9H288q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113V928q0-14 9-23t23-9h64q14 0 23 9t9 23zm384-864v512q0 26-19 45t-45 19-45-19l-176-176-652 652q-10 10-23 10t-23-10L695 983q-10-10-10-23t10-23l652-652-176-176q-19-19-19-45t19-45 45-19h512q26 0 45 19t19 45z' + +# Glyphicon Halflings in Bootstrap by Jan Kovařík - http://getbootstrap.com/components/#glyphicons +# License - https://github.com/twbs/bootstrap/blob/master/LICENSE (MIT) +# http://glyphicons.com/license/ +# +# SVG processing from svg-icon - https://leungwensen.github.io/svg-icon/#bootstrap +chevron-left: + viewbox: '0 0 749 1102' + path: 'M749 198L397 551l352 353-197 198L0 550 552 0z' + +# Octicons by GitHub - https://octicons.github.com/ +# License - https://github.com/primer/octicons/blob/master/LICENSE (MIT) +# +# SVG processing from svg-icon - https://leungwensen.github.io/svg-icon/#oct +package: + viewbox: '0 0 15 13' + path: 'M0 2.7v7.5c0 .5.3.9.8 1l6.5 1.7h.5l6.5-1.7c.4-.1.7-.5.7-1V2.7a1 1 0 0 0-.8-1L7.8 0a1.4 1.4 0 0 0-.5 0L.8 1.8a1 1 0 0 0-.8 1zm7 9.1l-6-1.6V3.5L7 5v6.7zM1 2.5l2.5-.7L10 3.5l-2.5.7L1 2.5zm13 7.7l-6 1.6V5.1l2-.6V7l2-.6V4l2-.5v6.7zM12 3L5.5 1.3l2-.6L14 2.5 12 3z' + +# icons by pixeldroid +# License - http://creativecommons.org/licenses/by/4.0/ (CC BY 4.0) +# +# SVG processing from svgomg - https://jakearchibald.github.io/svgomg/ +composition: + viewbox: '0 0 680 980' + path: 'M112 300v441l1 10a182.6 182.6 0 0 0 37.1 95c10.7 14.2 20.7 25 35.9 34.6a168.5 168.5 0 0 0 80 24.5l12 .9h163c2.3 0 5.7-.2 7.8 1 2.8 1.7 6.7 11.6 8.5 15 4.3 8 10.6 17.4 16.8 24 20 21.5 49.5 33.6 78.9 34 19.6.2 39-1.6 57-10.3 21.8-10.5 41-26.7 53.5-47.7A121.8 121.8 0 0 0 622 756.5c-22-13.2-42.7-16.8-68-16.5-28.7.3-58.9 11-79 32a121.8 121.8 0 0 0-18 25c-7.5 13.2-4.4 15-16 15H306c-24.3 0-51.7 1.5-72-14.5-17.8-14-25.7-36.4-26-58.5V540a189 189 0 0 0 72 16h161c2.3 0 5.7-.2 7.8 1 2.8 1.7 6.7 11.6 8.5 15 4.3 8 10.6 17.4 16.8 24 20 21.5 49.5 33.6 78.9 34 19.6.2 39-1.6 57-10.3 21.8-10.5 41-26.7 53.5-47.7A121.8 121.8 0 0 0 622 406.4c-22-13-42.7-16.7-68-16.4-28.7.3-58.9 11-79 32a121.8 121.8 0 0 0-18 25c-7.5 13.2-4.4 15-16 15H283c-8.8 0-18.5-1.6-27-3.9a65.1 65.1 0 0 1-18-7.8C202 427 208 381 208 344v-33c0-2.3-.2-5.8 1-7.7 1.8-2.9 12.4-6 16-7.6a158.2 158.2 0 0 0 38-24c30.8-26.8 52.5-69.5 53-110.7.4-33.5-6.9-62.7-25.3-91a154.8 154.8 0 0 0-251.8-8A156 156 0 0 0 8 161l1 10a153 153 0 0 0 65 110.7c9.3 6.3 27 16.6 38 18.3zm440 140.3a69.4 69.4 0 0 1 73.3 94.7 74.2 74.2 0 0 1-36.3 37 72.3 72.3 0 0 1-92.6-33 73 73 0 0 1-2-55 71.5 71.5 0 0 1 57.6-43.7zm0 350a69.4 69.4 0 0 1 73.3 94.7 74.2 74.2 0 0 1-36.3 37 72.3 72.3 0 0 1-92.6-33 73 73 0 0 1-2-55 71.5 71.5 0 0 1 57.6-43.7z' +datatype: # aka shapes (filled) + viewbox: '0 0 1020 1100' + path: 'M772 9.4l-17 1.9c-15 2-33 6.8-47 12.1A225.3 225.3 0 0 0 564 219c-.2 17.2-.4 34 2.4 51A226.3 226.3 0 0 0 640 402.7a225.4 225.4 0 0 0 77 44c18.4 6 33.9 8.6 53 10.5l9 .8c38.6.4 77.5-6.6 112-24.8A224.5 224.5 0 0 0 1007.8 281c2.5-11.7 3.5-23.1 4.3-35v-25c-2-30.2-7.7-55.3-20.4-83A224.3 224.3 0 0 0 832 13.2a231.3 231.3 0 0 0-60-3.8zM47 125.1c-3.7.9-7.5 1.2-11 2.5-17 6-26.8 20.7-27 38.4v566c0 25.3 16.7 42 42 42h293c6 0 8.1-.1 14-2a38 38 0 0 0 27-36v-18-553c0-26-19.5-39.7-44-39.9H47zm529 436.3c-5.2 1-9.2 2-14 4.4-17.6 8.8-24.4 26.5-24 45.2l4.2 408a43.3 43.3 0 0 0 41.8 36c16 .3 27.8-8 41-16l320-188.1c17.3-10 31.5-18 34.3-39.9.1-3 .5-4.9 0-8-.1-4.2-1-9-2.4-13-5.9-16.3-17-21.5-30.9-29.4L615 572.8c-13.5-7.6-22.8-13.4-39-11.4z' +usage: + viewbox: '0 0 1200 1200' + path: 'M121.4 350.1v164.2c0 78 63.4 141.4 141.4 141.4H551v194.6a154.6 154.6 0 0 0-105.6 146.5c0 85 69.2 154.3 154.4 154.3 85 0 154.3-69.2 154.3-154.3 0-71.6-49-132-115.3-149.4V655.7H927c78 0 141.4-63.5 141.4-141.4V353a154.6 154.6 0 0 0 115.3-149.3c0-85.1-69.2-154.4-154.3-154.4A154.5 154.5 0 0 0 875 203.7c0 68 44.4 126 105.7 146.4v164.2c0 29.5-24.1 53.6-53.7 53.6H638.8V353A154.6 154.6 0 0 0 754 203.7c0-85.1-69.2-154.4-154.4-154.4a154.5 154.5 0 0 0-154.3 154.4c0 68 44.3 126 105.6 146.4V568H262.8c-29.6 0-53.7-24-53.7-53.6V353a154.6 154.6 0 0 0 115.4-149.3c0-85.1-69.3-154.4-154.4-154.4A154.5 154.5 0 0 0 15.8 203.7c0 68 44.3 126 105.6 146.4zm908-213a66.7 66.7 0 1 1-.2 133.4 66.7 66.7 0 0 1 .2-133.4zm-429.7 0a66.7 66.7 0 1 1-.1 133.3 66.7 66.7 0 0 1 .1-133.3zm-429.6 0a66.7 66.7 0 1 1-.1 133.3 66.7 66.7 0 0 1 .1-133.3zm572 1071.3' \ No newline at end of file diff --git a/docs/_data/icons/theme.yml b/docs/_data/icons/theme.yml index 79e0ca6..7828a10 100644 --- a/docs/_data/icons/theme.yml +++ b/docs/_data/icons/theme.yml @@ -1,11 +1,12 @@ ## ## SVG icon data file for the programming pages theme ## -## retrieve via liquid: {% site.data.icons_template[] %} ## each icon has the following properties: ## - viewbox ## - path ## +## to embed via the icon macro: {% include icon.liquid id='' %} +## to retrieve this data directly via liquid: {% site.data.icons.theme[] %} # Glyphicon Halflings in Bootstrap by Jan Kovařík - http://getbootstrap.com/components/#glyphicons @@ -52,7 +53,9 @@ interface: # fa: neuter magnifier: # fa: search viewbox: '0 0 1664 1664' path: 'M1152 704q0-185-131.5-316.5T704 256 387.5 387.5 256 704t131.5 316.5T704 1152t316.5-131.5T1152 704zm512 832q0 52-38 90t-90 38q-54 0-90-38l-343-342q-179 124-399 124-143 0-273.5-55.5t-225-150-150-225T0 704t55.5-273.5 150-225 225-150T704 0t273.5 55.5 225 150 150 225T1408 704q0 220-124 399l343 343q37 37 37 90z' - +plus-square-outline: # fa plus-square-o + viewbox: '0 0 1408 1408' + path: 'M1152 672v64q0 14-9 23t-23 9H768v352q0 14-9 23t-23 9h-64q-14 0-23-9t-9-23V768H288q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h352V288q0-14 9-23t23-9h64q14 0 23 9t9 23v352h352q14 0 23 9t9 23zm128 448V288q0-66-47-113t-113-47H288q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5T1120 1408H288q-119 0-203.5-84.5T0 1120V288Q0 169 84.5 84.5T288 0h832q119 0 203.5 84.5T1408 288z' # Entypo pictograms by Daniel Bruce — www.entypo.com # License - http://creativecommons.org/licenses/by-sa/4.0/ (CC BY-SA 4.0) diff --git a/docs/_data/videos.yaml b/docs/_data/videos.yaml index 9a908f0..ac1acf7 100644 --- a/docs/_data/videos.yaml +++ b/docs/_data/videos.yaml @@ -34,6 +34,11 @@ demo_20150121: “Data-Oriented Demo: SOA, composition.” _YouTube_, uploaded by Jonathan Blow, Jan 21, 2015 url: https://youtu.be/ZHqFrNyLlpA +demo_20150211: + mla: |- + “Demo: Run-Time (and Compile-Time) Type Information” _YouTube_, uploaded by Jonathan Blow, Feb 11, 2015 + url: https://youtu.be/JoNkttD_MUs + reboot_2017: mla: |- “Reboot Develop 2017 - Jonathan Blow, Thekla Inc. / Making Game Programming Less Terrible.” _YouTube_, uploaded by Reboot Develop, May 22, 2017 diff --git a/docs/_includes/code/field_by_name.jai b/docs/_includes/code/field_by_name.jai new file mode 100644 index 0000000..777b5fb --- /dev/null +++ b/docs/_includes/code/field_by_name.jai @@ -0,0 +1,40 @@ +/** from: https://youtu.be/JoNkttD_MUs?t=2349 */ + +field_by_name :: () { + + Vector3 :: struct { + x, y, z: float; + } + + get_field :: (any : Any, name : string) -> ^u8 { + if any.type.type != Type_Info_Tag.STRUCT { + printf("Error: argument is not a struct.\n"); + return; + } + + info_struct := cast(any.type, ^Type_Info_Struct); + + for info_struct.members { + if strings_match(it.name, cast(name, ^u8)) { + base := cast(any.value_pointer, ^u8); + return base + it.offset_in_bytes; + } + } + + printf("field '%s' not found.\n", name); + return null; + } + + printf("\n"); + + vec : Vector3; + vec.x = 1; + vec.y = 4; + vec.z = 9; + + coordinate_name := "y"; + + pointer_to_y := get_field(vec, coordinate_name); + + printf("The '%s' coordinate is %f\n", coordinate_name, *cast(pointer_to_y, ^float)); +} diff --git a/docs/_includes/code/has_note.jai b/docs/_includes/code/has_note.jai new file mode 100644 index 0000000..e121cb6 --- /dev/null +++ b/docs/_includes/code/has_note.jai @@ -0,0 +1,6 @@ +/** from: https://youtu.be/JoNkttD_MUs?t=3418 */ + +has_note :: (member : Type_Info_Struct_Member, note_name : string) -> bool { + for member.notes if strings_match(it, cast(note_name, ^u8)) return true; + return false; +} diff --git a/docs/_includes/code/nine_to_five.jai b/docs/_includes/code/nine_to_five.jai new file mode 100644 index 0000000..792ebee --- /dev/null +++ b/docs/_includes/code/nine_to_five.jai @@ -0,0 +1,8 @@ +/** from: https://youtu.be/JoNkttD_MUs?t=3248 */ + +nine_to_five :: (s : ^u8) { + while *s { + if *s == '9 then *s = '5; + s += 1; + } +} \ No newline at end of file diff --git a/docs/_includes/code/print_all_types.jai b/docs/_includes/code/print_all_types.jai new file mode 100644 index 0000000..184dc94 --- /dev/null +++ b/docs/_includes/code/print_all_types.jai @@ -0,0 +1,118 @@ +/** from: https://youtu.be/JoNkttD_MUs?t=399 */ + +print_all_types :: () { + printf("The type table has %d entries:\n", _type_table.count); + for _type_table { + printf("%3d: ", it_index); + print_type(it, true); + printf("\n"); + } +} + +print_type :: (info : ^Type_Info, is_toplevel : bool) { + if !info then { + printf("Input type must not be null.\n"); + return; + } + + using Type_Info_Tag.members; + + if info.type == INTEGER { + info_integer := cast(info, ^Type_Info_Integer); + if info_integer.signed then { + printf("s%d", info_integer.size_in_bits); + } else { + printf("u%d", info_integer.size_in_bits); + } + return; + } + + if info.type == FLOAT { + info_float := cast(info, ^Type_Info_Float); + printf("float%d", info_float.size_in_bits); + return; + } + + if info.type == BOOL { + printf("bool"); + return; + } + + if info.type == STRING { + printf("string"); + return; + } + + if info.type == POINTER { + info_pointer := cast(info, ^Type_Info_Pointer); + printf("^"); + print_type(info_pointer.pointer_to, false); + return; + } + + if info.type == PROCEDURE { + info_procedure := cast(info, ^Type_Info_Procedure); + printf("("); + for info_procedure.argument_types { + print_type(it, false); + if it_index != info_procedure.argument_types.count-1 then printf(", "); + } + printf(") -> "); + print_type(info_procedure.pointer_to, false); + return; + } + + if info.type == VOID { + printf("void"); + return; + } + + if info.type == STRUCT { + info_struct := cast(info, ^Type_Info_Struct); + if info_struct.name && !is_toplevel then { + printf("%s", info_struct.name); + } else { + if info_struct.name then printf("%s :: ", info_struct.name); + printf("struct { "); + for info_struct.members { + printf("%s: ", it.name); + print_type(it.type, false); + printf(" offset %d", it.offset_in_bytes); + printf("; "); + } + } + return; + } + + if info.type == ARRAY { + info_array := cast(info, ^Type_Info_Array); + if info_array.array_type == Type_Info_Array.DYNAMIC { + printf("[..] "); + } else if info_array.array_type == Type_Info_Array.FIXED { + printf("[%d] ", info_array.array_count); + } else { + printf("[] "); + } + if info_array.soa_packing != -1 then printf("SOA "); + print_type(info_array.element_type, false); + return; + } + + if info.type == NULL { + printf("null"); + return; + } + + if info.type == ANY { + printf("Any"); + return; + } + + if info.type == ENUM { + info_enum := cast(info, ^Type_Info_Enum); + printf("enum"); // incomplete + return; + } + + printf("??? (%d)", info.type); +} diff --git a/docs/_includes/footnotes.liquid b/docs/_includes/footnotes.liquid index 8f81e22..7be00a6 100644 --- a/docs/_includes/footnotes.liquid +++ b/docs/_includes/footnotes.liquid @@ -2,6 +2,8 @@ Render helper for footnotes parameters: + no_hr - when 'true', prevents addition of horizontal rule + reflist_only - when 'true', creates an unordered list of reference paragraphs (no footnotes) references - list of objects with the following properties: label - footnote id, e.g. [^