fprime icon indicating copy to clipboard operation
fprime copied to clipboard

Update/type refactor

Open LeStarch opened this issue 3 years ago • 7 comments

Originating Project/Creator
Affected Component
Affected Architectures(s)
Related Issue(s)
Has Unit Tests (y/n)
Builds Without Errors (y/n)
Unit Tests Pass (y/n)
Documentation Included (y/n)


Change Description

This contains breaking changes

This implements the initial "logical types" design approved in PR #1571. These changes amount to:

  1. Improving StandardTypes.hpp to include the new platform type definitions
  2. Improving BasicTypes.hpp to include _MIN and _MAX definitions
  3. Reworking FpConfig.hpp to use typedef

This includes some "breaking changes".

  1. StandardTypes.hpp implementors must implement new types, or include DefaultTypes.hpp to get default implementations. See Fw/Types/Linux/StandardTypes.hpp for an example
  2. BasicTypes.hpp no longer includes the types defined in FpConfig.hpp. Users should switch to include FpConfig.hpp when needing project-defined types
  3. AssertArg has been renamed FwAssertArgType. Users must update.

This PR also includes some deprecated features:

  1. Use of NATIVE_INT_TYPE, NATIVE_UINT_TYPE and POINTER_CAST is no longer advised. Projects should update, at minumum, to use PlatformIntType, PlatformUIntType and PlatformPointerCastType respectively.
  2. Use of PlatformIntType, PlatformUIntType is discouraged outside of API calls returning int and unsigned int respectively. Other uses should be replaced with new "logical types". e.g. NATIVE_INT_TYPE in port calls should be replaced with FwIndexType.

Other restrictions:

  1. DefaultTypes.hpp should only ever be included in a StandardTypes.hpp header. All other users should be using FpConfig.hpp and trusting it to setup the types correctly.

Future Work

Define new "logical types" when identified. Replace uses of PRI[xud]NN for "logical types" with defined equivalent.

LeStarch avatar Aug 02 '22 21:08 LeStarch

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (2)

Ifwit Inttype

Previously acknowledged words that are now absent ABuffer apps argparse args arity aspx autocomplete autogenerated bw bytearray cfg checkbox chmod chr ci classmethod Concat config cpp cpy cspell css csv cxx datetime delattr deserialize DHTML django dockerfile dropdown elif endfor endif endswith etree ev exe fd fh filesystem filetypes fullstack func functools gainsboro getattr getcwd getpass gh globals gz hasattr hh hpp href htm html http hu hxx hyperlink hz img ini inl ino inttype ip isabs isdir isfile isinstance issubclass iu javascript jpg json len lifecycle lightgreen lightyellow listdir ljust localtime lstrip lte mailto makedirs middleware mkdir mlist mname mq MTIME multiline MVC Mypy namespace nargs nbsp Nh noreply onchange orangered overridable pdf perl php phtml png posix proj py pytest PYTHONPATH pyw quickstart rb readline regex rmdir rmtree rng rp rstrip rtf rx setattr shutil splitext splitlines startswith staticmethod strftime structs stylesheet svg sys td timezone tl tmp tmpl toc toolchain tooltip tt tz url urllib utc utils uuid vm vue vx whitelist wp writelines wx xhtml xls xlsx xml xmlns yml zsh zu
To accept :heavy_check_mark: these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the [email protected]:LeStarch/fprime.git repository on the update/type-refactor branch (:information_source: how do I use this?):

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
-H "Content-Type: application/json" \
"https://api.github.com/repos/nasa/fprime/issues/comments/1203253756" > "$comment_json"
comment_body=$(mktemp)
jq -r ".body // empty" "$comment_json" | tr -d "\\r" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")

patch_add=$(perl -e '$/=undef; $_=<>; if (m{Unrecognized words[^<]*</summary>\n*```\n*([^<]*)```\n*</details>$}m) { print "$1" } elsif (m{Unrecognized words[^<]*\n\n((?:\w.*\n)+)\n}m) { print "$1" };' < "$comment_body")

update_files
rm $comment_body
git add -u

If the flagged items are false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Aug 02 '22 21:08 github-actions[bot]

Do autocoders need to switch to FpConfig.hpp

LeStarch avatar Aug 02 '22 22:08 LeStarch

look-up int pointer t

LeStarch avatar Aug 02 '22 22:08 LeStarch

Rename StandardTypes.hpp -> PlatformTypes.hpp

LeStarch avatar Aug 02 '22 22:08 LeStarch

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

Inttype

