www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - interface idispatch

reply "Miguel Ferreira Simões" <Kobold netcabo.pt> writes:
I am trying to call D classes from jscript.
The problem is that my knowledge in COM programming is null.
I have read some information and I guess that I have to implement the 
interface IDispatch.

Where can I get more information?
Can anyone give me a clue of how to do it...

Thanks.

-- 
Miguel Ferreira Simões 
Apr 12 2005
parent reply jicman <jicman_member pathlink.com> writes:
Miguel,

Here is a post from a few months back...

"http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/19426" 

I don't know what happened to it.  But, if you get any where with this, I would
love to see your work.  I have a few JSCript that I would love to transfer to D.
I could provide you with some of those, but again, they are JSCript programs.

buena suerte!

josé

Miguel Ferreira Simões says...
I am trying to call D classes from jscript.
The problem is that my knowledge in COM programming is null.
I have read some information and I guess that I have to implement the 
interface IDispatch.

Where can I get more information?
Can anyone give me a clue of how to do it...

Thanks.

-- 
Miguel Ferreira Simões 
Apr 12 2005
next sibling parent "Miguel F. Simões" <Kobold netcabo.pt> writes:
I will take a look.

Obrigado!
Miguel 
Apr 12 2005
prev sibling parent reply J C Calvarese <jcc7 cox.net> writes:
jicman wrote:
 Miguel,
 
 Here is a post from a few months back...
 
 "http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/19426" 
 
 I don't know what happened to it.  But, if you get any where with this, I would
 love to see your work.  I have a few JSCript that I would love to transfer to
D.
 I could provide you with some of those, but again, they are JSCript programs.
Yeah, it looked like Carlos was making progress getting generic ActiveX and/or COM to work. I suspect he either ran into an obstacle or just got side-tracked into another project. It also looked like John C understood the method Carlos was using. I was looking into getting it to work for myself, but I started running into missing Windows headers and I wasn't in the mood to hunt for them or recreate them.
 
 buena suerte!
 
 josé
 
 Miguel Ferreira Simões says...
 
I am trying to call D classes from jscript.
The problem is that my knowledge in COM programming is null.
I have read some information and I guess that I have to implement the 
interface IDispatch.

Where can I get more information?
Can anyone give me a clue of how to do it...

Thanks.

-- 
Miguel Ferreira Simões 
-- jcc7 http://jcc_7.tripod.com/d/
Apr 16 2005
next sibling parent jicman <jicman_member pathlink.com> writes:
Me too, JCC.  I tried to compile that piece of code and got into missing headers
and other things.  I would love to get a COM library that works with D.  Love
to!

jic

J C Calvarese says...
jicman wrote:
 Miguel,
 
 Here is a post from a few months back...
 
 "http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/19426" 
 
 I don't know what happened to it.  But, if you get any where with this, I would
 love to see your work.  I have a few JSCript that I would love to transfer to
D.
 I could provide you with some of those, but again, they are JSCript programs.
Yeah, it looked like Carlos was making progress getting generic ActiveX and/or COM to work. I suspect he either ran into an obstacle or just got side-tracked into another project. It also looked like John C understood the method Carlos was using. I was looking into getting it to work for myself, but I started running into missing Windows headers and I wasn't in the mood to hunt for them or recreate them.
 
 buena suerte!
 
 josé
 
 Miguel Ferreira Simões says...
 
I am trying to call D classes from jscript.
The problem is that my knowledge in COM programming is null.
I have read some information and I guess that I have to implement the 
interface IDispatch.

Where can I get more information?
Can anyone give me a clue of how to do it...

Thanks.

-- 
Miguel Ferreira Simões 
-- jcc7 http://jcc_7.tripod.com/d/
Apr 16 2005
prev sibling parent reply "Carlos Santander B." <csantander619 gmail.com> writes:
J C Calvarese wrote:
 
 Yeah, it looked like Carlos was making progress getting generic ActiveX 
 and/or COM to work. I suspect he either ran into an obstacle or just got 
 side-tracked into another project. It also looked like John C understood 
 the method Carlos was using. I was looking into getting it to work for 
 myself, but I started running into missing Windows headers and I wasn't 
 in the mood to hunt for them or recreate them.
 
