Documentation fix for unloadAll and example for loading of a shared library (called loadCLib).
This commit is contained in:
		
							
								
								
									
										4
									
								
								examples/loadCLib/null/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								examples/loadCLib/null/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					TEST=   unloadAll/null
 | 
				
			||||||
 | 
					EXTRA_OBJS=Null.o Dep.o
 | 
				
			||||||
 | 
					TOP=../../..
 | 
				
			||||||
 | 
					include ../../build.mk
 | 
				
			||||||
							
								
								
									
										12
									
								
								examples/loadCLib/null/Null.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								examples/loadCLib/null/Null.hs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					module Null ( resource )  where
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import API
 | 
				
			||||||
 | 
					import Data.Dynamic
 | 
				
			||||||
 | 
					import Prelude hiding (null)
 | 
				
			||||||
 | 
					import Graphics.Rendering.OpenGL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					resource = null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- ! this has to be special: it can't be overridden by the user.
 | 
				
			||||||
 | 
					resource_dyn :: Dynamic
 | 
				
			||||||
 | 
					resource_dyn = toDyn resource
 | 
				
			||||||
							
								
								
									
										12
									
								
								examples/loadCLib/null/api/API.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								examples/loadCLib/null/api/API.hs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					{-# OPTIONS -fglasgow-exts #-}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module API where
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import Data.Dynamic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					data Null = Null { a, b :: Int }
 | 
				
			||||||
 | 
					   deriving (Typeable, Show)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					null :: Null
 | 
				
			||||||
 | 
					null = Null { a = 42 , b = 1 }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										11
									
								
								examples/loadCLib/null/prog/Main.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								examples/loadCLib/null/prog/Main.hs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					import System.Plugins
 | 
				
			||||||
 | 
					import API
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- an example where we just want to load an object and run it
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					main = do 
 | 
				
			||||||
 | 
					    m_v   <- load_ "../Null.o" ["../api",".."] "resource"
 | 
				
			||||||
 | 
					    case m_v of
 | 
				
			||||||
 | 
					        LoadFailure err -> error (unlines err)
 | 
				
			||||||
 | 
					        LoadSuccess m v -> do putStrLn ( show (a v) ) ; unload m
 | 
				
			||||||
							
								
								
									
										1
									
								
								examples/loadCLib/null/prog/expected
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								examples/loadCLib/null/prog/expected
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					42
 | 
				
			||||||
@ -9,7 +9,7 @@ main = do
 | 
				
			|||||||
    t     <- load_ "../Dep.o" ["../api"] "resource"
 | 
					    t     <- load_ "../Dep.o" ["../api"] "resource"
 | 
				
			||||||
    case m_v of
 | 
					    case m_v of
 | 
				
			||||||
        LoadFailure err -> error (unlines err)
 | 
					        LoadFailure err -> error (unlines err)
 | 
				
			||||||
        LoadSuccess m v -> do putStrLn ( show (a v) ) ; unloadAll m
 | 
					        LoadSuccess m v -> do putStrLn ( show (a v) ) ; unloadAll m -- unloads Null.o but not Dep.o since we're still using it.
 | 
				
			||||||
    case t of
 | 
					    case t of
 | 
				
			||||||
        LoadFailure err -> error (unlines err)
 | 
					        LoadFailure err -> error (unlines err)
 | 
				
			||||||
        LoadSuccess m v -> do putStrLn ( show (a v) ) ; unloadAll m
 | 
					        LoadSuccess m v -> do putStrLn ( show (a v) ) ; unloadAll m
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user