Previously acknowledged words that are now absent ABuffer apps argparse args arity aspx autocomplete autogenerated bw bytearray cfg checkbox chmod chr ci classmethod Concat config cpp cpy cspell css csv cxx datetime delattr deserialize DHTML django dockerfile dropdown elif endfor endif endswith etree ev exe fd fh filesystem filetypes fullstack func functools gainsboro getattr getcwd getpass gh globals gz hasattr hh hpp href htm html http hu hxx hyperlink hz img ini inl ino inttype ip isabs isdir isfile isinstance issubclass iu javascript jpg json len lifecycle lightgreen lightyellow listdir ljust localtime lstrip lte mailto makedirs middleware mkdir mlist mname mq MTIME multiline MVC Mypy namespace nargs nbsp Nh noreply onchange orangered overridable pdf perl php phtml png posix proj py pytest PYTHONPATH pyw quickstart rb readline regex rmdir rmtree rng rp rstrip rtf rx setattr shutil splitext splitlines startswith staticmethod strftime structs stylesheet svg sys td timezone tl tmp tmpl toc toolchain tooltip tt tz url urllib utc utils uuid vm vue vx whitelist wp writelines wx xhtml xls xlsx xml xmlns yml zsh zu
To accept :heavy_check_mark: these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the [email protected]:LeStarch/fprime.git repository on the update/type-refactor branch (:information_source: how do I use this?):

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
-H "Content-Type: application/json" \
"https://api.github.com/repos/nasa/fprime/issues/comments/1203487164" > "$comment_json"
comment_body=$(mktemp)
jq -r ".body // empty" "$comment_json" | tr -d "\\r" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")

patch_add=$(perl -e '$/=undef; $_=<>; if (m{Unrecognized words[^<]*</summary>\n*```\n*([^<]*)```\n*</details>$}m) { print "$1" } elsif (m{Unrecognized words[^<]*\n\n((?:\w.*\n)+)\n}m) { print "$1" };' < "$comment_body")

update_files
rm $comment_body
git add -u

If the flagged items are false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Aug 03 '22 05:08 github-actions[bot]

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

Inttype

Previously acknowledged words that are now absent ABuffer apps argparse args arity aspx autocomplete autogenerated bw bytearray cfg checkbox chmod chr ci classmethod Concat config cpp cpy cspell css csv cxx datetime delattr deserialize DHTML django dockerfile dropdown elif endfor endif endswith etree ev exe fd fh filesystem filetypes fullstack func functools gainsboro getattr getcwd getpass gh globals gz hasattr hh hpp href htm html http hu hxx hyperlink hz img ini inl ino inttype ip isabs isdir isfile isinstance issubclass iu javascript jpg json len lifecycle lightgreen lightyellow listdir ljust localtime lstrip lte mailto makedirs middleware mkdir mlist mname mq MTIME multiline MVC Mypy namespace nargs nbsp Nh noreply onchange orangered overridable pdf perl php phtml png posix proj py pytest PYTHONPATH pyw quickstart rb readline regex rmdir rmtree rng rp rstrip rtf rx setattr shutil splitext splitlines startswith staticmethod strftime structs stylesheet svg sys td timezone tl tmp tmpl toc toolchain tooltip tt tz url urllib utc utils uuid vm vue vx whitelist wp writelines wx xhtml xls xlsx xml xmlns yml zsh zu
To accept :heavy_check_mark: these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the [email protected]:LeStarch/fprime.git repository on the update/type-refactor branch (:information_source: how do I use this?):

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
-H "Content-Type: application/json" \
"https://api.github.com/repos/nasa/fprime/issues/comments/1203587905" > "$comment_json"
comment_body=$(mktemp)
jq -r ".body // empty" "$comment_json" | tr -d "\\r" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")

patch_add=$(perl -e '$/=undef; $_=<>; if (m{Unrecognized words[^<]*</summary>\n*```\n*([^<]*)```\n*</details>$}m) { print "$1" } elsif (m{Unrecognized words[^<]*\n\n((?:\w.*\n)+)\n}m) { print "$1" };' < "$comment_body")

update_files
rm $comment_body
git add -u

If the flagged items are false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Aug 03 '22 07:08 github-actions[bot]

Also, the Python Autocoder files still use AssertArg e.g. Autocoders/Python/src/fprime_ac/generators/templates/component/cpp.py ? I suspect those files are no longer maintained.

kevin-f-ortega avatar Aug 09 '22 01:08 kevin-f-ortega

I tried this one out and it compiled with my system. But is https://github.com/nasa/fprime/pull/1615 a duplicate of this PR?

kevin-f-ortega avatar Aug 16 '22 05:08 kevin-f-ortega