mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-11 20:03:28 +00:00
Update the samples to use MR_ types and MR_ macros for
Estimated hours taken: 0.5 samples/c_interface/c_calls_mercury/c_main.c: samples/c_interface/cplusplus_calls_mercury/cpp_main.cc: samples/c_interface/simpler_c_calls_mercury/c_main.c: samples/c_interface/simpler_cplusplus_calls_mercury/cpp_main.cc: Update the samples to use MR_ types and MR_ macros for creating lists.
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
|
||||
#include "c_main.h"
|
||||
|
||||
typedef Word MercuryList;
|
||||
typedef MR_Word MercuryList;
|
||||
|
||||
static void print_list(MercuryList);
|
||||
|
||||
void c_main(void) {
|
||||
Integer value;
|
||||
MR_Integer value;
|
||||
MercuryList list;
|
||||
|
||||
printf("In c_main().\n");
|
||||
@@ -76,15 +76,15 @@ void c_main(void) {
|
||||
}
|
||||
|
||||
static void print_list(MercuryList list) {
|
||||
if (list_is_empty(list)) {
|
||||
if (MR_list_is_empty(list)) {
|
||||
printf("[]");
|
||||
} else {
|
||||
printf("[");
|
||||
printf("%ld", (long) list_head(list));
|
||||
list = list_tail(list);
|
||||
while (!list_is_empty(list)) {
|
||||
printf(", %ld", (long) list_head(list));
|
||||
list = list_tail(list);
|
||||
list = MR_list_tail(list);
|
||||
while (!MR_list_is_empty(list)) {
|
||||
printf(", %ld", (long) MR_list_head(list));
|
||||
list = MR_list_tail(list);
|
||||
}
|
||||
printf("]");
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "cpp_main.h"
|
||||
|
||||
typedef Word MercuryList;
|
||||
typedef MR_Word MercuryList;
|
||||
|
||||
static void print_list(MercuryList);
|
||||
|
||||
@@ -25,7 +25,7 @@ void cpp_main() {
|
||||
** to the Mercury predicate foo/1 in mode
|
||||
** :- mode foo(out) is cc_multi.
|
||||
*/
|
||||
Integer value;
|
||||
MR_Integer value;
|
||||
one_foo(&value);
|
||||
printf("one_foo(&value) gives value = %ld\n", (long) value);
|
||||
|
||||
@@ -76,15 +76,15 @@ void cpp_main() {
|
||||
}
|
||||
|
||||
static void print_list(MercuryList list) {
|
||||
if (list_is_empty(list)) {
|
||||
if (MR_list_is_empty(list)) {
|
||||
printf("[]");
|
||||
} else {
|
||||
printf("[");
|
||||
printf("%ld", (long) list_head(list));
|
||||
list = list_tail(list);
|
||||
while (!list_is_empty(list)) {
|
||||
printf(", %ld", (long) list_head(list));
|
||||
list = list_tail(list);
|
||||
list = MR_list_tail(list);
|
||||
while (!MR_list_is_empty(list)) {
|
||||
printf(", %ld", (long) MR_list_head(list));
|
||||
list = MR_list_tail(list);
|
||||
}
|
||||
printf("]");
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef Word MercuryList;
|
||||
typedef MR_Word MercuryList;
|
||||
|
||||
static void print_list(MercuryList);
|
||||
|
||||
@@ -92,15 +92,15 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
static void print_list(MercuryList list) {
|
||||
if (list_is_empty(list)) {
|
||||
if (MR_list_is_empty(list)) {
|
||||
printf("[]");
|
||||
} else {
|
||||
printf("[");
|
||||
printf("%ld", (long) list_head(list));
|
||||
list = list_tail(list);
|
||||
while (!list_is_empty(list)) {
|
||||
printf(", %ld", (long) list_head(list));
|
||||
list = list_tail(list);
|
||||
list = MR_list_tail(list);
|
||||
while (!MR_list_is_empty(list)) {
|
||||
printf(", %ld", (long) MR_list_head(list));
|
||||
list = MR_list_tail(list);
|
||||
}
|
||||
printf("]");
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ extern "C" {
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef Word MercuryList;
|
||||
typedef MR_Word MercuryList;
|
||||
|
||||
static void print_list(MercuryList);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char dummy;
|
||||
Integer value;
|
||||
MR_Integer value;
|
||||
MercuryList list;
|
||||
int exit_status;
|
||||
|
||||
@@ -94,15 +94,15 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
static void print_list(MercuryList list) {
|
||||
if (list_is_empty(list)) {
|
||||
if (MR_list_is_empty(list)) {
|
||||
printf("[]");
|
||||
} else {
|
||||
printf("[");
|
||||
printf("%ld", (long) list_head(list));
|
||||
list = list_tail(list);
|
||||
list = MR_list_tail(list);
|
||||
while (!list_is_empty(list)) {
|
||||
printf(", %ld", (long) list_head(list));
|
||||
list = list_tail(list);
|
||||
printf(", %ld", (long) MR_list_head(list));
|
||||
list = MR_list_tail(list);
|
||||
}
|
||||
printf("]");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user