This set of function allow to pick, pop and push data from/to the RPL stack. It also allows to manipulate the stack (SWAP, DROP, ROT, ROLL, ...). Some C types are implemented as a C counterpart to the RPL types. The RPL types currently addressed are :
The elements of a list can be of any of the above types. The elements of an array/matrix can be any authorized types within the list above.
The interface provides for high level access functions, which allow to handle easily the most common operations.
Some examples :
LONGLONG val; hps_pick_int (3, &val);
list_t *list; hps_list_create (&list); hps_list_add_int (list, 1); hps_list_add_real (list, 2.3); hps_list_add_str (list, "Test"); hps_push_list (list);
A lower level interface allows to perform more advanced operations.
Example :
hpobj_t *obj_1; // Object for storing the 1st data hpobj_t *obj_2; // Object for storing the 2d level // Allocation of the objects hps_obj_create (&obj_1); hps_obj_create (&obj_2); // Picking the objects from the stack if ((hps_pick (1, obj_1) == HPS_OK) && (hps_pick (2, obj_2) == HPS_OK)) { list_t *list; // List to create // Creation of the list hps_list_create (&list); // Adding the objects to the list hps_list_add (list, obj_2); hps_list_add (list, obj_1); // Dropping the objects from the stack hps_drop (); hps_drop (); // Pushing the list onto the stack hps_push_list (list); }
Credits :
Some major parts of this code are coming or derived from the hplib/saturn files, by Al Borowski, Ingo Blank, Claudio Lapilli. I also found many informations in "Programming in System RPL" by Eduardo Kalinowski, and made a intensive usage of 'nosy' by Jurjen NE Bos to understand the RPL data structures.