* Help!!! (Variable arguments list)
@ 1998-06-06 0:00 Adrian BY, Hoe
1998-06-07 0:00 ` Adrian BY, Hoe
0 siblings, 1 reply; 2+ messages in thread
From: Adrian BY, Hoe @ 1998-06-06 0:00 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 3950 bytes --]
I have an Ada package written to interface to a database API which is, I
believe in C/C++. In the main, I have managed attaching the newdb
(db_handle) to an existing database with success! Then, I tried to pass
the newdb (db_handle) as a variable arguments list in function
d_start_transaction. An error was raised by the API stating that invalid
database handle (no active transaction). Under this circumstance, only a
null or invalid db_handle will raise this error. I have try to count the
number of arguments passed using Stdarg.Impl.ArgCount (args). It returns
3 (in this case was newdb'Unchecked_Access & tpb_length & tpb_address).
I can't figure out what is wrong with my code. It has perfect
compilation and runs well. I am suspecting the newdb'Unchecked_Access
was not passed correctly. Can someone help?
In C/C++ the syntax of isc_start_transaction() is :
ISC_STATUS isc_start_transaction(
ISC_STATUS *status_vector,
isc_tr_handle *trans_handle,
short db_handle_count, ...);
where ... is
isc_db_handle *db_handle,
unsigned short tpb_length,
char *tpb_address,
[isc_db_handle *db_handle,
unsigned short tpb_length,
char *tpb_address ...]);
My code is as below:
with Ada.Unchecked_Conversion;
with Stdarg;
with Interfaces;
with Interfaces.C;
with System;
package database is
type Void is null record;
subtype PVoid is System.Address;
subtype Long is Interfaces.C.Long;
type Long_Array is array (Natural range <>) of
aliased Long;
subtype Unsigned_long is Interfaces.C.Unsigned_Long;
subtype D_LONG is Long;
subtype D_UNSIGNED_LONG is Unsigned_Long;
subtype D_STATUS is Long;
type PD_STATUS is access all D_STATUS;
type D_STATUS_Array is array (Natural range <>) of
aliased D_STATUS;
subtype db_handle is PVoid;
subtype tr_handle is PVoid;
type Pdb_handle is access all db_handle;
...
function To_Char is new Ada.Unchecked_Conversion (Integer, Char);
function "&" is new Stdarg.Concat (Pdb_handle);
function "&" is new Stdarg.Concat (PChar);
function "&" is new Stdarg.Concat (Unsigned_Short);
function "&" is new Stdarg.Concat (Short);
...
function d_start_transaction (status_vector : access D_STATUS;
trans_handle : access tr_handle;
db_handle_count : Short;
args : Stdarg.Arglist :=
Stdarg.Empty) return D_STATUS;
private
...
pragma Import (Cdecl, d_start_transaction, "isc_start_transaction");
...
end database;
-----------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Interfaces.C; use Interfaces;
with Stdarg;
with Win32;
with ibase; use ibase;
procedure main is
newdb : aliased db_handle;
trans : aliased tr_handle;
status : aliased D_STATUS_Array (0..19);
sqlcode : D_LONG;
temp : D_STATUS;
tpb_length : Unsigned_Short := 0;
tpb_address : PChar := NULL;
begin
...
temp := d_start_transaction (status status'First)'Unchecked_Access,
trans'Unchecked_Access,
1,
Stdarg.Empty &
newdb'Unchecked_Access &
tpb_length &
tpb_address);
...
end main;
--------------------------------
--
BY Hoe byhoe.lexical@technologist.com
VP R&D (ES/IS Group) lexical@tm.net.my
Lexical Integration (M) Sdn Bhd http://www.angelfire.com/biz/Lexical
[-- Attachment #2: Card for Adrian BY, Hoe --]
[-- Type: text/x-vcard, Size: 340 bytes --]
begin: vcard
fn: Adrian BY, Hoe
n: Hoe;Adrian BY,
org: Lexical Integration (M) Sdn Bhd <http://www.angelfire.com/biz/Lexical>
email;internet: byhoe.lexical@technologist.com
title: VP, R&D (ES/IS Group)
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Help!!! (Variable arguments list)
1998-06-06 0:00 Help!!! (Variable arguments list) Adrian BY, Hoe
@ 1998-06-07 0:00 ` Adrian BY, Hoe
0 siblings, 0 replies; 2+ messages in thread
From: Adrian BY, Hoe @ 1998-06-07 0:00 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]
Adrian BY, Hoe wrote:
>
> I have an Ada package written to interface to a database API which is, I
> believe in C/C++. In the main, I have managed attaching the newdb
> (db_handle) to an existing database with success! Then, I tried to pass
> the newdb (db_handle) as a variable arguments list in function
> d_start_transaction. An error was raised by the API stating that invalid
> database handle (no active transaction). Under this circumstance, only a
> null or invalid db_handle will raise this error. I have try to count the
> number of arguments passed using Stdarg.Impl.ArgCount (args). It returns
> 3 (in this case was newdb'Unchecked_Access & tpb_length & tpb_address).
>
Since, there is no reply yet, I would like to add/correct some
information.
Of, prior to calling the d_start_transaction function, I have called the
d_attach_database to obtain the newdb (db_handle) with success. The
db_handle has been passed to other functions as well which return
expected results. I/we can rule out that the db_handle, newdb, was not
assigned properly.
In procedure main, correct with ibase; use ibase; to
with database; use database;
My question is,
Is the pointer to db_handle of type PVOID (void *, in C/C++) passed
correctly with my implementation: function "&" is new Stdarg.Concat
(Pdb_handle); and Stdarg.Empty & newdb'Unchecked_Access & tpb_length &
tpb_address in d_start_transaction?
Please help!
--
BY Hoe byhoe.lexical@technologist.com
VP R&D (ES/IS Group) lexical@tm.net.my
Lexical Integration (M) Sdn Bhd http://www.angelfire.com/biz/Lexical
[-- Attachment #2: Card for Adrian BY, Hoe --]
[-- Type: text/x-vcard, Size: 341 bytes --]
begin: vcard
fn: Adrian BY, Hoe
n: Hoe;Adrian BY,
org: Lexical Integration (M) Sdn Bhd <http://www.angelfire.com/biz/Lexical>
email;internet: byhoe.lexical@technologist.com
title: VP, R&D (ES/IS Group)
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
[-- Attachment #3: Card for Adrian BY, Hoe --]
[-- Type: text/x-vcard, Size: 340 bytes --]
begin: vcard
fn: Adrian BY, Hoe
n: Hoe;Adrian BY,
org: Lexical Integration (M) Sdn Bhd <http://www.angelfire.com/biz/Lexical>
email;internet: byhoe.lexical@technologist.com
title: VP, R&D (ES/IS Group)
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1998-06-07 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-06 0:00 Help!!! (Variable arguments list) Adrian BY, Hoe
1998-06-07 0:00 ` Adrian BY, Hoe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox