44 Commits

Author SHA1 Message Date
Jeroen van Rijn
ece213afca Render examples. 2025-10-10 12:24:28 +02:00
Jeroen van Rijn
7a9ea3ee6d Further overhaul of package line comments. 2025-10-09 23:05:29 +02:00
Jeroen van Rijn
153b0de420 Package lines for core:debug 2025-10-09 15:18:23 +02:00
gingerBill
bb4bc316a4 for in string16; Support string16 across core 2025-08-02 12:20:35 +01:00
Jeroen van Rijn
6d01aa9069 Appease -vet for haiku 2025-06-16 23:30:22 +02:00
Laytan Laats
189b4782fb dynlib: fix initialize_symbols when there is no field for the handle in the struct 2025-03-03 20:33:33 +01:00
Laytan Laats
80d09774b4 fix not using RTLD_LOCAL on darwin 2025-02-06 19:15:12 +01:00
Laytan Laats
1cece52359 dynlib: unload library before loading again & add LIBRARY_FILE_EXTENSION constant 2024-11-28 21:08:08 +01:00
Laytan
0b4a4212bb clean up dynlib and path/filepath with sys/posix 2024-10-28 19:21:16 +01:00
Karl Zylinski
19f0127e55 Moved all packages in core, base, vendor, tests and examples to use new #+ file tag syntax. 2024-09-14 18:27:49 +02:00
Laytan Laats
288312a812 core: improve package doc comments for the documentation generator 2024-09-03 19:59:04 +02:00
Jeroen van Rijn
8bee73b08e Remove implicit allocator usage in core:dynlib 2024-07-04 16:53:00 +02:00
Andreas T Jonsson
6298d4a36c Fixed some build tags in vendor libs 2024-05-13 10:00:19 +02:00
Jeroen van Rijn
436c5dc40c Merge pull request #3436 from karl-zylinski/fix-vet-unused-in-dynlib
Fix for dynlib:initialize_symbols not passing -vet-unused
2024-04-15 21:55:12 +02:00
Karl Zylinski
0729f2b4fb Fix for dynlib:initialize_symbols not passing -vet-unused 2024-04-15 21:26:30 +02:00
Maurizio M. Gavioli
a0cff82320 Fix the format of some doc.odin files of the core library which did not made into the documentation.
`c/frontend/tokenizer`:
   add proper "Example:" header to demo example code,
   removed empty lines.
`container/bit_array`:
   moved comment before package;
   aligned narrative lines to left margin;
   converted case lines into bulleted lines ("- ");
   converted individual examples to single-tab-indented preformatted text.
`dynlib`:
   removed "//+build ignore" line;
   added newline at EOF.
`image/netpmb`:
   converted indented lines of "Reading", "Wrting" and "Some syntax..." into bulleted lists;
   "Formats" indented lines kept as they are as the preformatted text seems relevant to keep the alignments;
   doubly indented lines kept as single-indented to keep them different (as the format does not allow for two-level bulleted lists);
   removed empy lines.
`os/os2`:	WIP, not modified
`sys/info`:
   removed "//+build ignore" line;
   converted tab-indented initial description into regular left-margin comment;
   moved uncommented sample code within the doc comment as an "Example:";
   moved simple- and double-tabbed separate comments with sample Windows and macOS outputs within the doc comment as bulleted headlines with preformatted output listings;
   removed now empty comments and blank lines after the package line.
`text/i18n`:
   removed "//+build ignore" line;
   moved the pacakge line at the end;
   de-indented the tab-indented introductory narrative;
   moved sample code comments into the doc comment as tab-indented code with a proper "Example:" heading;
   removed "```" MD attempts at code formatting.
`text/table`:
   unindented the comment lines of a descriptive kind;
   headlines of major subdivisions are marked as bold;
   kept code samples as tab-indented preformatted text (as there are several of them, the standard "Example:" and "Output:" headings cannot be used) removing the "```" MD attempts at code formatting;
   removed in-between blank lines.
