Skip to content

Commit

Permalink
Cast double to float instead of .getFloat
Browse files Browse the repository at this point in the history
Summary: ReadableArray doesn't have a .getFloat, so casting double to floats instead. This is consistent with how the prop conversion happens as well.

Reviewed By: makovkastar

Differential Revision: D16897600

fbshipit-source-id: e8c76558f030d291960b5790a262fa49a9f358e7
  • Loading branch information
TheSavior authored and facebook-github-bot committed Aug 19, 2019
1 parent cddc2c6 commit 0df5e50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,18 @@ function generatePropCasesString(
}`;
}

function getCommandArgJavaType(param) {
function getCommandArgJavaType(param, index) {
switch (param.typeAnnotation.type) {
case 'BooleanTypeAnnotation':
return 'getBoolean';
return `args.getBoolean(${index})`;
case 'DoubleTypeAnnotation':
return 'getDouble';
return `args.getDouble(${index})`;
case 'FloatTypeAnnotation':
return 'getFloat';
return `(float) args.getDouble(${index})`;
case 'Int32TypeAnnotation':
return 'getInt';
return `args.getInt(${index})`;
case 'StringTypeAnnotation':
return 'getString';
return `args.getString(${index})`;
default:
(param.typeAnnotation.type: empty);
throw new Error('Receieved invalid typeAnnotation');
Expand All @@ -156,11 +156,7 @@ function getCommandArgJavaType(param) {
function getCommandArguments(command: CommandTypeShape): string {
return [
'view',
...command.typeAnnotation.params.map((param, index) => {
const commandArgJavaType = getCommandArgJavaType(param);

return `args.${commandArgJavaType}(${index})`;
}),
...command.typeAnnotation.params.map(getCommandArgJavaType),
].join(', ');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public class CommandNativeComponentManagerDelegate<T extends View, U extends Bas
viewManager.flashScrollIndicators(view);
break;
case \\"allTypes\\":
viewManager.allTypes(view, args.getInt(0), args.getFloat(1), args.getDouble(2), args.getString(3), args.getBoolean(4));
viewManager.allTypes(view, args.getInt(0), (float) args.getDouble(1), args.getDouble(2), args.getString(3), args.getBoolean(4));
break;
}
}
Expand Down

0 comments on commit 0df5e50

Please sign in to comment.