A bit of both, actually. It needed a bit more of the time I could give it, at the moment. There were two parts I feel should be addressed: type checking, and getting rid of VARIANTARGs in client code. If anyone wants to do it, let me know and I'll send him what I have. If it works ok, I could use it for Walnut too. -- Carlos Santander Bernal JP2, you'll always live in our minds
Apr 17 2005
next sibling parent "Miguel F. Simoes" <Kobold netcabo.pt> writes:
 A bit of both, actually. It needed a bit more of the time I could give it, 
 at the moment. There were two parts I feel should be addressed: type 
 checking, and getting rid of VARIANTARGs in client code. If anyone wants 
 to do it, let me know and I'll send him what I have. If it works ok, I 
 could use it for Walnut too.
Can you send me, please. It would be great to have ActiveX and COM working! I know very little of COM interfaces and I doubt that I can make any progress with it... but I can try. Miguel.
Apr 17 2005
prev sibling parent reply J C Calvarese <jcc7 cox.net> writes:
Carlos Santander B. wrote:
 J C Calvarese wrote:
 Yeah, it looked like Carlos was making progress getting generic 
 ActiveX and/or COM to work. I suspect he either ran into an obstacle 
 or just got side-tracked into another project. It also looked like 
 John C understood the method Carlos was using. I was looking into 
 getting it to work for myself, but I started running into missing 
 Windows headers and I wasn't in the mood to hunt for them or recreate 
 them.
A bit of both, actually. It needed a bit more of the time I could give it, at the moment. There were two parts I feel should be addressed: type checking, and getting rid of VARIANTARGs in client code. If anyone wants to do it, let me know and I'll send him what I have. If it works ok, I could use it for Walnut too.
If you don't mind, I'd like a copy. I don't recall exactly what VARIANTARG's are, but maybe I can figure out how to remove them. I'd like to try to help. -- jcc7 http://jcc_7.tripod.com/d/
Apr 17 2005
parent reply "Carlos Santander B." <csantander619 gmail.com> writes:
J C Calvarese wrote:
 
 
 If you don't mind, I'd like a copy. I don't recall exactly what 
 VARIANTARG's are, but maybe I can figure out how to remove them. I'd 
 like to try to help.
 
I'm sending this to Justin, but I'd like to point something: I already sent the same to Miguel and previously to Robert Münch. John Chapman was also working on something similar. My proposal is, if all of you guys (and maybe even I when I have the time) are going to try to make some progress with this, how about setting up a small project in dsource just for this. All of you/us would be admins/moderators. This way, we'd avoid duplicate efforts. What do you guys think? -- Carlos Santander Bernal JP2, you'll always live in our minds
Apr 17 2005
next sibling parent reply J C Calvarese <jcc7 cox.net> writes:
Carlos Santander B. wrote:
 J C Calvarese wrote:
 
 If you don't mind, I'd like a copy. I don't recall exactly what 
 VARIANTARG's are, but maybe I can figure out how to remove them. I'd 
 like to try to help.
I'm sending this to Justin, but I'd like to point something: I already
I've got it. Thanks.
 sent the same to Miguel and previously to Robert Münch. John Chapman was 
 also working on something similar. My proposal is, if all of you guys 
 (and maybe even I when I have the time) are going to try to make some 
 progress with this, how about setting up a small project in dsource just 
 for this. All of you/us would be admins/moderators. This way, we'd avoid 
 duplicate efforts. What do you guys think?
