Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embedBinary: embed arbitrary string into a binary #794

Open
timotheecour opened this issue Jul 31, 2021 · 2 comments
Open

embedBinary: embed arbitrary string into a binary #794

timotheecour opened this issue Jul 31, 2021 · 2 comments

Comments

@timotheecour
Copy link
Owner

placehold, will add details later.

implementation and motivation

see codegendecl on a const - Nim forum

links

@juancarlospaco
Copy link
Collaborator

juancarlospaco commented Jul 31, 2021

Interesting idea, XPM embeds images in C as C https://en.wikipedia.org/wiki/X_PixMap#XPM

@timotheecour
Copy link
Owner Author

timotheecour commented Jul 31, 2021

how you pass that thru the review tho...

not sure if that comment applies to XPM or to embedBinary; for embedBinary the API should be clean:

something like this (similar to what i proposed in https://forum.nim-lang.org/t/8117#52130 but trying to turn it into an actual API):

# in std/backendutils:
type Blob* = object
  first*: ptr char
  n*: int

proc embedBinary*(a: static string): Blob = ...
proc toString*(a: Blob): string = ...

# in main.nim:
let blob = embedBinary("abc\0\tdef")
doAssert blob.toString == "abc\0\tdef"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants