Skip to content

Commit af60c89

Browse files
pjh9216Gemini CLI
andcommitted
[tizen_rpc_port] Support Dart protocol version 2
Add low level Parcel primitives to support the Dart protocol version 2 generator under packages/tizen_rpc_port. Implement the dataSize, reserve, and reader getter/setter properties in the Parcel class using Dart FFI to map them to the native C APIs: - rpc_port_parcel_get_reader - rpc_port_parcel_set_reader - rpc_port_parcel_get_data_size - rpc_port_parcel_set_data_size - rpc_port_parcel_reserve Co-Authored-By: Gemini CLI <gemini-cli@google.com> Signed-off-by: jh9216.park <jh9216.park@samsung.com>
1 parent 158dc46 commit af60c89

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

packages/tizen_rpc_port/lib/src/parcel.dart

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,4 +484,94 @@ class Parcel {
484484
return ParcelHeader._fromHandle(pHeader.value);
485485
});
486486
}
487+
488+
/// Gets the reader position of this parcel.
489+
int get reader {
490+
return using((Arena arena) {
491+
final Pointer<Uint32> pValue = arena();
492+
final int ret = _rpcPortParcelGetReader(_handle, pValue);
493+
if (ret != 0) {
494+
throw PlatformException(
495+
code: ret.toString(),
496+
message: tizen.get_error_message(ret).toDartString(),
497+
);
498+
}
499+
return pValue.value;
500+
});
501+
}
502+
503+
/// Sets the reader position of this parcel.
504+
set reader(int value) {
505+
final int ret = _rpcPortParcelSetReader(_handle, value);
506+
if (ret != 0) {
507+
throw PlatformException(
508+
code: ret.toString(),
509+
message: tizen.get_error_message(ret).toDartString(),
510+
);
511+
}
512+
}
513+
514+
/// Gets the data size of this parcel.
515+
int get dataSize {
516+
return using((Arena arena) {
517+
final Pointer<Uint32> pValue = arena();
518+
final int ret = _rpcPortParcelGetDataSize(_handle, pValue);
519+
if (ret != 0) {
520+
throw PlatformException(
521+
code: ret.toString(),
522+
message: tizen.get_error_message(ret).toDartString(),
523+
);
524+
}
525+
return pValue.value;
526+
});
527+
}
528+
529+
/// Sets the data size of this parcel.
530+
set dataSize(int value) {
531+
final int ret = _rpcPortParcelSetDataSize(_handle, value);
532+
if (ret != 0) {
533+
throw PlatformException(
534+
code: ret.toString(),
535+
message: tizen.get_error_message(ret).toDartString(),
536+
);
537+
}
538+
}
539+
540+
/// Reserves the capacity of this parcel.
541+
void reserve(int size) {
542+
final int ret = _rpcPortParcelReserve(_handle, size);
543+
if (ret != 0) {
544+
throw PlatformException(
545+
code: ret.toString(),
546+
message: tizen.get_error_message(ret).toDartString(),
547+
);
548+
}
549+
}
487550
}
551+
552+
final DynamicLibrary _libRpcPort = DynamicLibrary.open('librpc-port.so.1');
553+
554+
final int Function(Pointer<Void>, Pointer<Uint32>) _rpcPortParcelGetReader =
555+
_libRpcPort
556+
.lookup<NativeFunction<Int32 Function(Pointer<Void>, Pointer<Uint32>)>>('rpc_port_parcel_get_reader')
557+
.asFunction();
558+
559+
final int Function(Pointer<Void>, int) _rpcPortParcelSetReader =
560+
_libRpcPort
561+
.lookup<NativeFunction<Int32 Function(Pointer<Void>, Uint32)>>('rpc_port_parcel_set_reader')
562+
.asFunction();
563+
564+
final int Function(Pointer<Void>, Pointer<Uint32>) _rpcPortParcelGetDataSize =
565+
_libRpcPort
566+
.lookup<NativeFunction<Int32 Function(Pointer<Void>, Pointer<Uint32>)>>('rpc_port_parcel_get_data_size')
567+
.asFunction();
568+
569+
final int Function(Pointer<Void>, int) _rpcPortParcelSetDataSize =
570+
_libRpcPort
571+
.lookup<NativeFunction<Int32 Function(Pointer<Void>, Uint32)>>('rpc_port_parcel_set_data_size')
572+
.asFunction();
573+
574+
final int Function(Pointer<Void>, int) _rpcPortParcelReserve =
575+
_libRpcPort
576+
.lookup<NativeFunction<Int32 Function(Pointer<Void>, Uint32)>>('rpc_port_parcel_reserve')
577+
.asFunction();

0 commit comments

Comments
 (0)