2024-04-14 17:18:08 +02:00
gingerBill
1f0b24b735 Remove unneeded casts 2024-02-06 17:22:13 +00:00
gingerBill
a6878fcd91 Clean up code for initialize_symbols 2024-02-06 17:20:07 +00:00
gingerBill
3e7e779abf Replace core:* to base:* where appropriate 2024-01-28 22:18:51 +00:00
Jeroen van Rijn
e8102a40d0 Add hot reload support to dynlib.initialize_symbols 2024-01-19 18:43:02 +01:00
Laytan Laats
85b71708dd dynlib: add last_error procedure 2024-01-06 02:08:11 +01:00
Jeroen van Rijn
649b5fa528 Add bool return to dynlib.initialize_symbols. 2024-01-06 02:04:09 +01:00
Jeroen van Rijn
d6a89d667d Add dynlib.initialize_symbols (#3071)
```
package example

import "core:dynlib"
import "core:fmt"

Symbols :: struct {
	// `foo_` is prefixed, so we look for the symbol `foo_add`.
	add: proc "c" (int, int) -> int,
	// We use the tag here to override the symbol to look for, namely `bar_sub`.
	sub: proc "c" (int, int) -> int `dynlib:"bar_sub"`,

	// Exported global (if exporting an i32, the type must be ^i32 because the symbol is a pointer to the export.)
	// If it's not a pointer or procedure type, we'll skip the struct field.
	hellope: ^i32,

	// Handle to free library.
	// We can have more than one of these so we can match symbols for more than one DLL with one struct.
	_my_lib_handle: dynlib.Library,
}

main :: proc() {
	sym: Symbols

	// Load symbols from `lib.dll` into Symbols struct.
	// Each struct field is prefixed with `foo_` before lookup in the DLL's symbol table.
	// The library's Handle (to unload) will be stored in `sym._my_lib_handle`. This way you can load multiple DLLs in one struct.
	count := dynlib.initialize_symbols(&sym, "lib.dll", "foo_", "_my_lib_handle")
	defer dynlib.unload_library(sym._my_lib_handle)
	fmt.printf("%v symbols loaded from lib.dll (%p).\n", count, sym._my_lib_handle)

	if count > 0 {
		fmt.println("42 + 42 =", sym.add(42, 42))
		fmt.println("84 - 13 =", sym.sub(84, 13))
		fmt.println("hellope =", sym.hellope^)
	}
}
```
2024-01-06 01:31:27 +01:00
Rehkitzdev
e3b43b6e1c fixed dynlib wasm stub 2023-06-22 13:35:22 +02:00
Dragos Popescu
951511704d Responded to PR review. Made dynlib return false on js instead of panic 2023-03-20 21:57:51 +01:00
Dragos Popescu
adac039a2b Made most libraries panic on js targets instead of not compiling 2023-03-20 04:08:48 +01:00
gingerBill
553f338f6f Merge pull request #2360 from Lperlind/documentation/dynlib
Document core:dynlib
2023-03-02 12:07:32 +00:00
Lucas Perlind
bb72c804fb Document core:dynlib 2023-03-02 19:20:45 +11:00
gingerBill
986cba584e Add runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD where appropriate 2023-02-10 16:23:33 +00:00
gingerBill
d8e77cd738 Add #optional_ok to dynlib.symbol_address 2022-05-25 11:53:32 +01:00
gingerBill
95d4ce4aa3 Fix lib_unix.odin 2022-05-25 11:46:26 +01:00
gingerBill
acadbe050c Make core:dynlib use the private interface convention of other packages 2022-05-25 11:43:56 +01:00
Sébastien Marie
5676c9e7eb initial OpenBSD support 2022-02-25 08:49:25 +00:00
gingerBill
ca33cb990b Strip semicolons in core which were missing 2021-09-08 13:12:38 +01:00
gingerBill
251da264ed Remove unneeded semicolons from the core library 2021-08-31 22:21:13 +01:00
gingerBill
fe33a64b2e Remove #opaque usage in core library 2021-02-23 15:21:05 +00:00
gingerBill
fd453be831 Deprecate opaque in favour of #opaque in the core library 2020-12-04 18:49:39 +00:00
gingerBill
fc4fdd588e Remove usage of do in core library 2020-09-23 17:17:14 +01:00
Christian Seibold
577be4a8ae Get Odin compiling and produced exe's running on FreeBSD 2020-09-14 15:22:35 -05:00
gingerBill
6bd05ef5d7 Begin migration from sys/win32 to sys/windows 2020-06-26 19:11:34 +01:00
Scitoshi Nakayobro
d79ee7d530 Implement dynlib core library for unix/darwin; not 100% about the build tags 2019-12-30 19:09:59 -05:00
gingerBill
8ee7ee7120 Fix core library for the new procedure parameter addressing mode 2019-07-15 22:16:27 +01:00
gingerBill
a019059975 Fix -vet for demo.odin 2019-03-30 10:52:53 +00:00
gingerBill
9b4b20e8b1 package dynlib 2019-03-03 12:08:26 +00:00