A new project separate from Walnut? It's not that big of a project, is it? Maybe we should just post our future developments in the Walnut forum (so it doesn't get overlooked in the expansive Digital Mars newsgroups): http://www.dsource.org/forums/viewforum.php?f=51 -- jcc7 http://jcc_7.tripod.com/d/
Apr 17 2005
parent reply "Carlos Santander B." <csantander619 gmail.com> writes:
J C Calvarese wrote:
 
 A new project separate from Walnut? It's not that big of a project, is it?
 
 Maybe we should just post our future developments in the Walnut forum 
 (so it doesn't get overlooked in the expansive Digital Mars newsgroups): 
 http://www.dsource.org/forums/viewforum.php?f=51
 
Well, I thought it could be used for more than Walnut. I assume many will be needing it in the future. And there's also the issue about duplicated efforts. But I agree it wouldn't big enough, so I don't know. Whatever you (all of you) prefer. -- Carlos Santander Bernal JP2, you'll always live in our minds
Apr 17 2005
next sibling parent jicman <jicman_member pathlink.com> writes:
Carlos Santander B. says...
J C Calvarese wrote:
 
 A new project separate from Walnut? It's not that big of a project, is it?
 
 Maybe we should just post our future developments in the Walnut forum 
 (so it doesn't get overlooked in the expansive Digital Mars newsgroups): 
 http://www.dsource.org/forums/viewforum.php?f=51
 
Well, I thought it could be used for more than Walnut. I assume many will be needing it in the future. And there's also the issue about duplicated efforts. But I agree it wouldn't big enough, so I don't know. Whatever you (all of you) prefer.
I agree. Walnut is a different project. This IDispatch startup would be a different project altogher, though, Walnut could use it. Just a thought... jic
Apr 17 2005
prev sibling parent reply J C Calvarese <jcc7 cox.net> writes:
Carlos Santander B. wrote:
 J C Calvarese wrote:
 
 A new project separate from Walnut? It's not that big of a project, is 
 it?

 Maybe we should just post our future developments in the Walnut forum 
 (so it doesn't get overlooked in the expansive Digital Mars 
 newsgroups): http://www.dsource.org/forums/viewforum.php?f=51
Well, I thought it could be used for more than Walnut. I assume many will be needing it in the future. And there's also the issue about duplicated efforts. But I agree it wouldn't big enough, so I don't know. Whatever you (all of you) prefer.
I'm just doubtful that I can really add anything to this project (I think ActiveX is my personal kryptonite). And I'm already listed as member of at least three inactive projects at dsource: Core32, L8night, UnDig. I know there's no quota or anything, but I feel a little guilty about it. I'll try to help you and jic wherever you try to work on this (and I'll be more than a little interested in your progress), but this ActiveX/COM stuff just stymies me at every turn. For example, I thought this code might make it a little easier to use VARIANTARGs: VARIANTARG toVariant(...) { VARIANTARG myArg; if (_arguments[0] == typeid(char[])) { myArg.n1.n2.vt = VT_BSTR; myArg.n1.n2.n3.bstrVal = SysAllocString(va_arg!(wchar*)(_argptr)); } else throw new Exception("toVariant doesn't know what to do with it."); return myArg; } It compiles, but it generates an "Access Error" whenever I try to use it. I don't know what's wrong with it. It's probably something simple, but it just doesn't work. -- jcc7 http://jcc_7.tripod.com/d/
Apr 17 2005
parent reply Derek Parnell <derek psych.ward> writes:
On Sun, 17 Apr 2005 22:12:48 -0500, J C Calvarese wrote:

 Carlos Santander B. wrote:
 J C Calvarese wrote:
 
 A new project separate from Walnut? It's not that big of a project, is 
 it?

 Maybe we should just post our future developments in the Walnut forum 
 (so it doesn't get overlooked in the expansive Digital Mars 
 newsgroups): http://www.dsource.org/forums/viewforum.php?f=51
Well, I thought it could be used for more than Walnut. I assume many will be needing it in the future. And there's also the issue about duplicated efforts. But I agree it wouldn't big enough, so I don't know. Whatever you (all of you) prefer.
I'm just doubtful that I can really add anything to this project (I think ActiveX is my personal kryptonite). And I'm already listed as member of at least three inactive projects at dsource: Core32, L8night, UnDig. I know there's no quota or anything, but I feel a little guilty about it. I'll try to help you and jic wherever you try to work on this (and I'll be more than a little interested in your progress), but this ActiveX/COM stuff just stymies me at every turn. For example, I thought this code might make it a little easier to use VARIANTARGs: VARIANTARG toVariant(...) { VARIANTARG myArg; if (_arguments[0] == typeid(char[])) { myArg.n1.n2.vt = VT_BSTR; myArg.n1.n2.n3.bstrVal = SysAllocString(va_arg!(wchar*)(_argptr)); } else throw new Exception("toVariant doesn't know what to do with it."); return myArg; } It compiles, but it generates an "Access Error" whenever I try to use it. I don't know what's wrong with it. It's probably something simple, but it just doesn't work.
What is a "VARIANTARG"? Is it a class, struct, dynamic array, or what? Are you sure that "_arguments.length" is > 0 ? -- Derek Melbourne, Australia 18/04/2005 1:37:08 PM
Apr 17 2005
parent reply J C Calvarese <jcc7 cox.net> writes:
Derek Parnell wrote:
 On Sun, 17 Apr 2005 22:12:48 -0500, J C Calvarese wrote:
 
 
Carlos Santander B. wrote:

J C Calvarese wrote:


A new project separate from Walnut? It's not that big of a project, is 
it?

Maybe we should just post our future developments in the Walnut forum 
(so it doesn't get overlooked in the expansive Digital Mars 
newsgroups): http://www.dsource.org/forums/viewforum.php?f=51
Well, I thought it could be used for more than Walnut. I assume many will be needing it in the future. And there's also the issue about duplicated efforts. But I agree it wouldn't big enough, so I don't know. Whatever you (all of you) prefer.
I'm just doubtful that I can really add anything to this project (I think ActiveX is my personal kryptonite). And I'm already listed as member of at least three inactive projects at dsource: Core32, L8night, UnDig. I know there's no quota or anything, but I feel a little guilty about it. I'll try to help you and jic wherever you try to work on this (and I'll be more than a little interested in your progress), but this ActiveX/COM stuff just stymies me at every turn. For example, I thought this code might make it a little easier to use VARIANTARGs: VARIANTARG toVariant(...) { VARIANTARG myArg; if (_arguments[0] == typeid(char[])) { myArg.n1.n2.vt = VT_BSTR; myArg.n1.n2.n3.bstrVal = SysAllocString(va_arg!(wchar*)(_argptr)); } else throw new Exception("toVariant doesn't know what to do with it."); return myArg; } It compiles, but it generates an "Access Error" whenever I try to use it. I don't know what's wrong with it. It's probably something simple, but it just doesn't work.
What is a "VARIANTARG"? Is it a class, struct, dynamic array, or what?
It's a struct. (It's more frequently called "VARIANT".) Is that the problem?
 Are you sure that "_arguments.length" is > 0 ?
Yes, I just double checked. As I expected, there is one argument. -- jcc7 http://jcc_7.tripod.com/d/
Apr 17 2005
parent reply Derek Parnell <derek psych.ward> writes:
On Mon, 18 Apr 2005 00:23:00 -0500, J C Calvarese wrote:

 Derek Parnell wrote:
 On Sun, 17 Apr 2005 22:12:48 -0500, J C Calvarese wrote:
 
Carlos Santander B. wrote:

J C Calvarese wrote:


A new project separate from Walnut? It's not that big of a project, is 
it?

Maybe we should just post our future developments in the Walnut forum 
(so it doesn't get overlooked in the expansive Digital Mars 
newsgroups): http://www.dsource.org/forums/viewforum.php?f=51
Well, I thought it could be used for more than Walnut. I assume many will be needing it in the future. And there's also the issue about duplicated efforts. But I agree it wouldn't big enough, so I don't know. Whatever you (all of you) prefer.
I'm just doubtful that I can really add anything to this project (I think ActiveX is my personal kryptonite). And I'm already listed as member of at least three inactive projects at dsource: Core32, L8night, UnDig. I know there's no quota or anything, but I feel a little guilty about it. I'll try to help you and jic wherever you try to work on this (and I'll be more than a little interested in your progress), but this ActiveX/COM stuff just stymies me at every turn. For example, I thought this code might make it a little easier to use VARIANTARGs: VARIANTARG toVariant(...) { VARIANTARG myArg; if (_arguments[0] == typeid(char[])) { myArg.n1.n2.vt = VT_BSTR; myArg.n1.n2.n3.bstrVal = SysAllocString(va_arg!(wchar*)(_argptr)); } else throw new Exception("toVariant doesn't know what to do with it."); return myArg; } It compiles, but it generates an "Access Error" whenever I try to use it. I don't know what's wrong with it. It's probably something simple, but it just doesn't work.
What is a "VARIANTARG"? Is it a class, struct, dynamic array, or what?
It's a struct. (It's more frequently called "VARIANT".) Is that the problem?
 Are you sure that "_arguments.length" is > 0 ?
Yes, I just double checked. As I expected, there is one argument.
Can you post the definition of VARIANTARG? Also, if you are looking for typeid(char[]), why are you casting it as (wchar*) ? I have some similar code in one of my modules, but I code it as ... if (_arguments[0] is typeid(char[])) So maybe the problem is that you use "==" rather than "===" or "is" . -- Derek Melbourne, Australia 18/04/2005 3:29:56 PM
Apr 17 2005
parent reply J C Calvarese <jcc7 cox.net> writes:
Derek Parnell wrote:
 On Mon, 18 Apr 2005 00:23:00 -0500, J C Calvarese wrote:
 
 
Derek Parnell wrote:

On Sun, 17 Apr 2005 22:12:48 -0500, J C Calvarese wrote:


Carlos Santander B. wrote:


J C Calvarese wrote:



A new project separate from Walnut? It's not that big of a project, is 
it?

Maybe we should just post our future developments in the Walnut forum 
(so it doesn't get overlooked in the expansive Digital Mars 
newsgroups): http://www.dsource.org/forums/viewforum.php?f=51
Well, I thought it could be used for more than Walnut. I assume many will be needing it in the future. And there's also the issue about duplicated efforts. But I agree it wouldn't big enough, so I don't know. Whatever you (all of you) prefer.
I'm just doubtful that I can really add anything to this project (I think ActiveX is my personal kryptonite). And I'm already listed as member of at least three inactive projects at dsource: Core32, L8night, UnDig. I know there's no quota or anything, but I feel a little guilty about it. I'll try to help you and jic wherever you try to work on this (and I'll be more than a little interested in your progress), but this ActiveX/COM stuff just stymies me at every turn. For example, I thought this code might make it a little easier to use VARIANTARGs: VARIANTARG toVariant(...) { VARIANTARG myArg; if (_arguments[0] == typeid(char[])) { myArg.n1.n2.vt = VT_BSTR; myArg.n1.n2.n3.bstrVal = SysAllocString(va_arg!(wchar*)(_argptr)); } else throw new Exception("toVariant doesn't know what to do with it."); return myArg; } It compiles, but it generates an "Access Error" whenever I try to use it. I don't know what's wrong with it. It's probably something simple, but it just doesn't work.
What is a "VARIANTARG"? Is it a class, struct, dynamic array, or what?
It's a struct. (It's more frequently called "VARIANT".) Is that the problem?
Are you sure that "_arguments.length" is > 0 ?
Yes, I just double checked. As I expected, there is one argument.
Can you post the definition of VARIANTARG?
alias VARIANT VARIANTARG; Then you ask, "What's a VARIANT?" struct VARIANT { n1_t n1; }; Then you might ask, "What's a n1_t?" It gets kind of complicated. All of the details are in Core32. Here's file with the VARIANT definition: http://svn.dsource.org/svn/projects/core32/trunk/core32/win32/com/OAIDL.d
 Also, if you are looking for typeid(char[]), why are you casting it as
 (wchar*) ?
That's a good question. I think I need to cast it to a wchar* to satisfy SysAllocString, but I guess I should put in into a char[] first. Thanks to your incisive questioning, I came up with some code that doesn't produce an Access Error. Whether it's helpful to the ActiveX cause is something I'll have to wait to tommorrow to discover (it's now time for me to go to sleep). Thank you again for your help. VARIANTARG toVariant(...) { VARIANTARG myArg; writefln("%s", _arguments.length); if (_arguments[0] == typeid(char[])) { wchar* w = cast(wchar*) (va_arg!(char[])(_argptr) ~ "\0"); myArg.n1.n2.vt = VT_BSTR; myArg.n1.n2.n3.bstrVal = SysAllocString(w); } else throw new Exception("toVariant doesn't know what to do with it."); return myArg; } -- jcc7 http://jcc_7.tripod.com/d/
Apr 17 2005
parent reply Derek Parnell <derek psych.ward> writes:
On Mon, 18 Apr 2005 00:54:18 -0500, J C Calvarese wrote:

 Derek Parnell wrote:
[snip]
 Can you post the definition of VARIANTARG? 
alias VARIANT VARIANTARG; Then you ask, "What's a VARIANT?" struct VARIANT { n1_t n1; }; Then you might ask, "What's a n1_t?" It gets kind of complicated. All of the details are in Core32. Here's file with the VARIANT definition: http://svn.dsource.org/svn/projects/core32/trunk/core32/win32/com/OAIDL.d
Yuck! What a mess ;-)
 Also, if you are looking for typeid(char[]), why are you casting it as
 (wchar*) ?
That's a good question. I think I need to cast it to a wchar* to satisfy SysAllocString, but I guess I should put in into a char[] first.
If I recall correctly, casting a char[] to a wchar* does *not* convert the UTF8 string to a UTF16 string. So I think you might really need to do ... if (_arguments[0] is typeid(char[])) { wchar[] w = std.utf.toUTF16( (va_arg!(char[])(_argptr) ~ "\0"); myArg.n1.n2.vt = VT_BSTR; myArg.n1.n2.n3.bstrVal = SysAllocString(w.ptr); } -- Derek Melbourne, Australia 18/04/2005 4:35:52 PM
Apr 17 2005
parent J C Calvarese <jcc7 cox.net> writes:
In article <2bq10pgk5lks$.pjqtmq8tvk41.dlg 40tude.net>, Derek Parnell says...
On Mon, 18 Apr 2005 00:54:18 -0500, J C Calvarese wrote:

 Derek Parnell wrote:
[snip]
 Can you post the definition of VARIANTARG? 
alias VARIANT VARIANTARG; Then you ask, "What's a VARIANT?" struct VARIANT { n1_t n1; }; Then you might ask, "What's a n1_t?" It gets kind of complicated. All of the details are in Core32. Here's file with the VARIANT definition: http://svn.dsource.org/svn/projects/core32/trunk/core32/win32/com/OAIDL.d
Yuck! What a mess ;-)
I agree. Isn't Windows well-designed?
 Also, if you are looking for typeid(char[]), why are you casting it as
 (wchar*) ?
That's a good question. I think I need to cast it to a wchar* to satisfy SysAllocString, but I guess I should put in into a char[] first.
If I recall correctly, casting a char[] to a wchar* does *not* convert the UTF8 string to a UTF16 string. So I think you might really need to do ... if (_arguments[0] is typeid(char[])) { wchar[] w = std.utf.toUTF16( (va_arg!(char[])(_argptr) ~ "\0"); myArg.n1.n2.vt = VT_BSTR; myArg.n1.n2.n3.bstrVal = SysAllocString(w.ptr); }
Oops. I'm sure you're right. I think I'm trying to mess up everything that can be messed up. jcc7
Apr 18 2005
prev sibling parent reply "Carlos Santander B." <csantander619 gmail.com> writes:
Carlos Santander B. wrote:
 
 I'm sending this to Justin, but I'd like to point something: I already 
 sent the same to Miguel and previously to Robert Münch. John Chapman was 
 also working on something similar. My proposal is, if all of you guys 
 (and maybe even I when I have the time) are going to try to make some 
 progress with this, how about setting up a small project in dsource just 
 for this. All of you/us would be admins/moderators. This way, we'd avoid 
 duplicate efforts. What do you guys think?
 
I uploaded it to dsource. It's in http://svn.dsource.org/svn/projects/walnut/downloads/some_other_things/ -- Carlos Santander Bernal JP2, you'll always live in our minds
Apr 18 2005
parent "Miguel F. Simoes" <Kobold netcabo.pt> writes:
 I uploaded it to dsource. It's in 
 http://svn.dsource.org/svn/projects/walnut/downloads/some_other_things/
That's a good idea. If more people have access to the code... the result will probably better.
Apr 19 2005