Browse Source

Fix `JavaScriptBridge.eval()` never returning PackedByteArray

It wrongly returned 20 on array buffers, which used to be the enumerator
value of Godot 3.x's type PoolByteArray, and now is the value of type Color,
while it should return 29 which is the enumerator value for PackedByteArray.

(cherry picked from commit c662491bd4da857d641ff5fcb8a55ae0764a243a)
Emmanouil Papadeas 2 years ago
parent
commit
252d816459
1 changed files with 3 additions and 3 deletions
  1. 3 3
      platform/web/js/libs/library_godot_javascript_singleton.js

+ 3 - 3
platform/web/js/libs/library_godot_javascript_singleton.js

@@ -109,7 +109,7 @@ const GodotJSWrapper = {
 					return 2; // INT
 					return 2; // INT
 				}
 				}
 				GodotRuntime.setHeapValue(p_exchange, p_val, 'double');
 				GodotRuntime.setHeapValue(p_exchange, p_val, 'double');
-				return 3; // REAL
+				return 3; // FLOAT
 			} else if (type === 'string') {
 			} else if (type === 'string') {
 				const c_str = GodotRuntime.allocString(p_val);
 				const c_str = GodotRuntime.allocString(p_val);
 				GodotRuntime.setHeapValue(p_exchange, c_str, '*');
 				GodotRuntime.setHeapValue(p_exchange, c_str, '*');
@@ -313,7 +313,7 @@ const GodotEval = {
 
 
 		case 'number':
 		case 'number':
 			GodotRuntime.setHeapValue(p_union_ptr, eval_ret, 'double');
 			GodotRuntime.setHeapValue(p_union_ptr, eval_ret, 'double');
-			return 3; // REAL
+			return 3; // FLOAT
 
 
 		case 'string':
 		case 'string':
 			GodotRuntime.setHeapValue(p_union_ptr, GodotRuntime.allocString(eval_ret), '*');
 			GodotRuntime.setHeapValue(p_union_ptr, GodotRuntime.allocString(eval_ret), '*');
@@ -333,7 +333,7 @@ const GodotEval = {
 				const func = GodotRuntime.get_func(p_callback);
 				const func = GodotRuntime.get_func(p_callback);
 				const bytes_ptr = func(p_byte_arr, p_byte_arr_write, eval_ret.length);
 				const bytes_ptr = func(p_byte_arr, p_byte_arr_write, eval_ret.length);
 				HEAPU8.set(eval_ret, bytes_ptr);
 				HEAPU8.set(eval_ret, bytes_ptr);
-				return 20; // POOL_BYTE_ARRAY
+				return 29; // PACKED_BYTE_ARRAY
 			}
 			}
 			break;
 			break;