CreateLibraryTags

3 posts / 0 new
Last post
alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
CreateLibraryTags

Does anyone have a working example of how to create a library with CreateLibraryTags?? I have successfully created two exec Interfaces (with MakeInterfaceTags), but when I call CreateLibraryTags, I get a NULL pointer no matter how hard I try... Help?

salass00
salass00's picture
Offline
Last seen: 7 months 2 weeks ago
Joined: 2011-02-03 11:27
This is what I have in

This is what I have in cdplayer.library:

  1. /* Manager interface vectors */
  2. static CONST APTR lib_manager_vectors[] = {
  3. (APTR)_generic_Obtain,
  4. (APTR)_generic_Release,
  5. NULL,
  6. NULL,
  7. (APTR)libOpen,
  8. (APTR)libClose,
  9. (APTR)libExpunge,
  10. NULL,
  11. (APTR)-1
  12. };
  13.  
  14. /* "__library" interface tag list */
  15. static CONST struct TagItem lib_managerTags[] = {
  16. { MIT_Name, (Tag)"__library" },
  17. { MIT_VectorTable, (Tag)lib_manager_vectors },
  18. { MIT_Version, 1 },
  19. { TAG_DONE, 0 }
  20. };
  21.  
  22. STATIC CONST APTR main_vectors[] = {
  23. (APTR)_generic_Obtain,
  24. (APTR)_generic_Release,
  25. NULL,
  26. NULL,
  27. (APTR)_CDPlayer_CDEject,
  28. (APTR)_CDPlayer_CDPlay,
  29. (APTR)_CDPlayer_CDResume,
  30. (APTR)_CDPlayer_CDStop,
  31. (APTR)_CDPlayer_CDJump,
  32. (APTR)_CDPlayer_CDActive,
  33. (APTR)_CDPlayer_CDCurrentTitle,
  34. (APTR)_CDPlayer_CDTitleTime,
  35. (APTR)_CDPlayer_CDGetVolume,
  36. (APTR)_CDPlayer_CDSetVolume,
  37. (APTR)_CDPlayer_CDReadTOC,
  38. (APTR)_CDPlayer_CDInfo,
  39. (APTR)_CDPlayer_CDPlayAddr,
  40. (APTR)-1
  41. };
  42.  
  43. /* Uncomment this line (and see below) if your library has a 68k jump table */
  44. extern APTR VecTable68K[];
  45.  
  46. static CONST struct TagItem mainTags[] = {
  47. { MIT_Name, (Tag)"main" },
  48. { MIT_VectorTable, (Tag)main_vectors },
  49. { MIT_Version, 1 },
  50. { TAG_DONE, 0 }
  51. };
  52.  
  53. static CONST CONST_APTR libInterfaces[] = {
  54. lib_managerTags,
  55. mainTags,
  56. NULL
  57. };
  58.  
  59. static CONST struct TagItem libCreateTags[] = {
  60. { CLT_DataSize, sizeof(struct CDPlayerBase) },
  61. { CLT_InitFunc, (Tag)libInit },
  62. { CLT_Interfaces, (Tag)libInterfaces },
  63. /* Uncomment the following line if you have a 68k jump table */
  64. { CLT_Vector68K, (Tag)VecTable68K },
  65. { TAG_DONE, 0 }
  66. };

The libCreateTags is what is passed to CreateLibrary().

Note that unless you are creating a library in memory yourself you do not need to call CreateLibrary(Tags)() explicitly.

Note also that CreateLibrary() handles calling MakeInterface() for you for all the interfaces you specified with the CLT_Interfaces tag.

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
Thanks, I solved the problem:

Thanks, I solved the problem: I was creating the Interfaces with MakeInterface instead of just passing the Tags to CreateLibrary... Doh!

Log in or register to post comments