execute method

void execute()

Execute this batch.

Implementation

void execute() {
  final a = malloc<syz_AutomationCommand>(_commands.length);
  for (var i = 0; i < _commands.length; i++) {
    final command = _commands[i];
    final ref = a[i]
      ..time = command.time
      ..target = command.targetHandle.value
      ..type = command.type.toInt();
    if (command is AutomationAppendPropertyCommand) {
      final append = ref.params.append_to_property
        ..property = command.property.toInt();
      append.point
        ..interpolation_type = command.interpolationType.toInt()
        ..flags = 0;
      final dynamic value = command.value;
      if (value is double) {
        append.point.values[0] = value;
      } else if (value is Double3) {
        append.point.values[0] = value.x;
        append.point.values[1] = value.y;
        append.point.values[2] = value.z;
      } else if (value is Double6) {
        append.point.values[0] = value.x1;
        append.point.values[1] = value.y1;
        append.point.values[2] = value.z1;
        append.point.values[3] = value.x2;
        append.point.values[4] = value.y2;
        append.point.values[5] = value.z2;
      } else {
        throw SynthizerError(
          'Invalid point type ${value.runtimeType}: $value.',
          -1,
        );
      }
    } else if (command is AutomationClearPropertyCommand) {
      ref.params.clear_property.property = command.property.toInt();
    } else if (command is AutomationSendUserEventCommand) {
      ref.params.send_user_event.param = command.param;
    }
  }
  synthizer.check(
    synthizer.synthizer
        .syz_automationBatchAddCommands(handle.value, _commands.length, a),
  );
  malloc.free(a);
  synthizer
      .check(synthizer.synthizer.syz_automationBatchExecute(handle.value));
}