Skip to content

Commit

Permalink
Merge 8a128ae into a84361f
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Nov 3, 2016
2 parents a84361f + 8a128ae commit 607feaa
Show file tree
Hide file tree
Showing 65 changed files with 15,076 additions and 254 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
tests: $(patsubst %.h,%.out,$(wildcard src/tests/*.h))
tests: $(patsubst %.api.h,%.out.h,$(wildcard src/tests/*.h))

src/tests/%.out: src/tests/%.h all
src/tests/%.out.h: src/tests/%.api.h all
-cd src && ../apigen.native $(patsubst src/%,%,$<) > $(patsubst src/%,%,$@) 2>&1
diff -u $@ src/tests/$*.exp
diff -u $@ src/tests/$*.exp.h
rm -f $@

all:
Expand Down
6 changes: 3 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ BUILDFLAGS := -yaccflags --table

default: test

tests: $(patsubst %.h,%.out,$(wildcard tests/*.h))
tests: $(patsubst %.api.h,%.out.h,$(wildcard tests/*.h))

tests/%.out: tests/%.h build
tests/%.out.h: tests/%.api.h build
-./apigen.native $< > $@ 2>&1
diff -u $@ tests/$*.exp
diff -u $@ tests/$*.exp.h
rm -f $@

# We have our own for now, because upstream is broken.
Expand Down
2 changes: 1 addition & 1 deletion src/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.out
*.out.*
6 changes: 6 additions & 0 deletions src/tests/bad_prop_fun_decl.api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
uint8_t stuff {
/**
* Something.
*/
static get();
}
10 changes: 10 additions & 0 deletions src/tests/bad_prop_fun_decl.exp.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

uint8_t stuff {

/**
* Something.
*/
static get();
}


13 changes: 13 additions & 0 deletions src/tests/bad_prop_fun_decl.exp.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ApiAst.Api (None,
[(ApiAst.Decl_GetSet ((ApiAst.Ty_LName uint8_t), stuff,
[(ApiAst.Decl_Comment (
(ApiAst.Cmt_Doc
[ApiAst.Cmtf_Break; (ApiAst.Cmtf_Doc " Something.")]),
(ApiAst.Decl_Static
(ApiAst.Decl_Function (ApiAst.Ty_Auto, get, [], ApiAst.Err_None
)))
))
]
))
],
None))
1 change: 1 addition & 0 deletions src/tests/bad_prop_fun_decl.exp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("(ApiAst.Decl_Static\n (ApiAst.Decl_Function (ApiAst.Ty_Auto, get, [], ApiAst.Err_None)))")
1 change: 1 addition & 0 deletions src/tests/bad_prop_fun_decl.exp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("cannot infer types for decl: (ApiAst.Decl_Static\n (ApiAst.Decl_Function (ApiAst.Ty_Auto, get, [], ApiAst.Err_None)))")
File renamed without changes.
48 changes: 48 additions & 0 deletions src/tests/bitmask.exp.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

namespace toxav {

/**
* The call state is a set of operations that are currently being performed.
* A value of 0 means we are neither sending nor receiving anything, meaning,
* one of the sides requested pause. The call will be resumed once the side
* that initiated pause resumes it.
*/
enum CALL_STATE {

/**
* The friend is sending audio (we are receiving).
*/
SENDING_A,

/**
* The friend is sending video (we are receiving).
*/
SENDING_V,

/**
* The friend is receiving audio (we are sending).
*/
RECEIVING_A,

/**
* The friend is receiving video (we are sending).
*/
RECEIVING_V,

/**
* The call has finished. This is the final state after which no more state
* transitions can occur for the call.
*/
END,

/**
* Set by the AV core if an error occurred on the remote end. This call
* state will never be triggered in combination with other call states.
*/
ERROR,

}

}


