Skip to content

Instantly share code, notes, and snippets.

@ashgti
Created May 25, 2010 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashgti/412727 to your computer and use it in GitHub Desktop.
Save ashgti/412727 to your computer and use it in GitHub Desktop.
Current NCI System:
v - Void. As a return type it indicates that there is no return type.Not valid as a parameter type.
c - Char. This is an integer type, taken from (or put into) an I register. NOTE: it might be signed or unsigned because that is how an unadorned C 'char' works.
s - short. An integer type, taken from or put into an I register. It is always signed, not unsigned.
i - int. An integer type. It is always signed, not unsigned.
l - long. An integer type. You know the drill. It is always signed, not unsigned.
f - float. F register denizen.
d - double. F register, double-precision floating point type
P - A PMC register.
p - PMC thingie. A generic pointer, taken from a PMC by using its get_pointer vtable function, or NULL for a PMCNULL. If this is a return type and the value is NULL, PMCNULL is returned, otherwise parrot will create a new UnManagedStruct PMC type, which is just a generic "pointer to something" PMC type which Parrot does no management of.
2 - A pointer to a short, taken from an P register of an int-like PMC.
3 - A pointer to an int, taken from an P register of an int-like PMC.
4 - A pointer to a long, taken from an P register of an int-like PMC.
t - string pointer. Taken from, or stuck into, a string register. (Converted to a null-terminated C string before passing in)
U - This parameter is used for passing user data to a callback creation. More explanation in the callbacks section.
New Extensions:
Base Data Types:
c = char - 8 bit
b = int8 - 8 bit
w = w_char, system dependent
s = short - 16 bit
l = long - 32 bit
i = int
q = long long - 64 bit
f = float
d = double
D = long doulbe (if supported)
v = void
t = string pointer. From a string register. (null-terminated C String)
x = alignment size, eg. x[8]
Specials:
P = PMC
. = Var Args (Experimental), function definition only, has to be last argument.
U = Callback, Function Pointers
Modifiers:
Prefix:
* = Pointer
s = Signed
u = Unsigned
& = pass_by_ref in functions, only valid in function defintions
! = Native Type
^ = UnManaged
> = force big-endian
< = force little-endian
Infix:
| = union of left two right
Postfix:
i# = int of size ##, eg. i8, i16, i32, i64, i128...
{...} = key name, only valid in a structure after a definition.
[...] = array of a set size, or alignment size
Circumfix:
(...) = structure
New Ops:
PMC struct_from_string STRING
This operation will build a structure from a given string definition. For
consistancy, I think it should include the () in the definition.
Modified Ops:
loadlib - Modify this function to make a hash of values you have pulled from it. So you can say lib["function"] for instance, and retrieve the function definition.
Examples:
*c = char*
*(iuqd) = struct { int; unsigned long long; double}*
*(i{foo}d{bar}) = struct { int foo; double bar }*
***i = int*** (pointer's can point to pointers)
*(d{price} i{id})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment