compile fix
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4002 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
// Created: 01/02/97
|
// Created: 01/02/97
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
// Copyright: (c) Julian Smart and Markus Holzem
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "wx/setup.h"
|
#include "wx/setup.h"
|
||||||
@@ -25,19 +25,22 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __UNIX__
|
||||||
extern "C" {
|
extern "C"
|
||||||
#include "../../src/iodbc/isql.h"
|
{
|
||||||
#include "../../src/iodbc/isqlext.h"
|
#include "../../src/iodbc/isql.h"
|
||||||
#include "../../src/iodbc/odbc_funcs.h"
|
#include "../../src/iodbc/isqlext.h"
|
||||||
#include "../../src/iodbc/odbc_types.h"
|
#include "../../src/iodbc/odbc_funcs.h"
|
||||||
typedef float SFLOAT;
|
#include "../../src/iodbc/odbc_types.h"
|
||||||
typedef double SDOUBLE;
|
|
||||||
#define ULONG UDWORD
|
typedef float SFLOAT;
|
||||||
|
typedef double SDOUBLE;
|
||||||
|
|
||||||
|
#define ULONG UDWORD
|
||||||
}
|
}
|
||||||
#else
|
#else // !Unix
|
||||||
#include <sqlext.h>
|
#include <sqlext.h>
|
||||||
#endif
|
#endif // Unix/!Unix
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
@@ -60,13 +63,11 @@ class WXDLLEXPORT wxRecordSet;
|
|||||||
|
|
||||||
class WXDLLEXPORT wxDatabase: public wxObject
|
class WXDLLEXPORT wxDatabase: public wxObject
|
||||||
{
|
{
|
||||||
// JACS
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxDatabase)
|
DECLARE_DYNAMIC_CLASS(wxDatabase)
|
||||||
private:
|
|
||||||
protected:
|
protected:
|
||||||
static HENV hEnv;
|
static HENV hEnv;
|
||||||
static int refCount;
|
static int refCount;
|
||||||
|
|
||||||
HDBC hDBC;
|
HDBC hDBC;
|
||||||
char* username;
|
char* username;
|
||||||
char* password;
|
char* password;
|
||||||
@@ -83,19 +84,19 @@ class WXDLLEXPORT wxDatabase: public wxObject
|
|||||||
bool err_occured;
|
bool err_occured;
|
||||||
|
|
||||||
wxList recordSets; // Record sets: Added by JACS
|
wxList recordSets; // Record sets: Added by JACS
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxDatabase(void);
|
wxDatabase();
|
||||||
~wxDatabase(void);
|
~wxDatabase();
|
||||||
|
|
||||||
bool Open(char *, bool exclusive =FALSE, bool readOnly =TRUE, char *username ="ODBC", char *password ="");
|
bool Open(char *, bool exclusive =FALSE, bool readOnly =TRUE, char *username ="ODBC", char *password ="");
|
||||||
bool Close(void);
|
bool Close();
|
||||||
|
|
||||||
// Cleanup operations, added by JACS
|
// Cleanup operations, added by JACS
|
||||||
void DeleteRecordSets(void); // Called when the database is deleted
|
void DeleteRecordSets(void); // Called when the database is deleted
|
||||||
void ResetRecordSets(void); // Required if the database is closed
|
void ResetRecordSets(void); // Required if the database is closed
|
||||||
inline wxList& GetRecordSets(void) { return recordSets; }
|
inline wxList& GetRecordSets(void) { return recordSets; }
|
||||||
|
|
||||||
inline char *GetUsername(void) { return username; }
|
inline char *GetUsername(void) { return username; }
|
||||||
inline char *GetPassword(void) { return password; }
|
inline char *GetPassword(void) { return password; }
|
||||||
inline char *GetDataSource(void) { return datasource; }
|
inline char *GetDataSource(void) { return datasource; }
|
||||||
@@ -103,31 +104,31 @@ class WXDLLEXPORT wxDatabase: public wxObject
|
|||||||
inline wxRETCODE GetErrorCode(void) { return retcode; }
|
inline wxRETCODE GetErrorCode(void) { return retcode; }
|
||||||
inline HDBC GetHDBC(void) { return hDBC; }
|
inline HDBC GetHDBC(void) { return hDBC; }
|
||||||
inline HENV GetHENV(void) { return hEnv; }
|
inline HENV GetHENV(void) { return hEnv; }
|
||||||
|
|
||||||
void SetPassword(char *s);
|
void SetPassword(char *s);
|
||||||
void SetUsername(char *s);
|
void SetUsername(char *s);
|
||||||
void SetDataSource(char *s);
|
void SetDataSource(char *s);
|
||||||
|
|
||||||
// Database attributes
|
// Database attributes
|
||||||
char *GetDatabaseName(void);
|
char *GetDatabaseName();
|
||||||
bool CanUpdate(void);
|
bool CanUpdate();
|
||||||
bool CanTransact(void);
|
bool CanTransact();
|
||||||
bool InWaitForDataSource(void);
|
bool InWaitForDataSource();
|
||||||
void SetLoginTimeout(long seconds);
|
void SetLoginTimeout(long seconds);
|
||||||
void SetQueryTimeout(long seconds);
|
void SetQueryTimeout(long seconds);
|
||||||
void SetSynchronousMode(bool synchronous);
|
void SetSynchronousMode(bool synchronous);
|
||||||
|
|
||||||
// Database operations
|
// Database operations
|
||||||
bool BeginTrans(void);
|
bool BeginTrans();
|
||||||
bool CommitTrans(void);
|
bool CommitTrans();
|
||||||
bool RollbackTrans(void);
|
bool RollbackTrans();
|
||||||
void Cancel(void);
|
void Cancel();
|
||||||
|
|
||||||
// Error handling
|
// Error handling
|
||||||
bool ErrorOccured(void);
|
bool ErrorOccured();
|
||||||
char* GetErrorMessage(void);
|
char* GetErrorMessage();
|
||||||
long GetErrorNumber(void);
|
long GetErrorNumber();
|
||||||
char* GetErrorClass(void);
|
char* GetErrorClass();
|
||||||
inline void ErrorSnapshot(HSTMT =SQL_NULL_HSTMT);
|
inline void ErrorSnapshot(HSTMT =SQL_NULL_HSTMT);
|
||||||
|
|
||||||
// Overridables
|
// Overridables
|
||||||
@@ -154,23 +155,23 @@ class WXDLLEXPORT wxQueryField: public wxObject
|
|||||||
long size;
|
long size;
|
||||||
bool dirty;
|
bool dirty;
|
||||||
|
|
||||||
bool AllocData(void);
|
bool AllocData();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxQueryField(void);
|
wxQueryField();
|
||||||
~wxQueryField(void);
|
~wxQueryField();
|
||||||
|
|
||||||
bool SetData(void*, long);
|
bool SetData(void*, long);
|
||||||
void SetDirty(bool =TRUE);
|
void SetDirty(bool =TRUE);
|
||||||
void ClearData(void);
|
void ClearData();
|
||||||
void SetType(short);
|
void SetType(short);
|
||||||
void SetSize(long);
|
void SetSize(long);
|
||||||
|
|
||||||
void* GetData(void);
|
void* GetData();
|
||||||
short GetType(void);
|
short GetType();
|
||||||
long GetSize(void);
|
long GetSize();
|
||||||
|
|
||||||
bool IsDirty(void);
|
bool IsDirty();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Represents a column description
|
// Represents a column description
|
||||||
@@ -184,13 +185,13 @@ class WXDLLEXPORT wxQueryCol: public wxObject
|
|||||||
bool nullable;
|
bool nullable;
|
||||||
long varsize;
|
long varsize;
|
||||||
void* var;
|
void* var;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxList fields;
|
wxList fields;
|
||||||
|
|
||||||
wxQueryCol(void);
|
wxQueryCol();
|
||||||
~wxQueryCol(void);
|
~wxQueryCol();
|
||||||
|
|
||||||
void* BindVar(void*, long);
|
void* BindVar(void*, long);
|
||||||
void FillVar(int);
|
void FillVar(int);
|
||||||
void AppendField(void*, long);
|
void AppendField(void*, long);
|
||||||
@@ -199,10 +200,10 @@ class WXDLLEXPORT wxQueryCol: public wxObject
|
|||||||
void SetNullable(bool);
|
void SetNullable(bool);
|
||||||
void SetFieldDirty(int, bool =TRUE);
|
void SetFieldDirty(int, bool =TRUE);
|
||||||
void SetType(short);
|
void SetType(short);
|
||||||
|
|
||||||
char* GetName(void);
|
char* GetName();
|
||||||
short GetType(void);
|
short GetType();
|
||||||
bool IsNullable(void);
|
bool IsNullable();
|
||||||
void* GetData(int);
|
void* GetData(int);
|
||||||
long GetSize(int);
|
long GetSize(int);
|
||||||
|
|
||||||
@@ -217,7 +218,7 @@ class WXDLLEXPORT wxRecordSet: public wxObject
|
|||||||
int cursor;
|
int cursor;
|
||||||
int type;
|
int type;
|
||||||
int options;
|
int options;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HSTMT hStmt;
|
HSTMT hStmt;
|
||||||
int nFields;
|
int nFields;
|
||||||
@@ -232,48 +233,50 @@ class WXDLLEXPORT wxRecordSet: public wxObject
|
|||||||
wxRETCODE retcode;
|
wxRETCODE retcode;
|
||||||
wxList cols;
|
wxList cols;
|
||||||
wxList fetchbuf;
|
wxList fetchbuf;
|
||||||
|
|
||||||
void FillVars(int);
|
void FillVars(int);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// JACS gave parent a default value for benefit of IMPLEMENT_DYNAMIC_CLASS
|
// JACS gave parent a default value for benefit of IMPLEMENT_DYNAMIC_CLASS
|
||||||
wxRecordSet(wxDatabase *parent = NULL, int =wxOPEN_TYPE_DYNASET, int =wxOPTION_DEFAULT);
|
wxRecordSet(wxDatabase *parent = NULL,
|
||||||
~wxRecordSet(void);
|
int = wxOPEN_TYPE_DYNASET,
|
||||||
|
int = wxOPTION_DEFAULT);
|
||||||
|
~wxRecordSet();
|
||||||
|
|
||||||
// My own, lower-level functions.
|
// My own, lower-level functions.
|
||||||
bool BeginQuery(int openType, char *sql = NULL, int options = wxOPTION_DEFAULT);
|
bool BeginQuery(int openType, char *sql = NULL, int options = wxOPTION_DEFAULT);
|
||||||
bool EndQuery(void);
|
bool EndQuery();
|
||||||
bool Query(char* columns, char* table =NULL, char *filter =NULL);
|
bool Query(char* columns, char* table =NULL, char *filter =NULL);
|
||||||
|
|
||||||
// Attributes
|
// Attributes
|
||||||
inline int GetNumberFields(void) { return nFields; }
|
inline int GetNumberFields(void) { return nFields; }
|
||||||
inline int GetNumberParams(void) { return nParams; }
|
inline int GetNumberParams(void) { return nParams; }
|
||||||
long GetNumberRecords(void);
|
long GetNumberRecords();
|
||||||
long GetNumberCols(void);
|
long GetNumberCols();
|
||||||
inline char *GetFilter(void) { return recordFilter; }
|
inline char *GetFilter(void) { return recordFilter; }
|
||||||
inline char *GetSortString(void) { return sortString; }
|
inline char *GetSortString(void) { return sortString; }
|
||||||
inline wxDatabase *GetDatabase(void) { return parentdb; }
|
inline wxDatabase *GetDatabase(void) { return parentdb; }
|
||||||
inline wxRETCODE GetErrorCode(void) { return retcode; }
|
inline wxRETCODE GetErrorCode(void) { return retcode; }
|
||||||
bool CanAppend(void);
|
bool CanAppend();
|
||||||
bool CanRestart(void);
|
bool CanRestart();
|
||||||
bool CanScroll(void);
|
bool CanScroll();
|
||||||
bool CanTransact(void);
|
bool CanTransact();
|
||||||
bool CanUpdate(void);
|
bool CanUpdate();
|
||||||
long GetCurrentRecord(void);
|
long GetCurrentRecord();
|
||||||
bool RecordCountFinal(void);
|
bool RecordCountFinal();
|
||||||
bool GetResultSet(void);
|
bool GetResultSet();
|
||||||
bool ExecuteSQL(char*);
|
bool ExecuteSQL(char*);
|
||||||
bool GetTables(void);
|
bool GetTables();
|
||||||
bool GetColumns(char* =NULL);
|
bool GetColumns(char* =NULL);
|
||||||
bool GetPrimaryKeys(char* =NULL);
|
bool GetPrimaryKeys(char* =NULL);
|
||||||
bool GetForeignKeys(char* , char * );
|
bool GetForeignKeys(char* , char * );
|
||||||
char *GetTableName(void);
|
char *GetTableName();
|
||||||
void SetTableName(char*);
|
void SetTableName(char*);
|
||||||
char *GetSQL(void);
|
char *GetSQL();
|
||||||
bool IsOpen(void);
|
bool IsOpen();
|
||||||
bool IsBOF(void);
|
bool IsBOF();
|
||||||
bool IsEOF(void);
|
bool IsEOF();
|
||||||
bool IsDeleted(void);
|
bool IsDeleted();
|
||||||
|
|
||||||
bool GetFieldData(int colPos, int dataType, void *dataPtr);
|
bool GetFieldData(int colPos, int dataType, void *dataPtr);
|
||||||
bool GetFieldData(const char*, int dataType, void *dataPtr);
|
bool GetFieldData(const char*, int dataType, void *dataPtr);
|
||||||
@@ -286,50 +289,50 @@ class WXDLLEXPORT wxRecordSet: public wxObject
|
|||||||
void* BindVar(const char*, void*, long);
|
void* BindVar(const char*, void*, long);
|
||||||
|
|
||||||
void SetType(int);
|
void SetType(int);
|
||||||
int GetType(void);
|
int GetType();
|
||||||
void SetOptions(int);
|
void SetOptions(int);
|
||||||
int GetOptions(void);
|
int GetOptions();
|
||||||
|
|
||||||
// Update operations
|
// Update operations
|
||||||
void AddNew(void);
|
void AddNew();
|
||||||
bool Delete(void);
|
bool Delete();
|
||||||
void Edit(void);
|
void Edit();
|
||||||
bool Update(void);
|
bool Update();
|
||||||
|
|
||||||
// Record navigation
|
// Record navigation
|
||||||
virtual bool Move(long rows);
|
virtual bool Move(long rows);
|
||||||
virtual bool MoveFirst(void);
|
virtual bool MoveFirst();
|
||||||
virtual bool MoveLast(void);
|
virtual bool MoveLast();
|
||||||
virtual bool MoveNext(void);
|
virtual bool MoveNext();
|
||||||
virtual bool MovePrev(void);
|
virtual bool MovePrev();
|
||||||
virtual bool GoTo(long);
|
virtual bool GoTo(long);
|
||||||
|
|
||||||
// Others
|
// Others
|
||||||
bool GetDataSources(void);
|
bool GetDataSources();
|
||||||
|
|
||||||
// Associate a column name/position with a data location
|
// Associate a column name/position with a data location
|
||||||
// bool BindColumn(int colPos, int dataType, void *dataPtr);
|
// bool BindColumn(int colPos, int dataType, void *dataPtr);
|
||||||
|
|
||||||
void Cancel(void);
|
void Cancel();
|
||||||
bool IsFieldDirty(int);
|
bool IsFieldDirty(int);
|
||||||
bool IsFieldDirty(const char*);
|
bool IsFieldDirty(const char*);
|
||||||
bool IsFieldNull(int);
|
bool IsFieldNull(int);
|
||||||
bool IsFieldNull(const char*);
|
bool IsFieldNull(const char*);
|
||||||
bool IsColNullable(int);
|
bool IsColNullable(int);
|
||||||
bool IsColNullable(const char*);
|
bool IsColNullable(const char*);
|
||||||
virtual bool Requery(void);
|
virtual bool Requery();
|
||||||
virtual void SetFieldDirty(int, bool dirty = TRUE);
|
virtual void SetFieldDirty(int, bool dirty = TRUE);
|
||||||
virtual void SetFieldDirty(const char*, bool dirty = TRUE);
|
virtual void SetFieldDirty(const char*, bool dirty = TRUE);
|
||||||
void SetFieldNull(void *p, bool isNull = TRUE);
|
void SetFieldNull(void *p, bool isNull = TRUE);
|
||||||
|
|
||||||
// Overridables
|
// Overridables
|
||||||
virtual char *GetDefaultConnect(void);
|
virtual char *GetDefaultConnect();
|
||||||
virtual char *GetDefaultSQL(void);
|
virtual char *GetDefaultSQL();
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
|
|
||||||
// Build SQL query from column specification
|
// Build SQL query from column specification
|
||||||
bool ConstructDefaultSQL(void);
|
bool ConstructDefaultSQL();
|
||||||
void SetDefaultSQL(char *s);
|
void SetDefaultSQL(char *s);
|
||||||
bool ReleaseHandle(void); // Added JACS
|
bool ReleaseHandle(void); // Added JACS
|
||||||
};
|
};
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
public:
|
public:
|
||||||
// override base class virtuals
|
// override base class virtuals
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
|
|
||||||
// this one is called on application startup and is a good place for the app
|
// this one is called on application startup and is a good place for the app
|
||||||
// initialization (doing it here and not in the ctor allows to have an error
|
// initialization (doing it here and not in the ctor allows to have an error
|
||||||
// return: if OnInit() returns false, the application terminates)
|
// return: if OnInit() returns false, the application terminates)
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
public:
|
public:
|
||||||
// ctor(s)
|
// ctor(s)
|
||||||
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||||
|
|
||||||
// event handlers (these functions should _not_ be virtual)
|
// event handlers (these functions should _not_ be virtual)
|
||||||
void OnQuit(wxCommandEvent& event);
|
void OnQuit(wxCommandEvent& event);
|
||||||
void OnAbout(wxCommandEvent& event);
|
void OnAbout(wxCommandEvent& event);
|
||||||
@@ -71,10 +71,7 @@
|
|||||||
Minimal_Quit = 1,
|
Minimal_Quit = 1,
|
||||||
Minimal_About,
|
Minimal_About,
|
||||||
Minimal_Back,
|
Minimal_Back,
|
||||||
Minimal_Forward,
|
Minimal_Forward
|
||||||
|
|
||||||
// controls start here (the numbers are, of course, arbitrary)
|
|
||||||
Minimal_Text = 1000,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -90,18 +87,18 @@
|
|||||||
EVT_MENU(Minimal_Back, MyFrame::OnBack)
|
EVT_MENU(Minimal_Back, MyFrame::OnBack)
|
||||||
EVT_MENU(Minimal_Forward, MyFrame::OnForward)
|
EVT_MENU(Minimal_Forward, MyFrame::OnForward)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// Create a new application object: this macro will allow wxWindows to create
|
// Create a new application object: this macro will allow wxWindows to create
|
||||||
// the application object during program execution (it's better than using a
|
// the application object during program execution (it's better than using a
|
||||||
// static object for many reasons) and also declares the accessor function
|
// static object for many reasons) and also declares the accessor function
|
||||||
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
|
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
|
||||||
// not wxApp)
|
// not wxApp)
|
||||||
IMPLEMENT_APP(MyApp)
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// the application class
|
// the application class
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -114,18 +111,18 @@
|
|||||||
#if wxUSE_LIBJPEG
|
#if wxUSE_LIBJPEG
|
||||||
wxImage::AddHandler(new wxJPEGHandler);
|
wxImage::AddHandler(new wxJPEGHandler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxFileSystem::AddHandler(new wxZipFSHandler);
|
wxFileSystem::AddHandler(new wxZipFSHandler);
|
||||||
|
|
||||||
// Create the main application window
|
// Create the main application window
|
||||||
MyFrame *frame = new MyFrame("wxHtmlWindow testing application",
|
MyFrame *frame = new MyFrame("wxHtmlWindow testing application",
|
||||||
wxPoint(50, 50), wxSize(640, 480));
|
wxPoint(50, 50), wxSize(640, 480));
|
||||||
|
|
||||||
// Show it and tell the application that it's our main window
|
// Show it and tell the application that it's our main window
|
||||||
// @@@ what does it do exactly, in fact? is it necessary here?
|
// @@@ what does it do exactly, in fact? is it necessary here?
|
||||||
frame->Show(TRUE);
|
frame->Show(TRUE);
|
||||||
SetTopWindow(frame);
|
SetTopWindow(frame);
|
||||||
|
|
||||||
// success: wxApp::OnRun() will be called which will enter the main message
|
// success: wxApp::OnRun() will be called which will enter the main message
|
||||||
// loop and the application will run. If we returned FALSE here, the
|
// loop and the application will run. If we returned FALSE here, the
|
||||||
// application would exit immediately.
|
// application would exit immediately.
|
||||||
@@ -157,7 +154,7 @@ wxHtmlWindow *html;
|
|||||||
|
|
||||||
// ... and attach this menu bar to the frame
|
// ... and attach this menu bar to the frame
|
||||||
SetMenuBar(menuBar);
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
CreateStatusBar(1);
|
CreateStatusBar(1);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@@ -1,13 +1,11 @@
|
|||||||
#if !defined(__VISAGECPP__)
|
|
||||||
# pragma warning(disable:4001) /* non standard extension used: single line comment */
|
|
||||||
#endif
|
|
||||||
#include "wx/setup.h"
|
#include "wx/setup.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#if wxUSE_APPLE_IEEE
|
#if wxUSE_APPLE_IEEE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* C O N V E R T T O I E E E E X T E N D E D
|
* C O N V E R T T O I E E E E X T E N D E D
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Copyright (C) 1988-1991 Apple Computer, Inc.
|
/* Copyright (C) 1988-1991 Apple Computer, Inc.
|
||||||
@@ -16,7 +14,7 @@
|
|||||||
* Machine-independent I/O routines for IEEE floating-point numbers.
|
* Machine-independent I/O routines for IEEE floating-point numbers.
|
||||||
*
|
*
|
||||||
* NaN's and infinities are converted to HUGE_VAL or HUGE, which
|
* NaN's and infinities are converted to HUGE_VAL or HUGE, which
|
||||||
* happens to be infinity on IEEE machines. Unfortunately, it is
|
* happens to be infinity on IEEE machines. Unfortunately, it is
|
||||||
* impossible to preserve NaN's in a machine-independent way.
|
* impossible to preserve NaN's in a machine-independent way.
|
||||||
* Infinities are, however, preserved on IEEE machines.
|
* Infinities are, however, preserved on IEEE machines.
|
||||||
*
|
*
|
||||||
@@ -49,67 +47,68 @@
|
|||||||
|
|
||||||
void ConvertToIeeeExtended(double num, unsigned char *bytes)
|
void ConvertToIeeeExtended(double num, unsigned char *bytes)
|
||||||
{
|
{
|
||||||
int sign;
|
int sign;
|
||||||
int expon;
|
int expon;
|
||||||
double fMant, fsMant;
|
double fMant, fsMant;
|
||||||
unsigned long hiMant, loMant;
|
unsigned long hiMant, loMant;
|
||||||
|
|
||||||
if (num < 0) {
|
if (num < 0) {
|
||||||
sign = 0x8000;
|
sign = 0x8000;
|
||||||
num *= -1;
|
num *= -1;
|
||||||
} else {
|
} else {
|
||||||
sign = 0;
|
sign = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num == 0) {
|
if (num == 0) {
|
||||||
expon = 0; hiMant = 0; loMant = 0;
|
expon = 0; hiMant = 0; loMant = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fMant = frexp(num, &expon);
|
fMant = frexp(num, &expon);
|
||||||
if ((expon > 16384) || !(fMant < 1)) { /* Infinity or NaN */
|
if ((expon > 16384) || !(fMant < 1)) { /* Infinity or NaN */
|
||||||
expon = sign|0x7FFF; hiMant = 0; loMant = 0; /* infinity */
|
expon = sign|0x7FFF; hiMant = 0; loMant = 0; /* infinity */
|
||||||
}
|
}
|
||||||
else { /* Finite */
|
else { /* Finite */
|
||||||
expon += 16382;
|
expon += 16382;
|
||||||
if (expon < 0) { /* denormalized */
|
if (expon < 0) { /* denormalized */
|
||||||
fMant = ldexp(fMant, expon);
|
fMant = ldexp(fMant, expon);
|
||||||
expon = 0;
|
expon = 0;
|
||||||
}
|
}
|
||||||
expon |= sign;
|
expon |= sign;
|
||||||
fMant = ldexp(fMant, 32);
|
fMant = ldexp(fMant, 32);
|
||||||
fsMant = floor(fMant);
|
fsMant = floor(fMant);
|
||||||
hiMant = FloatToUnsigned(fsMant);
|
hiMant = FloatToUnsigned(fsMant);
|
||||||
fMant = ldexp(fMant - fsMant, 32);
|
fMant = ldexp(fMant - fsMant, 32);
|
||||||
fsMant = floor(fMant);
|
fsMant = floor(fMant);
|
||||||
loMant = FloatToUnsigned(fsMant);
|
loMant = FloatToUnsigned(fsMant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disable the warning about 'possible loss of data' & 'conversion between diff types' */
|
/* disable the warning about 'possible loss of data' & 'conversion between
|
||||||
#ifdef _MSC_VER
|
* diff types' */
|
||||||
#pragma warning(disable: 4244)
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable: 4135)
|
#pragma warning(disable: 4244)
|
||||||
#endif /* Visual C++ */
|
#pragma warning(disable: 4135)
|
||||||
|
#endif /* Visual C++ */
|
||||||
|
|
||||||
bytes[0] = (expon >> 8) & 0xff;
|
bytes[0] = (expon >> 8) & 0xff;
|
||||||
bytes[1] = expon & 0xff;
|
bytes[1] = expon & 0xff;
|
||||||
bytes[2] = (unsigned char) ((hiMant >> 24) & 0xff);
|
bytes[2] = (unsigned char) ((hiMant >> 24) & 0xff);
|
||||||
bytes[3] = (unsigned char) ((hiMant >> 16) & 0xff);
|
bytes[3] = (unsigned char) ((hiMant >> 16) & 0xff);
|
||||||
bytes[4] = (unsigned char) ((hiMant >> 8) & 0xff);
|
bytes[4] = (unsigned char) ((hiMant >> 8) & 0xff);
|
||||||
bytes[5] = (unsigned char) (hiMant & 0xff);
|
bytes[5] = (unsigned char) (hiMant & 0xff);
|
||||||
bytes[6] = (unsigned char) ((loMant >> 24) & 0xff);
|
bytes[6] = (unsigned char) ((loMant >> 24) & 0xff);
|
||||||
bytes[7] = (unsigned char) ((loMant >> 16) & 0xff);
|
bytes[7] = (unsigned char) ((loMant >> 16) & 0xff);
|
||||||
bytes[8] = (unsigned char) ((loMant >> 8) & 0xff);
|
bytes[8] = (unsigned char) ((loMant >> 8) & 0xff);
|
||||||
bytes[9] = (unsigned char) (loMant & 0xff);
|
bytes[9] = (unsigned char) (loMant & 0xff);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(default: 4244)
|
#pragma warning(default: 4244)
|
||||||
#pragma warning(default: 4135)
|
#pragma warning(default: 4135)
|
||||||
#endif /* Visual C++ */
|
#endif /* Visual C++ */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* C O N V E R T F R O M I E E E E X T E N D E D
|
* C O N V E R T F R O M I E E E E X T E N D E D
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -119,16 +118,16 @@ void ConvertToIeeeExtended(double num, unsigned char *bytes)
|
|||||||
* Machine-independent I/O routines for IEEE floating-point numbers.
|
* Machine-independent I/O routines for IEEE floating-point numbers.
|
||||||
*
|
*
|
||||||
* NaN's and infinities are converted to HUGE_VAL or HUGE, which
|
* NaN's and infinities are converted to HUGE_VAL or HUGE, which
|
||||||
* happens to be infinity on IEEE machines. Unfortunately, it is
|
* happens to be infinity on IEEE machines. Unfortunately, it is
|
||||||
* impossible to preserve NaN's in a machine-independent way.
|
* impossible to preserve NaN's in a machine-independent way.
|
||||||
* Infinities are, however, preserved on IEEE machines.
|
* Infinities are, however, preserved on IEEE machines.
|
||||||
*
|
*
|
||||||
* These routines have been tested on the following machines:
|
* These routines have been tested on the following machines:
|
||||||
* Apple Macintosh, MPW 3.1 C compiler
|
* Apple Macintosh, MPW 3.1 C compiler
|
||||||
* Apple Macintosh, THINK C compiler
|
* Apple Macintosh, THINK C compiler
|
||||||
* Silicon Graphics IRIS, MIPS compiler
|
* Silicon Graphics IRIS, MIPS compiler
|
||||||
* Cray X/MP and Y/MP
|
* Cray X/MP and Y/MP
|
||||||
* Digital Equipment VAX
|
* Digital Equipment VAX
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Implemented by Malcolm Slaney and Ken Turkowski.
|
* Implemented by Malcolm Slaney and Ken Turkowski.
|
||||||
@@ -156,38 +155,38 @@ void ConvertToIeeeExtended(double num, unsigned char *bytes)
|
|||||||
|
|
||||||
double ConvertFromIeeeExtended(const unsigned char *bytes)
|
double ConvertFromIeeeExtended(const unsigned char *bytes)
|
||||||
{
|
{
|
||||||
double f;
|
double f;
|
||||||
int expon;
|
int expon;
|
||||||
unsigned long hiMant, loMant;
|
unsigned long hiMant, loMant;
|
||||||
|
|
||||||
expon = ((bytes[0] & 0x7F) << 8) | (bytes[1] & 0xFF);
|
expon = ((bytes[0] & 0x7F) << 8) | (bytes[1] & 0xFF);
|
||||||
hiMant = ((unsigned long)(bytes[2] & 0xFF) << 24)
|
hiMant = ((unsigned long)(bytes[2] & 0xFF) << 24)
|
||||||
| ((unsigned long) (bytes[3] & 0xFF) << 16)
|
| ((unsigned long) (bytes[3] & 0xFF) << 16)
|
||||||
| ((unsigned long) (bytes[4] & 0xFF) << 8)
|
| ((unsigned long) (bytes[4] & 0xFF) << 8)
|
||||||
| ((unsigned long) (bytes[5] & 0xFF));
|
| ((unsigned long) (bytes[5] & 0xFF));
|
||||||
loMant = ((unsigned long) (bytes[6] & 0xFF) << 24)
|
loMant = ((unsigned long) (bytes[6] & 0xFF) << 24)
|
||||||
| ((unsigned long) (bytes[7] & 0xFF) << 16)
|
| ((unsigned long) (bytes[7] & 0xFF) << 16)
|
||||||
| ((unsigned long) (bytes[8] & 0xFF) << 8)
|
| ((unsigned long) (bytes[8] & 0xFF) << 8)
|
||||||
| ((unsigned long) (bytes[9] & 0xFF));
|
| ((unsigned long) (bytes[9] & 0xFF));
|
||||||
|
|
||||||
if (expon == 0 && hiMant == 0 && loMant == 0) {
|
if (expon == 0 && hiMant == 0 && loMant == 0) {
|
||||||
f = 0;
|
f = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (expon == 0x7FFF) { /* Infinity or NaN */
|
if (expon == 0x7FFF) { /* Infinity or NaN */
|
||||||
f = HUGE_VAL;
|
f = HUGE_VAL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
expon -= 16383;
|
expon -= 16383;
|
||||||
f = ldexp(UnsignedToFloat(hiMant), expon-=31);
|
f = ldexp(UnsignedToFloat(hiMant), expon-=31);
|
||||||
f += ldexp(UnsignedToFloat(loMant), expon-=32);
|
f += ldexp(UnsignedToFloat(loMant), expon-=32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes[0] & 0x80)
|
if (bytes[0] & 0x80)
|
||||||
return -f;
|
return -f;
|
||||||
else
|
else
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* wxUSE_APPLE_IEEE */
|
#endif /* wxUSE_APPLE_IEEE */
|
||||||
|
Reference in New Issue
Block a user