71 changes: 71 additions & 0 deletions src/tests/bitmask.exp.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
(ApiAst.Api (None,
[(ApiAst.Decl_Namespace (toxav,
[(ApiAst.Decl_Comment (
(ApiAst.Cmt_Doc
[ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" The call state is a set of operations that are currently being performed.");
ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" A value of 0 means we are neither sending nor receiving anything, meaning,");
ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" one of the sides requested pause. The call will be resumed once the side");
ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc " that initiated pause resumes it.")]),
(ApiAst.Decl_Enum (ApiAst.Enum_Bitmask, CALL_STATE,
[(ApiAst.Enum_Name (
(ApiAst.Cmt_Doc
[ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" The friend is sending audio (we are receiving).")
]),
SENDING_A, None));
(ApiAst.Enum_Name (
(ApiAst.Cmt_Doc
[ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" The friend is sending video (we are receiving).")
]),
SENDING_V, None));
(ApiAst.Enum_Name (
(ApiAst.Cmt_Doc
[ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" The friend is receiving audio (we are sending).")
]),
RECEIVING_A, None));
(ApiAst.Enum_Name (
(ApiAst.Cmt_Doc
[ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" The friend is receiving video (we are sending).")
]),
RECEIVING_V, None));
(ApiAst.Enum_Name (
(ApiAst.Cmt_Doc
[ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" The call has finished. This is the final state after which no more state");
ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" transitions can occur for the call.")
]),
END, None));
(ApiAst.Enum_Name (
(ApiAst.Cmt_Doc
[ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" Set by the AV core if an error occurred on the remote end. This call");
ApiAst.Cmtf_Break;
(ApiAst.Cmtf_Doc
" state will never be triggered in combination with other call states.")
]),
ERROR, None))
]
))
))
]
))
],
None))
File renamed without changes.
41 changes: 41 additions & 0 deletions src/tests/bitmask.exp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module Main where

import Data.Int (Int16, Int32, Int64, Int8)
import Data.Word (Word16, Word32, Word64, Word8)
import Foreign.C.String (CString, withCString)
import Foreign.C.Types (CInt (..), CSize (..))
import Foreign.Ptr (FunPtr, Ptr)

-- |
-- The call state is a set of operations that are currently being performed.
-- A value of 0 means we are neither sending nor receiving anything, meaning,
-- one of the sides requested pause. The call will be resumed once the side
-- that initiated pause resumes it.
data TOXAV_CALL_STATE

= TOXAV_CALL_STATE_SENDING_A = 1
-- ^
-- The friend is sending audio (we are receiving).

| TOXAV_CALL_STATE_SENDING_V = 2
-- ^
-- The friend is sending video (we are receiving).

| TOXAV_CALL_STATE_RECEIVING_A = 4
-- ^
-- The friend is receiving audio (we are sending).

| TOXAV_CALL_STATE_RECEIVING_V = 8
-- ^
-- The friend is receiving video (we are sending).

| TOXAV_CALL_STATE_END = 16
-- ^
-- The call has finished. This is the final state after which no more state
-- transitions can occur for the call.

| TOXAV_CALL_STATE_ERROR = 32
-- ^
-- Set by the AV core if an error occurred on the remote end. This call
-- state will never be triggered in combination with other call states.
deriving (Eq, Ord, Enum, Bounded, Read, Show)
File renamed without changes.
1 change: 0 additions & 1 deletion src/tests/class_number.exp

This file was deleted.

1 change: 1 addition & 0 deletions src/tests/class_number.exp.api
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("tests/class_number.api.h:1:7: error at NUMBER 3")
1 change: 1 addition & 0 deletions src/tests/class_number.exp.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("tests/class_number.api.h:1:7: error at NUMBER 3")
1 change: 1 addition & 0 deletions src/tests/class_number.exp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("tests/class_number.api.h:1:7: error at NUMBER 3")
1 change: 1 addition & 0 deletions src/tests/class_number.exp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("tests/class_number.api.h:1:7: error at NUMBER 3")
2 changes: 2 additions & 0 deletions src/tests/duplicate_name.api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int32_t x;
int32_t x;
7 changes: 7 additions & 0 deletions src/tests/duplicate_name.exp.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

int32_t x;


int32_t x;


4 changes: 4 additions & 0 deletions src/tests/duplicate_name.exp.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(ApiAst.Api (None,
[(ApiAst.Decl_Member ((ApiAst.Ty_LName int32_t), x));
(ApiAst.Decl_Member ((ApiAst.Ty_LName int32_t), x))],
None))
1 change: 1 addition & 0 deletions src/tests/duplicate_name.exp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("duplicate name: x")
1 change: 1 addition & 0 deletions src/tests/duplicate_name.exp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("duplicate name: x")
File renamed without changes.
1 change: 0 additions & 1 deletion src/tests/empty.exp

This file was deleted.

1 change: 1 addition & 0 deletions src/tests/empty.exp.api
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("tests/empty.api.h:1:1: error at EOF")
1 change: 1 addition & 0 deletions src/tests/empty.exp.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("tests/empty.api.h:1:1: error at EOF")
1 change: 1 addition & 0 deletions src/tests/empty.exp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("tests/empty.api.h:1:1: error at EOF")
1 change: 1 addition & 0 deletions src/tests/empty.exp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fatal error: exception Failure("tests/empty.api.h:1:1: error at EOF")
File renamed without changes.
45 changes: 45 additions & 0 deletions src/tests/event.exp.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

