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
test('timezones', () { | |
final pubspecFile = File('pubspec.yaml'); | |
final pubspecYaml = loadYaml(pubspecFile.readAsStringSync()) as YamlMap; | |
final config = Config.fromYaml(pubspecYaml['ffigen'] as YamlMap); | |
final output = parse(config).generate(); | |
expect(output, contains('class TimeZoneLibrary{')); | |
expect(output, contains('class NSString extends _ObjCWrapper {')); | |
expect(output, contains('static NSTimeZone? getLocalTimeZone(')); | |
); | |
} |
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
test('url_cache', () { | |
final pubspecFile = File('url_cache_config.yaml'); | |
final pubspecYaml = loadYaml(pubspecFile.readAsStringSync()) as YamlMap; | |
final config = Config.fromYaml(pubspecYaml); | |
final output = parse(config).generate(); | |
expect(output, contains('class URLCacheLibrary{')); | |
expect(output, contains('static NSURLCache?getSharedURLCache(')); | |
}); | |
} |
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
void logWarnings([Level level = Level.WARNING]) { | |
Logger.root.level = level; | |
Logger.root.onRecord.listen((record) { | |
print('${record.level.name.padRight(8)}: ${record.message}'); | |
}); | |
} |
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
const dylibPath='/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation'; | |
final lib = TimeZoneLibrary(DynamicLibrary.open(dylibPath)); | |
final timeZone = NSTimeZone.getLocalTimeZone(lib); | |
if (timeZone != null) { | |
print('Timezone name: ${timeZone.name}'); | |
print('Offset: ${timeZone.secondsFromGMT / 60 / 60} hours'); | |
} |
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
dev_dependencies: | |
ffigen: | |
name: TimeZoneLibrary | |
language: objc | |
output: "timezone_bindings.dart" | |
exclude-all-by-default: true | |
objc-interfaces: | |
include: | |
- "NSTimeZone" | |
headers: |
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
void main() { | |
const dylibPath = '/System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation'; | |
final lib = URLCacheLibrary(DynamicLibrary.open(dylibPath)); | |
final urlCache = NSURLCache.getSharedURLCache(lib); | |
if (urlCache != null) { | |
print('currentDiskUsage: ${urlCache.currentDiskUsage}'); | |
print('currentMemoryUsage: ${urlCache.currentMemoryUsage}'); | |
print('diskCapacity: ${urlCache.diskCapacity}'); | |
print('memoryCapacity: ${urlCache.memoryCapacity}'); | |
} |
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
objc-interfaces: | |
include: | |
# Includes a specific interface. | |
- 'NSURLCache' | |
# Includes all interfaces starting with "NS". | |
- 'NS.*' | |
exclude: | |
# Override the above NS.* inclusion, to exclude NSURL. | |
- 'NSURL' | |
rename: |
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
name: URLCacheLibrary | |
language: objc | |
output: "url_cache_bindings.dart" | |
exclude-all-by-default: true | |
objc-interfaces: | |
include: | |
- "NSURLCache" | |
headers: | |
entry-points: | |
- "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLCache.h" |
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
dart create ffi_2_18 | |
## ffi_2_18 is the name of the project which will be created |
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
brew install llvm |
NewerOlder