generated from Over-Run/project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Over-Run/rewrite
Rewrite
- Loading branch information
Showing
25 changed files
with
2,052 additions
and
623 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2023 Overrun Organization | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
|
||
package overrun.marshal; | ||
|
||
import java.lang.foreign.Arena; | ||
import java.lang.foreign.SymbolLookup; | ||
|
||
/** | ||
* A library loader. | ||
* | ||
* @author squid233 | ||
* @see NativeApi | ||
* @since 0.1.0 | ||
*/ | ||
public interface LibraryLoader { | ||
/** | ||
* Creates a library lookup with the given name. | ||
* | ||
* @param name the name of the native library | ||
* @return the symbol lookup of the library | ||
*/ | ||
static SymbolLookup loadLibrary(String name) { | ||
return SymbolLookup.libraryLookup(name, Arena.global()); | ||
} | ||
|
||
/** | ||
* Loads a library based on the basename and the operating system. | ||
* | ||
* @param basename the basename of the native library | ||
* @return the symbol lookup of the library | ||
*/ | ||
SymbolLookup load(String basename); | ||
|
||
/** | ||
* The default library loader. | ||
* | ||
* @author squid233 | ||
* @since 0.1.0 | ||
*/ | ||
final class Default implements LibraryLoader { | ||
/** | ||
* Creates the default library loader. | ||
*/ | ||
public Default() { | ||
} | ||
|
||
@Override | ||
public SymbolLookup load(String basename) { | ||
return SymbolLookup.libraryLookup(basename, Arena.global()); | ||
} | ||
} | ||
} |
Oops, something went wrong.