@@ -25,23 +25,15 @@ pub fn serialize_value<'gc>(
2525 amf_version : AMFVersion ,
2626 object_table : & mut ObjectTable < ' gc > ,
2727) -> Option < AmfValue > {
28- match elem {
28+ match elem. normalize ( ) {
2929 Value :: Undefined => Some ( AmfValue :: Undefined ) ,
3030 Value :: Null => Some ( AmfValue :: Null ) ,
3131 Value :: Bool ( b) => Some ( AmfValue :: Bool ( b) ) ,
3232 Value :: Number ( f) => Some ( AmfValue :: Number ( f) ) ,
33- Value :: Integer ( num) => {
34- // NOTE - we should really be converting `Value::Integer` to `Value::Number`
35- // whenever it's outside this range, instead of performing this during AMF serialization.
36- // Integers are unsupported in AMF0, and must be converted to Number regardless of whether
37- // it can be represented as an integer.
38- // FIXME - handle coercion floats like '1.0' to integers
39- if amf_version == AMFVersion :: AMF0 || num >= ( 1 << 28 ) || num < -( 1 << 28 ) {
40- Some ( AmfValue :: Number ( num as f64 ) )
41- } else {
42- Some ( AmfValue :: Integer ( num) )
43- }
44- }
33+ // Integers are unsupported in AMF0, and must be converted to Number regardless of whether
34+ // it can be represented as an integer.
35+ Value :: Integer ( i) if amf_version == AMFVersion :: AMF0 => Some ( AmfValue :: Number ( i as f64 ) ) ,
36+ Value :: Integer ( i) => Some ( AmfValue :: Integer ( i) ) ,
4537 Value :: String ( s) => Some ( AmfValue :: String ( s. to_string ( ) ) ) ,
4638 Value :: Object ( o) => {
4739 // TODO: Find a more general rule for which object types should be skipped,
0 commit comments