Christian Schmitz wrote:
> Tim Jones <tjmac at tolisgroup dot com> wrote:
>
>
>> Thanks Christian. Since 'r' is going to be modified by the algorithm,
>> shouldn't the entry be "ByRef r As MemoryBlock"?
>>
>
> do you modify the reference or the content?
> Byref is to modify the reference.
> e.g. to assign a new memoryblock to it in the function.
>
Ah, since I'm modifying the content, I shouldn't use ByRef in the
definition. But, will I need to use ByRef in the call from RB as I do
if calling a shared library declare?
> Also, am I using the
> correct identifier for this type of function (accept 3 memoryblocks,
> modify the contents of the 3rd) when I use "REALNoImplementation"?
>
>
> looks correct.
>
>
>> The change above works and my ModularExp() method nows autocompletes in
>> the IDE editor - however, the helper text does not show up in the IDE's
>> status bar.
>>
>
> You will get used to it.
>
Oh, another of *THOSE* quirky things ...
>
>
>>
>> I get a hard crash.
>>
>
> your C function is not declared to take REALmemoryblocks.
>
Ah, so my current function call code looks like:
void ModularExp(unsigned short *base,
unsigned short *power,
unsigned short *result)
and the actual module's code expects pointers to 3 arrays of 64 unsigned
shorts. When I look up the type definition for REALmemoryBlock, I can't
find a typedef, so I should assume that, in this case, a REALmemoryBlock
is just a struct? What should be changed from normal C code to enable
the memoryblock manipulation?
Here's the entire function in C. The arrays "one[]" and "exp[]" are
predefined arrays of 64 unsigned shorts. And the variable BIGNUM_SHORTS
is 64.
void ModularExp(unsigned short *base, unsigned short *power, unsigned
short *result) {
unsigned short z, sqr[BIGNUM_SHORTS], exp[BIGNUM_SHORTS];
int i;
for(i=0; i<BIGNUM_SHORTS; i++) {
result[i] = one[i];
exp[i] = power[i];
}
modular_product(base, one, sqr);
for(;;) {
if (exp[0] & 1)
montgomery_reduction(sqr, result, result);
z = 0;
for(i=0; i<BIGNUM_SHORTS-1; i++) {
exp[i] = (exp[i] >> 1) | ((exp[i+1] & 1) << 15);
z |= exp[i];
}
exp[BIGNUM_SHORTS-1] >>= 1;
z |= exp[BIGNUM_SHORTS-1];
if (z == 0)
break;
montgomery_reduction(sqr, sqr, sqr);
}
modular_product(result, rp, result);
}
Am I just going to modify the calling parameters and then deal with the
arrays internally as I do in the normal C program, or are the required
changes going to move into my other functions as well?
Thanks,
Tim
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
From Tue 23 Oct 2007 20:13:07 +0200
Return-Path: <realbasic-plugins-bounces at lists dot realsoftware dot com>
X-Original-To: listarchive at realsoftware dot com
Delivered-To: listarchive at realsoftware dot com
Received: by xmail.realsoftware.com (Postfix, from userid 1037)
id 497CA490CE62; Tue, 23 Oct 2007 11:13:30 -0700 (PDT)
X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on
www.realsoftware.com
X-Spam-Level:
X-Spam-Status: No, score=-2.5 required=4.5 tests=AWL,BAYES_00 autolearn=ham
version=3.1.1
Received: from lists.realsoftware.com (m.realsoftware.com [66.116.103.65])
by xmail.realsoftware.com (Postfix) with ESMTP id 1521E490CE4A;
Tue, 23 Oct 2007 11:13:15 -0700 (PDT)
Received: from real-software-mini.local (localhost [127.0.0.1])
by lists.realsoftware.com (Postfix) with ESMTP id D255F811D9B;
Tue, 23 Oct 2007 13:12:54 -0500 (CDT)
X-Original-To: realbasic-plugins at lists dot realsoftware dot com
Delivered-To: realbasic-plugins at lists dot realsoftware dot com
Received: from smtprelay06.ispgateway.de (smtprelay06.ispgateway.de
[80.67.18.44])
by lists.realsoftware.com (Postfix) with ESMTP id DCA46811D90
for <realbasic-plugins at lists dot realsoftware dot com>;
Tue, 23 Oct 2007 13:12:50 -0500 (CDT)
Received: (qmail 30841 invoked from network); 23 Oct 2007 18:13:07 -0000
Received: from unknown (HELO [192.168.1.80]) (363246 at [84 dot 175 dot 98 dot
215])
(envelope-sender <support at monkeybreadsoftware dot de>)
by smtprelay06.ispgateway.de (qmail-ldap-1.03) with SMTP
for <realbasic-plugins at lists dot realsoftware dot com>;
23 Oct 2007 18:13:07 -0000
To: realbasic-plugins at lists dot realsoftware dot com (REALbasic Plugins)
In-Reply-To: <471E3757 dot 6070806 at tolisgroup dot com>
Subject: Re: Proper declares request
From: support at monkeybreadsoftware dot de (Christian Schmitz)
Date: Tue, 23 Oct 2007 20:13:07 +0200
Message-ID: <1i6gdf2 dot y4kh631yn1jz9M%support at monkeybreadsoftware dot de>
MIME-Version: 1.0
Organization: Monkeybread Software Germany
X-Face: nrf3>{WQ6c&r+7 at e)"]0G60`-6ND^)I2mI%>)QGYa=9"=7jhd-g2|b3!>Al0+
Ccb%xGQshhi|g at QU2$
User-Agent: MacSOUP/D-2.8 (Mac OS X version 10.4.9 (PPC))
X-BeenThere: realbasic-plugins at lists dot realsoftware dot com
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot
com>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Sender: realbasic-plugins-bounces at lists dot realsoftware dot com
Errors-To: realbasic-plugins-bounces at lists dot realsoftware dot com
Tim Jones <tjmac at tolisgroup dot com> wrote:
> Ah, since I'm modifying the content, I shouldn't use ByRef in the =
> definition. But, will I need to use ByRef in the call from RB as I do
> if calling a shared library declare?
I'm not sure if you know exactly what byref means.
Maybe you check some webpages about it.
> and the actual module's code expects pointers to 3 arrays of 64 unsigned
> shorts. When I look up the type definition for REALmemoryBlock, I can't
> find a typedef, so I should assume that, in this case, a REALmemoryBlock
> is just a struct? =
REALmemoryBlock is a pointer to a structure.
The SDK has a function to ask thre memoryblock for the pointer.
the pointer can be casted to a (short*) pointer.
Gru=DF
Christian
-- =
Over 900 classes with 17000 functions in one REALbasic plug-in. =
The Monkeybread Software Realbasic Plugin v7.6. =
<http://www.monkeybreadsoftware.de/realbasic/plugins.shtml>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|