mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
tests/hard_coded/Mmakefile:
Foreign enums are only currently supported by the C and C# grades.
Don't run tests for them in the Java grade.
tests/hard_coded/foreign_enum_mod2.m:
Comment out a foreign_enum pragma for Java.
75 lines
1.5 KiB
Mathematica
75 lines
1.5 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module foreign_enum_mod2.
|
|
:- interface.
|
|
|
|
:- type instrument.
|
|
|
|
:- type ingredient
|
|
---> eggs
|
|
; sugar
|
|
; flour
|
|
; milk.
|
|
|
|
:- func my_instrument = instrument.
|
|
|
|
:- implementation.
|
|
|
|
:- type instrument
|
|
---> violin
|
|
; piano
|
|
; xylophone.
|
|
|
|
:- type foo
|
|
---> foo
|
|
; bar
|
|
; baz.
|
|
|
|
my_instrument = piano.
|
|
|
|
% This should end up in the .int file.
|
|
%
|
|
:- pragma foreign_enum("C", ingredient/0, [
|
|
foreign_enum_mod2.eggs - "EGGS",
|
|
foreign_enum_mod2.sugar - "SUGAR",
|
|
foreign_enum_mod2.flour - "FLOUR",
|
|
foreign_enum_mod2.milk - "MILK"
|
|
]).
|
|
|
|
% As should this.
|
|
% XXX not currently supported in Java grade.
|
|
%:- pragma foreign_enum("Java", ingredient/0, [
|
|
% eggs - "Ingredient.EGGS",
|
|
% sugar - "Ingredient.SUGAR",
|
|
% flour - "Ingredient.FLOUR",
|
|
% milk - "Ingredient.MILK"
|
|
%]).
|
|
|
|
% This shouldn't since the type is not exported.
|
|
%
|
|
:- pragma foreign_enum("C", foo/0, [
|
|
foo - "3",
|
|
bar - "4",
|
|
baz - "5"
|
|
]).
|
|
|
|
% This shouldn't since the type is abstract.
|
|
%
|
|
:- pragma foreign_enum("C", instrument/0, [
|
|
violin - "100",
|
|
piano - "200",
|
|
xylophone - "300"
|
|
]).
|
|
|
|
:- pragma foreign_decl("C", "
|
|
|
|
#define EGGS 10
|
|
#define SUGAR 20
|
|
#define FLOUR 30
|
|
#define MILK 40
|
|
|
|
").
|
|
|