C++ api question

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

C++ api question

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:20 pm

by tim >> Sat, 26 Jul 2008 1:28:10 GMT

hi im having trouble returning a binary. the code im using is to calc ttf checksum like the example here about half way down the page

www.microsoft.com/typography/otspec/otff.htm

im not getting back any value from this:


extern "C" DllExport int JOMAPI
ttfCheckSum(DskBuffer* pBuffer, DskParam* pParams, DskParam* pReturn)
{
BYTE *data;
Size length;
ULONG *table;
ULONG sum = 0;
paramGetBinary(*pParams,data,length);
//if((length % 4) != 0) return 0;
table = (ULONG*)data;
ULONG Sum = 0L;
ULONG *endptr = table+((length+3) & ~3) / sizeof(ULONG);
while(table < endptr)
{
sum += *table++;
}
sum++; //just to check if above code does anything but this is still returning 00000000
return paramSetBinaryData(*pReturn,(BYTE*)∑,sizeof(ULONG));
}

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: C++ api question

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:21 pm

by Allistar >> Sun, 27 Jul 2008 23:11:24 GMT

Hi Tim,
You seem to be defining "sum" and "Sum" in your external method - I cannot see which is being passed into paramSetBinaryData - is it the right one?

Allistar.
--
A.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: C++ api question

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:21 pm

by tim >> Mon, 28 Jul 2008 10:11:05 GMT

i dont know why i had the extra sum there or why there is that sum smbol there on the last line (as i see in firefox3) bcos it shouldn't have been interpreted without the semi colon. here it is again.


extern "C" DllExport int JOMAPI
ttfCheckSum(DskBuffer* pBuffer, DskParam* pParams, DskParam* pReturn)
{
BYTE *data;
Size length;
ULONG *table;
ULONG sum = 0;
paramGetBinary(*pParams,data,length);
//if((length % 4) != 0) return 0;
table = (ULONG*)data;
ULONG *endptr = table+((length+3) & ~3) / sizeof(ULONG);
while(table < endptr)
{
sum += *table++;
}
sum++; //just to check if above code does anything but this is still returning 00000000
return paramSetBinary(*pReturn,(BYTE*)&sum,sizeof(ULONG));
}

I don't understand the usage of this completely and couldn't find anything of documentation on it. should i be using

paramCreateJadeBinary
paramSetBinary
paramSetBinaryBlock
paramSetBinaryData
JADE_SET_BINARY

lots to choose from but still couldn't get a return value.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: C++ api question

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:21 pm

by Allistar >> Mon, 28 Jul 2008 20:31:58 GMT

Can you post the definition of the external method as you see it in Jade? --
A.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: C++ api question

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:21 pm

by tim >> Tue, 29 Jul 2008 2:22:22 GMT

just pass in one binary and return one like this:

ttfCheckSum(data : Binary) : Binary is ttfCheckSum in fonts;

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: C++ api question

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:21 pm

by Allistar >> Wed, 30 Jul 2008 1:11:20 GMT

Sorry, I can't see anything obviously wrong with that code. Can you confirm that it executes the paramSetBinary method and the the return value of it is "0"?
--
A.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: C++ api question

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:21 pm

by tim >> Thu, 31 Jul 2008 2:39:51 GMT

yeah I don't understand it and I will look into it in more detail but first could you please explain me the differnce between those functions.

paramCreateJadeBinary
paramSetBinary
paramSetBinaryBlock
paramSetBinaryData
JADE_SET_BINARY


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests