ExternalArray of Strings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

ExternalArray of Strings

Günther Schmidt
Hi,

how do I assemble an ExternalArray of Strings to pass it to a C function?

Günther


Reply | Threaded
Open this post in threaded view
|

Re: ExternalArray of Strings

Schwab,Wilhelm K
Günther,

> how do I assemble an ExternalArray of Strings to pass it to a C function?

Most C functions that I have seen do this via one string of characters
with single nulls to terminate/separate the strings, and two nulls in a
row to mark the end of the array.

The following (untested!!) should do more or less what I described:

| out |
out := ByteArray writeStream.
someStrings do:[ :each |
    out nextPutAll:each asByteArray; nextPut:0.
].
out nextPut:0.

It is also possible to pass an array of addresses of individual buffers.
  It all depends on what the function expects.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: ExternalArray of Strings

Günther Schmidt
Bill,

thanks, I don't think that would be working though.

This is a description of the function:

Function: xsltApplyStylesheet

xmlDocPtr xsltApplyStylesheet (xsltStylesheetPtr style,
                                         xmlDocPtr doc,
                                         const char ** params)

Apply the stylesheet to the document NOTE: This may lead to a
non-wellformed output XML wise !
style: a parsed XSLT stylesheet
doc: a parsed XML document
params: a NULL terminated arry of parameters names/values tuples
Returns: the result document or NULL in case of error



where "> const char ** params)"

is the unresolved part


I'm just reading a 900 pages book about the C language and
am so grateful I don't usually have to deal with C.


Günther



Bill Schwab schrieb:

> Günther,
>
>> how do I assemble an ExternalArray of Strings to pass it to a C function?
>
>
> Most C functions that I have seen do this via one string of characters
> with single nulls to terminate/separate the strings, and two nulls in a
> row to mark the end of the array.
>
> The following (untested!!) should do more or less what I described:
>
> | out |
> out := ByteArray writeStream.
> someStrings do:[ :each |
>    out nextPutAll:each asByteArray; nextPut:0.
> ].
> out nextPut:0.
>
> It is also possible to pass an array of addresses of individual buffers.
>  It all depends on what the function expects.
>
> Have a good one,
>
> Bill
>


Reply | Threaded
Open this post in threaded view
|

Re: ExternalArray of Strings

Schwab,Wilhelm K
Günther,

> This is a description of the function:
>
> Function: xsltApplyStylesheet
>
> xmlDocPtr    xsltApplyStylesheet    (xsltStylesheetPtr style,
>                      xmlDocPtr doc,
>                      const char ** params)
>
> Apply the stylesheet to the document NOTE: This may lead to a
> non-wellformed output XML wise !
> style:    a parsed XSLT stylesheet
> doc:    a parsed XML document
> params:    a NULL terminated arry of parameters names/values tuples
> Returns:    the result document or NULL in case of error
>
> where "> const char ** params)"
>
> is the unresolved part

It sounds like an array of pointers to the "strings" with a null in the
last slot so they can tell when to quit.  One way to do that would be to
build a DWORD aray by sending #yourAddress to each of the string/value
tuples.  That assumes that a tuple is a String, which it almost has to
be given their definition.  You will need to uncover their syntax; it is
probably either name=value, something more natural to XML, % encoding,
etc.  Do you have any examples?

With anything like this, get your image ready to make the call, save
(before you actually evaluate the expression), and then have fun.  It's
a good idea to make a backup just in case things melt down or you
acidentally save when you shouldn't.

Remember to hang onto the strings/tuples themselves.  If you keep a
reference to only their addresses, they will likely be gc'd with bad
results when the DLL tries to access the memory.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: ExternalArray of Strings

Udo Schneider
Bill Schwab wrote:

>> xmlDocPtr    xsltApplyStylesheet    (xsltStylesheetPtr style,
>>                      xmlDocPtr doc,
>>                      const char ** params)
> It sounds like an array of pointers to the "strings" with a null in the
> last slot so they can tell when to quit.  One way to do that would be to
> build a DWORD aray by sending #yourAddress to each of the string/value
> tuples.  That assumes that a tuple is a String, which it almost has to
> be given their definition.  You will need to uncover their syntax; it is
> probably either name=value, something more natural to XML, % encoding,
> etc.  Do you have any examples?

Günther,

are you wrapping the library manually? If my assumption is correct the
XSLT library contains a "few more" functions, structures and constants.
You might consider transforming the header files in IDL and then let the
AXTypeLibraryAnalyzer do the hard work for you ...

CU,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: ExternalArray of Strings

Günther Schmidt
Hi Udo,

happy new year!

I would love to do that if I only had the slightest idea how.

Günther

Udo Schneider schrieb:

> Bill Schwab wrote:
>
>>> xmlDocPtr    xsltApplyStylesheet    (xsltStylesheetPtr style,
>>>                      xmlDocPtr doc,
>>>                      const char ** params)
>>
>> It sounds like an array of pointers to the "strings" with a null in
>> the last slot so they can tell when to quit.  One way to do that would
>> be to build a DWORD aray by sending #yourAddress to each of the
>> string/value tuples.  That assumes that a tuple is a String, which it
>> almost has to be given their definition.  You will need to uncover
>> their syntax; it is probably either name=value, something more natural
>> to XML, % encoding, etc.  Do you have any examples?
>
>
> Günther,
>
> are you wrapping the library manually? If my assumption is correct the
> XSLT library contains a "few more" functions, structures and constants.
> You might consider transforming the header files in IDL and then let the
> AXTypeLibraryAnalyzer do the hard work for you ...
>
> CU,
>
> Udo


Reply | Threaded
Open this post in threaded view
|

Re: ExternalArray of Strings

Udo Schneider
Günther Schmidt wrote:
> I would love to do that if I only had the slightest idea how.
There was an Article on the Dolphin Wiki called
"CreatingTLBfromaCheaderFile"
(http://www.object-arts.co.uk/wiki/html/Dolphin/CreatingTLBfromaCheaderFile.htm)
which is not available anymore. Try the cached version:
http://66.102.7.104/search?q=cache:9hGjjcF_GJMJ:www.object-arts.co.uk/wiki/html/Dolphin/CreatingTLBfromaCheaderFile.htm+CreatingTLBfromaCheaderFile++&hl=en&client=firefox-a

CU,

Udo