diff --git a/fig/sem-to-c-api/mpoquet.tmTheme b/fig/sem-to-c-api/mpoquet.tmTheme new file mode 100644 index 0000000000000000000000000000000000000000..9b3a803c3c6d56d167bb4e89c0a2239cc8fbf06a --- /dev/null +++ b/fig/sem-to-c-api/mpoquet.tmTheme @@ -0,0 +1,374 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>author</key> + <string>Ankur Gupta</string> + <key>name</key> + <string>GitHub Clean White</string> + <key>settings</key> + <array> + <dict> + <key>settings</key> + <dict> + <key>background</key> + <string>#FFFFFF</string> + <key>caret</key> + <string>#000000</string> + <key>foreground</key> + <string>#000000</string> + <key>invisibles</key> + <string>#B3B3B3F4</string> + <key>lineHighlight</key> + <string>#0000001A</string> + <key>selection</key> + <string>#BAD6FD</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>String</string> + <key>scope</key> + <string>string</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#C41A16</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Number</string> + <key>scope</key> + <string>constant.numeric</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#0086B3</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Keyword</string> + <key>scope</key> + <string>keyword</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#A71D5D</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Operator</string> + <key>scope</key> + <string>keyword.operator</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#000000</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Built-in constant</string> + <key>scope</key> + <string>constant.language</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#0086B3</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Exception</string> + <key>scope</key> + <string>support.class.exception</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#990000</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Function name</string> + <key>scope</key> + <string>entity.name.function</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#000000</string> + <!-- <key>fontStyle</key> + <string>italic</string> --> + </dict> + </dict> + <dict> + <key>name</key> + <string>Type name</string> + <key>scope</key> + <string>entity.name.type</string> + <key>settings</key> + <dict> + <key>fontStyle</key> + <string>bold underline</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Arguments</string> + <key>scope</key> + <string>variable.parameter</string> + <key>settings</key> + <dict> + <key>fontStyle</key> + <string>italic</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Comment</string> + <key>scope</key> + <string>comment</string> + <key>settings</key> + <dict> + <!-- <key>fontStyle</key> + <string>italic</string> --> + <key>foreground</key> + <string>#707070</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Invalid</string> + <key>scope</key> + <string>invalid</string> + <key>settings</key> + <dict> + <!-- <key>background</key> + <string>#E71A114D</string> --> + <key>foreground</key> + <string>#FF0000</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Trailing whitespace</string> + <key>scope</key> + <string>invalid.deprecated.trailing-whitespace</string> + <key>settings</key> + <dict> + <key>background</key> + <string>#E71A1100</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Embedded source</string> + <key>scope</key> + <string>text source</string> + <key>settings</key> + <dict> + <key>background</key> + <string>#FAFAFAFC</string> + <key>foreground</key> + <string>#000000</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Tag</string> + <key>scope</key> + <string>meta.tag, declaration.tag</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#AA0D91</string> + </dict> + </dict> + <!-- <dict> + <key>name</key> + <string>Constant</string> + <key>scope</key> + <string>constant, support.constant</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#000000</string> + </dict> + </dict> --> + <dict> + <key>name</key> + <string>Support</string> + <key>scope</key> + <string>support</string> + <key>settings</key> + <dict> + <key>fontStyle</key> + <string>bold</string> + <key>foreground</key> + <string>#000000</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Storage</string> + <key>scope</key> + <string>storage</string> + <key>settings</key> + <dict> + <!-- <key>fontStyle</key> + <string>bold</string> --> + <key>foreground</key> + <string>#AA0D91</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Section name</string> + <key>scope</key> + <string>entity.name.section</string> + <key>settings</key> + <dict> + <key>fontStyle</key> + <string>bold underline</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>Frame title</string> + <key>scope</key> + <string>entity.name.function.frame</string> + <key>settings</key> + <dict> + <key>fontStyle</key> + <string>bold</string> + <key>foreground</key> + <string>#000000</string> + <!-- <string>#881280</string> --> + </dict> + </dict> + <dict> + <key>name</key> + <string>XML Declaration</string> + <key>scope</key> + <string>meta.tag.preprocessor.xml</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#333333</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>html attribute</string> + <key>scope</key> + <string>entity.other.attribute-name</string> + <key>settings</key> + <dict> + <key>fontStyle</key> + <string>italic</string> + <key>foreground</key> + <!-- <string>#3366CC</string> --> + <string>#0A8585</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>html tag punctuation</string> + <key>scope</key> + <string>entity.name.tag</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#121289</string> + <!-- <key>fontStyle</key> + <string>bold</string> --> + </dict> + </dict> + <!-- Adding stuff for diff. This works in ST3 --> + <dict> + <key>name</key> + <string>diff header from</string> + <key>scope</key> + <string>meta.diff.header.from-file</string> + <key>settings</key> + <dict> + <key>background</key> + <string>#FFDDDD</string> + <key>fontStyle</key> + <string></string> + <key>foreground</key> + <string>#000000</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>diff header to</string> + <key>scope</key> + <string>meta.diff.header.to-file</string> + <key>settings</key> + <dict> + <key>background</key> + <string>#DDFFDD</string> + <key>fontStyle</key> + <string></string> + <key>foreground</key> + <string>#000000</string> + </dict> + </dict> + <dict> + <key>name</key> + <string>diff inserted</string> + <key>scope</key> + <string>markup.inserted.diff</string> + <key>settings</key> + <dict> + <key>background</key> + <string>#DDFFDD</string> + <key>fontStyle</key> + <string></string> + </dict> + </dict> + <dict> + <key>name</key> + <string>diff deleted</string> + <key>scope</key> + <string>markup.deleted.diff</string> + <key>settings</key> + <dict> + <key>background</key> + <string>#FFDDDD</string> + <key>fontStyle</key> + <string></string> + <key>foreground</key> + <string>#000000</string> + </dict> + </dict> + <!-- BracketHighlighter colors --> + <dict> + <key>name</key> + <string>BH Color</string> + <key>scope</key> + <string>brackethighlighter.default</string> + <key>settings</key> + <dict> + <key>foreground</key> + <string>#FF992244</string> + <key>fontStyle</key> + <string>italic</string> + </dict> + </dict> + </array> + <key>uuid</key> + <string>26786979-843B-4FE2-BCB6-4FCEC6F8FB58</string> + <key>colorSpaceName</key> + <string>sRGB</string> + <key>semanticClass</key> + <string>theme.light.git_hub_clean_white</string> + <key>comment</key> + <string>v1.0 Feb 1, 2015 +Made to look as close to GitHub as possible.</string> +</dict> +</plist> diff --git a/fig/sem-to-c-api/sem-to-c-api.typ b/fig/sem-to-c-api/sem-to-c-api.typ new file mode 100644 index 0000000000000000000000000000000000000000..7cf698ef8d0abc5e4955d3df9247348a588e3419 --- /dev/null +++ b/fig/sem-to-c-api/sem-to-c-api.typ @@ -0,0 +1,74 @@ +#import "@preview/cetz:0.2.2" + +#let pagescale = 0.95 +#set page(width: 16cm * pagescale, height: 9cm * pagescale, margin: 5mm) +#set raw(theme: "mpoquet.tmTheme") + +#show math.equation: block.with(fill: white, inset: 1pt) +#let il = -4mm + +#cetz.canvas(length: 3cm, { + import cetz.draw: * + + let theox = 0mm + let implemx = 4.5cm + let mutexy = 0cm + let semy = -5cm + + let y = mutexy + let x = implemx + let x-border = 2mm + let rect-width = 9.25cm + let rect-height = 2.75cm + rect((x - x-border, y), (x + rect-width + x-border, y - rect-height), stroke: .1mm, fill: none) + content((x + rect-width / 2, y), anchor: "center", [ + #box(fill: luma(230), inset: (x: 2mm, y: 1.25mm), stroke: .2mm, [`mutex` API (C, POSIX threads)]) + ]) + let y = y + il/4 + content((x, y + il*1), anchor: "west", raw("#include <pthread.h>", lang: "c")) + content((x, y + il*2), anchor: "west", raw("int pthread_mutex_init(...);", lang: "c"), name: "pthread-mutex-init") + content((x, y + il*3), anchor: "west", raw("pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;", lang: "c"), name: "pthread-mutex-init-macro") + content((x, y + il*4), anchor: "west", raw("int pthread_mutex_destroy(...);", lang: "c")) + content((x, y + il*5), anchor: "west", raw("int pthread_mutex_lock(...);", lang: "c"), name: "pthread-mutex-lock") + content((x, y + il*6), anchor: "west", raw("int pthread_mutex_unlock(...);", lang: "c"), name: "pthread-mutex-unlock") + + let x = theox + let y = mutexy + //content((x, y), anchor: "west", [Sémaphore théorique]) + let y = y + il/4 + content((x, y + il*2), anchor: "west", [`init(1)`], name: "theo-init") + content((x, y + il*5), anchor: "west", [`P()`], name: "theo-p") + content((x, y + il*6), anchor: "west", [`V()`], name: "theo-v") + + line("theo-init.east", (4.475cm, y + il*2), mark: none, padding: 1cm, stroke: .3mm) + line((3cm, y + il*2), (3cm, y + il*3), (4.475cm, y + il*3), mark: none, padding: 1cm, stroke: .3mm) + line("theo-p.east", "pthread-mutex-lock.west", mark: none, padding: 1cm, stroke: .3mm) + line("theo-v.east", "pthread-mutex-unlock.west", mark: none, padding: 1cm, stroke: .3mm) + + let x = implemx + let y = semy + let rect-width = 9.25cm + let rect-height = 2.4cm + rect((x - x-border, y), (x + rect-width + x-border, y - rect-height), stroke: .1mm, fill: none) + content((x + rect-width / 2, y), anchor: "center", [ + #box(fill: luma(230), inset: (x: 2mm, y: 1.25mm), stroke: .2mm, [`sem` API (C, POSIX threads)]) + ]) + let y = y + il/4 + content((x, y + il*1), anchor: "west", raw("#include <semaphore.h>", lang: "c")) + content((x, y + il*2), anchor: "west", raw("int sem_init(..., unsigned int n);", lang: "c"), name: "pthread-sem-init") + content((x, y + il*3), anchor: "west", raw("int sem_destroy(...);", lang: "c")) + content((x, y + il*4), anchor: "west", raw("int sem_wait(...);", lang: "c"), name: "pthread-sem-wait") + content((x, y + il*5), anchor: "west", raw("int sem_post(...);", lang: "c"), name: "pthread-sem-post") + + let x = theox + let y = semy + //content((x, y), anchor: "west", [Sémaphore théorique]) + let y = y + il/4 + content((x, y + il*2), anchor: "west", [`init(n)`], name: "theo-init") + content((x, y + il*4), anchor: "west", [`P()`], name: "theo-p") + content((x, y + il*5), anchor: "west", [`V()`], name: "theo-v") + + line("theo-init.east", (4.475cm, y + il*2), mark: none, padding: 1cm, stroke: .3mm) + line("theo-p.east", "pthread-sem-wait.west", mark: none, padding: 1cm, stroke: .3mm) + line("theo-v.east", "pthread-sem-post.west", mark: none, padding: 1cm, stroke: .3mm) +})