www.digitalmars.com         C & C++   DMDScript  

D - DbC

reply "Charles" <sanders-consulting comcast.net> writes:
Shouldnt this constructor catch that hbm is null in the OUT contract ?

class Bitmap
{
public:
 HBITMAP hbm;
 BITMAP bm;

 this()
 {
  hbm = null;
  bm.bmWidth  = -1;
  bm.bmHeight = -1;
 }

 this( char[] name )
 out {  // here, this never gets executed it seems
  wassert( hbm !== null ,"hbm !== null in File : [images.d] Line :  (25) ");
  msgBox("HERE");
 }
 body {

  hbm = LoadImage( WA.globalInstance, c_str(name), IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION );
  if ( hbm !== null )
  {
   GetObject( hbm, bm.size, &bm );
  }
  else
  {
   msgBox("image load failed");
   msgBox(OS.getLastError() );
  }
 }

It seems that the out part of the contuctor is never hit , am I missing
something ?  Im getting a message box with image load failed ... but no
wassert, and no msgbox in out contract.


C
Dec 31 2003
parent reply "Walter" <walter digitalmars.com> writes:
Try putting a printf  in the out and see if it gets executed.

"Charles" <sanders-consulting comcast.net> wrote in message
news:bsv43n$1lhg$1 digitaldaemon.com...
 Shouldnt this constructor catch that hbm is null in the OUT contract ?

 class Bitmap
 {
 public:
  HBITMAP hbm;
  BITMAP bm;

  this()
  {
   hbm = null;
   bm.bmWidth  = -1;
   bm.bmHeight = -1;
  }

  this( char[] name )
  out {  // here, this never gets executed it seems
   wassert( hbm !== null ,"hbm !== null in File : [images.d] Line :  (25)
");
   msgBox("HERE");
  }
  body {

   hbm = LoadImage( WA.globalInstance, c_str(name), IMAGE_BITMAP, 0, 0,
 LR_LOADFROMFILE|LR_CREATEDIBSECTION );
   if ( hbm !== null )
   {
    GetObject( hbm, bm.size, &bm );
   }
   else
   {
    msgBox("image load failed");
    msgBox(OS.getLastError() );
   }
  }

 It seems that the out part of the contuctor is never hit , am I missing
 something ?  Im getting a message box with image load failed ... but no
 wassert, and no msgbox in out contract.


 C
Dec 31 2003
parent reply "Charles" <sanders-consulting comcast.net> writes:
My fault, a -release got slipped in there, it works as expected :).

On a side-note , ive been using D alot lately , and I've run into almost no
trouble at all , be it internal errors , weird compiler error messages ,
import troubles etc.  I think D is a perfect candidate for extreme
programming ( though I think we've all been practicing this long before they
had a name for it ) , which almost elimiates the need for a debugger.  With
the upcoming template revisions I think it will be ready for full blown use!

Can't wait for the new release!

C


"Walter" <walter digitalmars.com> wrote in message
news:bsvbvj$20m1$1 digitaldaemon.com...
 Try putting a printf  in the out and see if it gets executed.

 "Charles" <sanders-consulting comcast.net> wrote in message
 news:bsv43n$1lhg$1 digitaldaemon.com...
 Shouldnt this constructor catch that hbm is null in the OUT contract ?

 class Bitmap
 {
 public:
  HBITMAP hbm;
  BITMAP bm;

  this()
  {
   hbm = null;
   bm.bmWidth  = -1;
   bm.bmHeight = -1;
  }

  this( char[] name )
  out {  // here, this never gets executed it seems
   wassert( hbm !== null ,"hbm !== null in File : [images.d] Line :  (25)
");
   msgBox("HERE");
  }
  body {

   hbm = LoadImage( WA.globalInstance, c_str(name), IMAGE_BITMAP, 0, 0,
 LR_LOADFROMFILE|LR_CREATEDIBSECTION );
   if ( hbm !== null )
   {
    GetObject( hbm, bm.size, &bm );
   }
   else
   {
    msgBox("image load failed");
    msgBox(OS.getLastError() );
   }
  }

 It seems that the out part of the contuctor is never hit , am I missing
 something ?  Im getting a message box with image load failed ... but no
 wassert, and no msgbox in out contract.


 C
Dec 31 2003
next sibling parent "Matthew" <matthew.hat stlsoft.dot.org> writes:
I've not yet used a debugger on D. Haven't had the need. :)

"Charles" <sanders-consulting comcast.net> wrote in message
news:bsvfdd$25kq$1 digitaldaemon.com...
 My fault, a -release got slipped in there, it works as expected :).

