Skip to content
Abe Pralle edited this page Oct 6, 2022 · 1 revision

Syntax

nativeType<<"c-value-type-name">> NativeTypeName

local data = native( ''(NativeTypeName) { value }'' )->NativeTypeName

native @|c-value-type-name value = $data.value

Example

nativeType<<"char*">> RogueCString

routine printf( string:RogueCString ) [essential]
  native @|printf( "%s\n", $string.value );
endRoutine

local arg = native(''(RogueCString){"Hello World!"}'')->RogueCString
printf arg

Description

nativeType<<"c-value-type-name">> NativeTypeName declares a Rogue compound / C struct type which contains a single property value of type c-value-type-name. The resulting wrapper or container type has the same name in Rogue and in C.

Native types are used to wrap (or contain) arbitrary C types that can be passed between Rogue and C code. Rogue code never "understands" what's in the opaque native type data, but C code can create wrapped values, send the wrapper to Rogue, and retrieve the wrapped .value later.

Clone this wiki locally