This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Globals #139
Merged
Merged
Globals #139
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ee5a5f8
globals generated
TimWhiting 6dcd229
remove manual late initialization instead using the non-nullable late…
TimWhiting 7d41bd6
fix naming and globals test
TimWhiting 91651a9
add typedef dependencies of globals
TimWhiting ff8d605
just fixing some naming to make more sense
TimWhiting 3cf263e
updates with test, and exclude params
TimWhiting ab929f9
update readme to include globals
TimWhiting ef5b56f
address review comments
TimWhiting a50526a
a last log statement
TimWhiting 905ba09
address comments
TimWhiting File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file | ||
TimWhiting marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:ffigen/src/code_generator.dart'; | ||
import 'package:ffigen/src/header_parser/data.dart'; | ||
import 'package:logging/logging.dart'; | ||
|
||
import '../clang_bindings/clang_bindings.dart' as clang_types; | ||
import '../data.dart'; | ||
import '../utils.dart'; | ||
|
||
final _logger = Logger('ffigen.header_parser.var_parser'); | ||
|
||
/// Parses a global variable | ||
Global? parseVarDefinition(clang_types.CXCursor cursor) { | ||
final type = cursor.type().toCodeGenType(); | ||
if (type.broadType == BroadType.Unimplemented) { | ||
TimWhiting marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_logger | ||
.warning('Global Type not supported $type ${cursor.type().spelling()}'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add these logs instead. _logger.fine(
'---- Removed Global, reason: unsupported type: ${cursor.completeStringRepr()}');
_logger.warning(
"Skipped global variable '$globalName', type not supported."); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
return null; | ||
} | ||
final g = Global( | ||
originalName: cursor.spelling(), | ||
TimWhiting marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: config.globals.renameUsingConfig(cursor.spelling()), | ||
usr: cursor.usr(), | ||
type: cursor.type().toCodeGenType(), | ||
dartDoc: getCursorDocComment(cursor), | ||
); | ||
return g; | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think global variables are not constants, they can be changed.
If that's the case, we should instead add getters and setters for this.
So for an int global variable, we can do this -
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this works for all types except structs, which just don't have a setter, but fields for structs can be set from the ref that is obtained via the getter.