 On a side-note , ive been using D alot lately , and I've run into almost
no
 trouble at all , be it internal errors , weird compiler error messages ,
 import troubles etc.  I think D is a perfect candidate for extreme
 programming ( though I think we've all been practicing this long before
they
 had a name for it ) , which almost elimiates the need for a debugger.
With
 the upcoming template revisions I think it will be ready for full blown
use!
 Can't wait for the new release!

 C


 "Walter" <walter digitalmars.com> wrote in message
 news:bsvbvj$20m1$1 digitaldaemon.com...
 Try putting a printf  in the out and see if it gets executed.

 "Charles" <sanders-consulting comcast.net> wrote in message
 news:bsv43n$1lhg$1 digitaldaemon.com...
 Shouldnt this constructor catch that hbm is null in the OUT contract ?

 class Bitmap
 {
 public:
  HBITMAP hbm;
  BITMAP bm;

  this()
  {
   hbm = null;
   bm.bmWidth  = -1;
   bm.bmHeight = -1;
  }

  this( char[] name )
  out {  // here, this never gets executed it seems
   wassert( hbm !== null ,"hbm !== null in File : [images.d] Line :
(25)
 ");
   msgBox("HERE");
  }
  body {

   hbm = LoadImage( WA.globalInstance, c_str(name), IMAGE_BITMAP, 0, 0,
 LR_LOADFROMFILE|LR_CREATEDIBSECTION );
   if ( hbm !== null )
   {
    GetObject( hbm, bm.size, &bm );
   }
   else
   {
    msgBox("image load failed");
    msgBox(OS.getLastError() );
   }
  }

 It seems that the out part of the contuctor is never hit , am I
missing
 something ?  Im getting a message box with image load failed ... but
no
 wassert, and no msgbox in out contract.


 C
Dec 31 2003
prev sibling next sibling parent reply Ant <duitoolkit yahoo.ca> writes:
On Wed, 31 Dec 2003 15:42:04 -0800, Charles wrote:

 On a side-note , ive been using D alot lately , and I've run into almost no
 trouble at all , be it internal errors , weird compiler error messages ,
 import troubles etc.
I think my weekend import epiphany will cover most of the problems I was having... Ant
Dec 31 2003
parent reply "Matthew" <matthew.hat stlsoft.dot.org> writes:
"Ant" <duitoolkit yahoo.ca> wrote in message
news:pan.2003.12.31.23.38.59.666895 yahoo.ca...
 On Wed, 31 Dec 2003 15:42:04 -0800, Charles wrote:

 On a side-note , ive been using D alot lately , and I've run into almost
no
 trouble at all , be it internal errors , weird compiler error messages ,
 import troubles etc.
I think my weekend import epiphany will cover most of the problems I was having...
Can you summarise this for the rest of us?
Dec 31 2003
parent Ant <duitoolkit yahoo.ca> writes:
On Thu, 01 Jan 2004 11:09:47 +1100, Matthew wrote:

 "Ant" <duitoolkit yahoo.ca> wrote in message
 I think my weekend import epiphany will cover most of the
 problems I was having...
Can you summarise this for the rest of us?
It's that boring thread I started http://www.digitalmars.com/drn-bin/wwwnews?D/20837 basically for 2 files with 2 classes do: module MA; class A { import MB; B b; } module MB; import MA; class B : A { } and the forward references problem goes away. it's obvious! ("The use of j*va cripples the mind..." ;) if there are any S*n guys monitoring this: it's a joke) I'm just used to put imports outside the class definition. I'm gonna change all my programs to have the imports inside the class definition except the modules with the super class and interfaces. I bet I can now code the dispatcher access on DUI callbaks as I originally intended (except that I'm gonna change that to delegates...) This ends a 3 or 4 month long quest!... and it's obvious... (I hope...) Ant
Dec 31 2003
prev sibling parent "Walter" <walter digitalmars.com> writes:
"Charles" <sanders-consulting comcast.net> wrote in message
news:bsvfdd$25kq$1 digitaldaemon.com...
 On a side-note , ive been using D alot lately , and I've run into almost
no
 trouble at all , be it internal errors , weird compiler error messages ,
 import troubles etc.  I think D is a perfect candidate for extreme
 programming ( though I think we've all been practicing this long before
they
 had a name for it ) , which almost elimiates the need for a debugger.
With
 the upcoming template revisions I think it will be ready for full blown
use! That's really nice to hear, as usually most of what I get are bug reports!
 Can't wait for the new release!
I can't wait to finish it <g>.
Jan 01 2004