From 3197c46797a3e98bed5f4e6a22c765a2b7b6421d Mon Sep 17 00:00:00 2001
From: Robin Dunn <robin@alldunn.com>
Date: Mon, 18 Jan 2021 14:15:57 -0800
Subject: [PATCH 1/2] Add support for using setCppCode on function objects

---
 etgtools/sip_generator.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/etgtools/sip_generator.py b/etgtools/sip_generator.py
index 1621fdd43..38db80b1d 100644
--- a/etgtools/sip_generator.py
+++ b/etgtools/sip_generator.py
@@ -206,7 +206,14 @@ def generateFunction(self, function, stream, _needDocstring=True):
                     stream.write(nci(code, 4))
                     stream.write('%End\n')
                 elif codeType == 'function':
-                    raise NotImplementedError() # TODO: See generateMethod for an example, refactor to share code...
+                    ## raise NotImplementedError() # TODO: See generateMethod for an example, refactor to share code...
+                    cm = extractors.CppMethodDef.FromMethod(function)
+                    cm.body = code
+                    self.generateCppMethod(cm, stream, "", skipDeclaration=True)
+                    # generateCppMethod will have already done the overloads
+                    # and virtual catcher code, so we can just return from
+                    # here.
+                    return
         for f in function.overloads:
             self.generateFunction(f, stream, _needDocstring)
         stream.write('\n')

From 91a205fb172d4a7979fce7941195103b86328223 Mon Sep 17 00:00:00 2001
From: Robin Dunn <robin@alldunn.com>
Date: Mon, 18 Jan 2021 14:16:59 -0800
Subject: [PATCH 2/2] Provide a stubbed version of wxHandleFatalExceptions
 based on wxUSE_ON_FATAL_EXCEPTION

---
 etg/app.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/etg/app.py b/etg/app.py
index 9416d9a58..cbdf11913 100644
--- a/etg/app.py
+++ b/etg/app.py
@@ -209,6 +209,16 @@ def run():
 
     #-------------------------------------------------------
 
+    module.find('wxHandleFatalExceptions').setCppCode("""\
+        #if wxUSE_ON_FATAL_EXCEPTION
+            return wxHandleFatalExceptions(doIt);
+        #else
+            wxLogInfo("This build of wxWidgets does not support wxHandleFatalExceptions.");
+            return false;
+        #endif
+        """)
+
+    #-------------------------------------------------------
 
     module.addHeaderCode("""\
         enum wxAppAssertMode {
