Jump to content
shadowrecon

Type exporting in Plugins??

Recommended Posts

I can not get scar to recognize my exported types.. Ive tried a ton of different ways. Heres what i have

 

[scar]

Type

TGMRLColor = Record

ColorCount : Integer;

ColorData : Array of Array of Integer;

end;

 

.........

....

...

 

function GetTypeCount(): Integer; stdcall; export;

begin

Result := 1;

end;

 

function GetTypeInfo(x: Integer; var sType, sTypeDef: string): Integer; stdcall;

begin

case x of

0:

begin

sType := 'TGMRLColor';

sTypeDef := 'record ColorCount : Integer; ColorData : Array of Array of Integer; End;';

end;

else

x := -1;

end;

Result := x;

end;

 

exports GetTypeCount;

exports GetTypeInfo;

exports GetFunctionCount;

exports GetFunctionInfo;

[/scar]

Link to comment
Share on other sites

There appears to be a bug in the plugin system related to type exports, I've uploaded a fix to the prerelease repository, it will be included in 3.32.02 as well.

 

Do note that

function GetTypeInfo(x: Integer; var sType, sTypeDef: string): Integer; stdcall;

should be

function GetTypeInfo(x: Integer; var sType, sTypeDef: AnsiString): Integer; stdcall;

 

As Delphi 2009 and newer use Unicode. If you're working with a version older than Delphi 2009, you should upgrade.

 

EDIT: You should also use SCAR defined types. Add this to the type section of your library:

 

[scar]TIntArray = array of Integer;

T2DIntArray = array of TIntArray;[/scar]

 

Replace "Array of Array of Integer" with "T2DIntArray" everywhere. Since "T2DIntArray" is already defined in SCAR, you don't need to export it.

 

Also make sure that you use an updated copy of FastShareMem for Delphi 2009+: http://svn.scar-divi.com/scar_shellutils/FastShareMem.pas

Edited by Freddy
Link to comment
Share on other sites

Alright I didn't know if I made types within my plugin the same as scar's types if I hadto export them or not. I was using t2dintarray but I didn't know why scar wasn't recognizing it.

 

---------- Post added 04-03-2012 at 06:05 AM ---------- Previous post was 04-02-2012 at 10:08 PM ----------

 

Since ive updated Delphi to 2009, and fastsharemem , i can not get scar to recognize any functions. The dll compiles fine. Im doing everything the same way i did in 2007. I deleted all references to the old fastsharemem .pas files and .dcu files. just to make sure it wasnt linking them instead. I also tried to use the old fastsharemem with 2009 but it gives a bunch of warnings when compiling so i know im not using the old fastsharemem. Im at a dead end.. Ive spent 6 hours messing with this.. i guess ill look at it tomorrow im tired.. anyone have any ideas on what could be the problem?

Edited by shadowrecon
Link to comment
Share on other sites

Everywhere you use "string", replace it with "AnsiString". Do the same for "PChar" and "PAnsiChar".

 

Yep thats the problem, because the "PChar" .. Thanks, wish i would of known that last night would of saved me 6 hours of time. err!

Your the man Freddy.

Edited by shadowrecon
Link to comment
Share on other sites

As I said before, you can use this as an example: http://svn.scar-divi.com/scar_shellutils/

Don't rely on outdated tutorials.

 

Yeah i rember you posting something about that a while back i really didnt understand the process then, im understanding it more and more now. Maybe when im done ill make a Tut so people dont waste there time doing the same mistakes ive done throughout this process.

Link to comment
Share on other sites

SCAR Divi 3.33 will come with a new library system (again), I miscalculated my future needs when I rewrote it the last time. I'll also be providing examples on how to create library. I'll still be supporting the old plugin architecture, I've even made some improvements to give it some additional power. But there will also be a new library architecture which should be better compatible with C++ among other things.

Link to comment
Share on other sites

Having the ability to use C++ to build lib will be pretty awesome.

 

Note:

I figured out why when i was using the scar type T2DIntArray i was getting an access violation, I was trying to use it as a dynamic array and i needed tomake it a static array and set the length of both arrays! =)

Link to comment
Share on other sites

Having the ability to use C++ to build lib will be pretty awesome.

 

Note:

I figured out why when i was using the scar type T2DIntArray i was getting an access violation, I was trying to use it as a dynamic array and i needed tomake it a static array and set the length of both arrays! =)

 

I can make C++ easier, but you'd still be able to do more with Delphi.

 

... T2DIntArray is dynamic

Link to comment
Share on other sites

I can make C++ easier, but you'd still be able to do more with Delphi.

 

... T2DIntArray is dynamic

The Delphi plugin system is pretty easy it's just difficult when you have no clue what scar is looking for. But I think ive got it down.

yeah, I don't know what I was thinking, I should of said my problem was because I wasn't setting array lengths.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...