537 I.e. retrieve the module handle and the code pointer." |
537 I.e. retrieve the module handle and the code pointer." |
538 |
538 |
539 |handle moduleNameUsed functionName| |
539 |handle moduleNameUsed functionName| |
540 |
540 |
541 name isNumber ifTrue:[ |
541 name isNumber ifTrue:[ |
542 self isCPPFunction ifTrue:[ |
542 self isCPPFunction ifTrue:[ |
543 "/ no need to load a dll. |
543 "/ no need to load a dll. |
544 ^ self |
544 ^ self |
545 ] |
545 ] |
546 ]. |
546 ]. |
547 |
547 |
|
548 "/ in some other smalltalks, there is no moduleName in the ffi-spec; |
|
549 "/ instead, the class provides the libraryName... |
548 (moduleNameUsed := moduleName) isNil ifTrue:[ |
550 (moduleNameUsed := moduleName) isNil ifTrue:[ |
549 owningClass isNil ifTrue:[ |
551 owningClass isNil ifTrue:[ |
550 self error:'Missing moduleName'. |
552 self error:'Missing moduleName'. |
551 ]. |
553 ]. |
552 moduleNameUsed := owningClass theNonMetaclass libraryName asSymbol. |
554 moduleNameUsed := owningClass theNonMetaclass libraryName asSymbol. |
553 ]. |
555 ]. |
554 moduleHandle isNil ifTrue:[ |
556 moduleHandle isNil ifTrue:[ |
555 handle := self loadLibrary:moduleNameUsed. |
557 handle := self loadLibrary:moduleNameUsed. |
556 handle isNil ifTrue:[ |
558 handle isNil ifTrue:[ |
557 self error:('Cannot load module: "%1"' bindWith: moduleNameUsed). |
559 self error:('Cannot load module: "%1"' bindWith: moduleNameUsed). |
558 ]. |
560 ]. |
559 moduleHandle := handle. |
561 moduleHandle := handle. |
560 ]. |
562 ]. |
561 name isNumber ifFalse:[ |
563 name isNumber ifFalse:[ |
562 functionName := name. |
564 functionName := name. |
563 (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[ |
565 (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[ |
564 functionName := ('_', functionName) asSymbol. |
566 functionName := ('_', functionName) asSymbol. |
565 |
567 |
566 (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[ |
568 (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[ |
567 moduleHandle := nil. |
569 moduleHandle := nil. |
568 self error:'Missing function: ', name, ' in module: ', moduleNameUsed. |
570 self error:'Missing function: ', name, ' in module: ', moduleNameUsed. |
569 ]. |
571 ]. |
570 ]. |
572 ]. |
571 ]. |
573 ]. |
572 |
574 |
573 "Modified: / 01-08-2006 / 16:24:14 / cg" |
575 "Modified: / 01-08-2006 / 16:24:14 / cg" |
|
576 "Modified (comment): / 07-10-2011 / 16:43:11 / cg" |
574 ! |
577 ! |
575 |
578 |
576 loadLibrary:dllName |
579 loadLibrary:dllName |
577 |handle nameString filename| |
580 |handle nameString filename| |
578 |
581 |