(12) United States Patent ao) Patent No.: us 6,886,155 B2
Hasha (45) Date of Patent: Apr. 26,2005
(54) METHOD AND SYSTEM FOR
IMPLEMENTING VIRTUAL FUNCTIONS OF
(75) Inventor: Richard Hasha, Seattle, WA (US)
(73) Assignee: William H. Gates, III, Medina, WA (US)
( * ) Notice: Subject to any disclaimer, the term of this patent is extended or adjusted under 35 U.S.C. 154(b) by 0 days.'
(21) Appl. No.: 10/639,108
(22) Filed: Aug. 12, 2003
(65) Prior Publication Data
US 2004/0049765 Al Mar. 11, 2004
Related U.S. Application Data
(63) Continuation of application No. 09/322,965, tiled on May
28, 1999, now Pat. No. 6,704,924. (60) Provisional application No. 60/118,668, filed on Feb. 3,
(51) Int. CI.7 G06F 9/44
(52) U.S. CI 717/116
(58) Field of Search 717/116
(56) References Cited
U.S. PATENT DOCUMENTS
5,327,562 A * 7/1994 Adcock 717/116
5,854,931 A * 12/1998 lones et al 717/116
6,704,924 Bl * 3/2004 Hasha 717/116
Nackman, Lee R. et al., "Base-Class Composition with Multiple Derivation and Virtual Bases," Proceedings of the 1994 Usenix C++ Technical Conference, Cambridge, MA, pp. 57-71, 1994.
"Object-Oriented Programming in C— The Linnaeus System," IBM Technical Disclosure Bulletin 2i(9B):437-439, 1990.
Stroustrup, "The C++ Programming Language," Addison— Wesley, 3rd Edition, Chapters 2, and 12, Jul. 1998.
* cited by examiner
Primary Examiner—-Todd Ingberg
(74) Attorney, Agent, or Firm—Woodcock Washburn LLP (57) ABSTRACT
A method and system for implementing functions in a class that inherits an interface and that inherits an implementing class which implements the interface. A forwarding system adds to the class for each virtual function a forwarding implementation of that virtual function. The forwarding implementation forwards its invocation to the implementation of that the virtual function in the implementing class. The forwarding system implements a special forwarding instruction that specifies the interface and implementing class. A developer of a class that inherits the interface and the implementing class inserts the forwarding instruction into the class definition. When the forwarding system encounters such an instruction during compilation of the class definition, the forwarding system provides an implementation of each virtual function of the interface that forwards its invocation to a corresponding virtual function in the implementing class. The forwarding system also forwards virtual functions of any direct or indirect base interface of the interface to the implementing class.
13 Claims, 6 Drawing Sheets