Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
Cómo pasar una matriz de matriz de javascript a ensamblador

Tengo en el lado de javasctipt una matriz de matriz estructurada como esta:

 const arrayOfArray = [ArrayBuffer, ArrayBuffer, ArrayBuffer, ...]; const dataLenght = 100; //lenght of arrays inside of array

Necesito pasarlo al script de ensamblaje, debajo de un código de muestra (lado de javascript):

 const arrayOfPointers = new Uint32Array(arrayOfArray.lenght); for (let arrayIndex = 0; arrayIndex < arrayOfArray.lenght; arrayIndex ++) { const myArray = new Uint8ClampedArray(arrayOfArray[arrayIndex]); for (let i = 0; i < dataLenght ; i++) { //I try to fill with sample values for test myArray [i] = arrayIndex * 7 + 7; } const myArrayPtr = __newArray(Int8Array_ID, myArray ); arrayOfPointers [arrayIndex ] = myArrayPtr ; } const arrayOfPointersPtr = newArray(Int32Array_ID, arrayOfPointers); const resultPtr = wasmModule.DoStuffs(arrayOfPointersPtr, dataLenght); const mergedLayersBuffer = self.__getArray(resultPtr);

En cambio, este es el código AssemblyScriptSide

 export const Int8Array_ID = idof<Int8Array>(); export const Int32Array_ID = idof<Int32Array>(); export function mergeLayers(arrayOfArrayPointers: Array<usize>, dataLenght: i32): Uint8Array { const layer0Ptr : usize = arrayOfArrayPointers[0]; const layer0Buffer: ArrayBuffer = changetype<ArrayBuffer>(layer0Ptr); const resultLayer: Uint8Array = Uint8Array.wrap(layer0Buffer); for (let i: i32 = 0; i < 10; i++) { const value: u8 = resultLayer[i]; trace('Value', 1, value); } return resultLayer; }

Recibo los punteros correctamente en el lado del script de ensamblaje, pero luego no puedo convertir correctamente los punteros a Uint8ClampedArray y leer los valores.

¿Qué estoy haciendo mal y cómo puedo corregir este código?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!