File: superror.cpp

package info (click to toggle)
camlidl 1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,592 kB
  • sloc: ml: 5,238; ansic: 945; cpp: 908; makefile: 358; xml: 213; sh: 74
file content (69 lines) | stat: -rw-r--r-- 2,020 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/***********************************************************************/
/*                                                                     */
/*                              CamlIDL                                */
/*                                                                     */
/*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
/*                                                                     */
/*  Copyright 1999 Institut National de Recherche en Informatique et   */
/*  en Automatique.  All rights reserved.  This file is distributed    */
/*  under the terms of the GNU Library General Public License.         */
/*                                                                     */
/***********************************************************************/

/* $Id: superror.cpp,v 1.3 2000-08-19 11:05:00 xleroy Exp $ */

/* The ISupportErrorInfo interface for Caml components */

extern "C" {
#include <caml/mlvalues.h>
#include "camlidlruntime.h"
}
#include "comstuff.h"

class camlidl_sei : public ISupportErrorInfo
{
private:
  struct camlidl_intf * intf;
  long refcount;

public:

  virtual HRESULT __stdcall QueryInterface(const IID& iid, void ** object)
  {
    return camlidl_QueryInterface(intf, iid, object);
  }
  ULONG __stdcall AddRef()
  {
    return InterlockedIncrement(&refcount);
  }
  ULONG __stdcall Release()
  {
    ULONG newrefcount = InterlockedDecrement(&refcount);
    if (newrefcount == 0) {
      ((IUnknown *) intf)->Release();
      delete this;
    }
    return newrefcount;
  }
  HRESULT __stdcall InterfaceSupportsErrorInfo(const IID& iid)
  {
    if (iid == IID_IUnknown || iid == IID_ISupportErrorInfo)
      return S_FALSE;
    else
      return S_OK;
  }

  // constructor
  camlidl_sei (struct camlidl_intf * intf_init)
  {
    intf = intf_init;
    ((IUnknown *) intf)->AddRef();
    refcount = 1;
  }
};

extern "C"
ISupportErrorInfo *  camlidl_support_error_info(struct camlidl_intf * i)
{
  return new camlidl_sei(i);
}