class fooBar {

struct this;

event thing {

/**
* yoy
*/
typedef void cb();

}


namespace bleh {

event thing {

/**
* yoy
*/
typedef void cb();

}


event otherthing const {

/**
* Heyo haha.
*/
typedef `a cb(uint32_t fluff);

}

}


`a iterate(`a user_data);

`any iterate2(`any user_data);
}


39 changes: 39 additions & 0 deletions src/tests/event.exp.ast
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
(ApiAst.Api (None,
[(ApiAst.Decl_Class (fooBar,
[(ApiAst.Decl_Struct (this, [], []));
(ApiAst.Decl_Event (thing, false,
[(ApiAst.Decl_Comment (
(ApiAst.Cmt_Doc [ApiAst.Cmtf_Break; (ApiAst.Cmtf_Doc " yoy")]),
(ApiAst.Decl_Typedef ((ApiAst.Ty_LName void), cb, []))))
]
));
(ApiAst.Decl_Namespace (bleh,
[(ApiAst.Decl_Event (thing, false,
[(ApiAst.Decl_Comment (
(ApiAst.Cmt_Doc
[ApiAst.Cmtf_Break; (ApiAst.Cmtf_Doc " yoy")]),
(ApiAst.Decl_Typedef ((ApiAst.Ty_LName void), cb, []))))
]
));
(ApiAst.Decl_Event (otherthing, true,
[(ApiAst.Decl_Comment (
(ApiAst.Cmt_Doc
[ApiAst.Cmtf_Break; (ApiAst.Cmtf_Doc " Heyo haha.")]),
(ApiAst.Decl_Typedef ((ApiAst.Ty_TVar a), cb,
[(ApiAst.Param ((ApiAst.Ty_LName uint32_t), fluff))]
))
))
]
))
]
));
(ApiAst.Decl_Function ((ApiAst.Ty_TVar a), iterate,
[(ApiAst.Param ((ApiAst.Ty_TVar a), user_data))], ApiAst.Err_None
));
(ApiAst.Decl_Function ((ApiAst.Ty_TVar any), iterate2,
[(ApiAst.Param ((ApiAst.Ty_TVar any), user_data))],
ApiAst.Err_None))
]
))
],
None))
File renamed without changes.
38 changes: 38 additions & 0 deletions src/tests/event.exp.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module Main where

import Data.Int (Int16, Int32, Int64, Int8)
import Data.Word (Word16, Word32, Word64, Word8)
import Foreign.C.String (CString, withCString)
import Foreign.C.Types (CInt (..), CSize (..))
import Foreign.Ptr (FunPtr, Ptr)


--struct FooBar
-- |
-- yoy
--typedef foobar_thing_cb = {- bar :: -} Ptr FooBar -> {- user_data :: -} Ptr () -> ()

-- |
-- Set the callback for the `${thing}` event. Pass NULL to unset.
--
--foreign import ccall foobar_callback_thing :: {- bar :: -} Ptr FooBar -> {- callback :: -} Ptr foobar_thing_cb -> {- user_data :: -} Ptr () -> {- result :: -} ()
-- |
-- yoy
--typedef foobar_bleh_thing_cb = {- bar :: -} Ptr FooBar -> {- user_data :: -} Ptr () -> ()

-- |
-- Set the callback for the `${bleh_thing}` event. Pass NULL to unset.
--
--foreign import ccall foobar_callback_bleh_thing :: {- bar :: -} Ptr FooBar -> {- callback :: -} Ptr foobar_bleh_thing_cb -> {- user_data :: -} Ptr () -> {- result :: -} ()
-- |
-- Heyo haha.
--typedef foobar_bleh_otherthing_cb = {- bar :: -} Ptr FooBar -> {- fluff :: -} Word32 -> {- user_data :: -} Ptr () -> <unresolved>

-- |
-- Set the callback for the `${bleh_otherthing}` event. Pass NULL to unset.
--
--foreign import ccall foobar_callback_bleh_otherthing :: {- bar :: -} Ptr FooBar -> {- callback :: -} Ptr foobar_bleh_otherthing_cb -> {- result :: -} ()

--foreign import ccall foobar_iterate :: {- bar :: -} Ptr FooBar -> {- user_data :: -} <unresolved> -> {- result :: -} <unresolved>

--foreign import ccall foobar_iterate2 :: {- bar :: -} Ptr FooBar -> {- user_data :: -} <unresolved> -> {- result :: -} <unresolved>

0 comments on commit 607feaa

Please sign in to comment.