867 "Modified (comment): / 23-05-2014 / 16:16:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
854 "Modified (comment): / 23-05-2014 / 16:16:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
868 ! ! |
855 ! ! |
869 |
856 |
870 !CompilerTests2 methodsFor:'tests - FFI'! |
857 !CompilerTests2 methodsFor:'tests - FFI'! |
871 |
858 |
872 test_external_function_call_01 |
859 test_external_function_call_01a |
873 "Test for stx bug for <cdecl> specs like |
860 "Test for stx bug for <cdecl> specs like |
874 |
861 |
875 <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) > |
862 <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) > |
876 |
863 |
877 i.e., when custom subclass of ExternalAddress is in namespace." |
864 i.e., when custom subclass of ExternalAddress is in namespace." |
883 <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int ) module: ''librun.so''> |
870 <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int ) module: ''librun.so''> |
884 self primitive failed'. |
871 self primitive failed'. |
885 free := 'free: ptr |
872 free := 'free: ptr |
886 |
873 |
887 <cdecl: const void "free" ( RegressionTests::CompilerTests2ExternalBytes ) module: ''librun.so''> |
874 <cdecl: const void "free" ( RegressionTests::CompilerTests2ExternalBytes ) module: ''librun.so''> |
|
875 self primitive failed'. |
|
876 #( #bc #stc ) do:[:mode | |
|
877 | ptr | |
|
878 |
|
879 self compile:malloc mode:mode. |
|
880 self compile:free mode:mode. |
|
881 ptr := self perform:(mode , '_malloc:') asSymbol with:1. |
|
882 self assert:ptr class == RegressionTests::CompilerTests2ExternalBytes. |
|
883 self perform:(mode , '_free:') asSymbol with:ptr. |
|
884 ] |
|
885 |
|
886 "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
887 "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
888 ! |
|
889 |
|
890 test_external_function_call_01b |
|
891 "Test for stx bug for <cdecl> specs like |
|
892 |
|
893 <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) > |
|
894 |
|
895 i.e., when custom subclass of ExternalAddress is in namespace." |
|
896 |
|
897 | malloc free | |
|
898 |
|
899 malloc := 'malloc: size |
|
900 |
|
901 <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int ) module: ''librun''> |
|
902 self primitive failed'. |
|
903 free := 'free: ptr |
|
904 |
|
905 <cdecl: const void "free" ( RegressionTests::CompilerTests2ExternalBytes ) module: ''librun''> |
|
906 self primitive failed'. |
|
907 #( #bc #stc ) do:[:mode | |
|
908 | ptr | |
|
909 |
|
910 self compile:malloc mode:mode. |
|
911 self compile:free mode:mode. |
|
912 ptr := self perform:(mode , '_malloc:') asSymbol with:1. |
|
913 self assert:ptr class == RegressionTests::CompilerTests2ExternalBytes. |
|
914 self perform:(mode , '_free:') asSymbol with:ptr. |
|
915 ] |
|
916 |
|
917 "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
918 "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
919 ! |
|
920 |
|
921 test_external_function_call_01c |
|
922 "Test for stx bug for <cdecl> specs like |
|
923 |
|
924 <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) > |
|
925 |
|
926 i.e., when custom subclass of ExternalAddress is in namespace." |
|
927 |
|
928 | malloc free | |
|
929 |
|
930 malloc := 'malloc: size |
|
931 |
|
932 <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int )> |
|
933 self primitive failed'. |
|
934 free := 'free: ptr |
|
935 |
|
936 <cdecl: const void "free" ( RegressionTests::CompilerTests2ExternalBytes )> |
888 self primitive failed'. |
937 self primitive failed'. |
889 #( #bc #stc ) do:[:mode | |
938 #( #bc #stc ) do:[:mode | |
890 | ptr | |
939 | ptr | |
891 |
940 |
892 self compile:malloc mode:mode. |
941 self compile:malloc mode:mode. |