]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - lib/c++/orb.cc
minor orb stuff
[polintos/scott/priv.git] / lib / c++ / orb.cc
index 26f3fc2731b4a74039a3fe84e1726b49b7925136..30b1bcc576c364893fe5a69ea4e5e93b1835b6db 100644 (file)
@@ -1,12 +1,12 @@
 #include <System.h>
+#include <util/radix.h>
 
 namespace System {
 namespace RunTime {
-       using ::System::Exceptions::Std;
+       using namespace ::System::Exceptions::Std;
 
        // This function could be made to do a binary search if we can
        // manage to somehow sort the IFaceTables...
-
        uintptr_t downcast(::System::_i_Object *obj,
                           const unsigned long *new_guid)
        {
@@ -48,9 +48,16 @@ namespace RunTime {
                
                return ptr;
        };
-       
 
        namespace Priv {
+               typedef void (*MethodEntry)(ParamInfoBlock *pib);
+
+               struct Object {
+                       MethodEntry entry;
+                       void *ptr; // pointer to the class interface
+               };
+
+               typedef ::Util::RadixTree<Object, ID, 6> ObjTable;
                ObjTable objtable;
 
                unsigned long get_pc()
@@ -60,44 +67,46 @@ namespace RunTime {
 
                void exception_to_array(::System::VStruct *ex, Array<uint8_t> *ar)
                {
-                       ar->ptr = reinterpret_cast<uint8_t *>(ex);
-                       ar->count = ex->_infoptr->structlen;
+                       // FIXME: marshall struct
                }
-               
-               void handle_message(ParameterInfoBlock *pib)
+
+               void handle_message(ParamInfoBlock *pib)
                {
                        Message *msg = reinterpret_cast<Message *>(pib->segments[0].ptr);
                
-                       switch (seg0->opcode) {
+                       switch (msg->seg0.opcode) {
                                case Segment0::InvokeMethod: {
-                                       if (pib->segments[0].len < sizeof(InvokeMessage))
+                                       if (pib->segments[0].len < sizeof(InvokeMethod))
                                                throw_idl(ShortMessage, 0, pib->segments[0].len,
-                                                         sizeof(InvokeMessage));
+                                                         sizeof(InvokeMethod));
        
-                                       ID obj = pib->objlist[0];
+//                                     ID obj = pib->objlist[0];
                                        
                                        
                                        break;
                                }
                                
                                default:
-                                       throw_idl(InvalidOpcode, seg0->opcode);
+                                       throw_idl(InvalidOpcode, msg->seg0.opcode);
                        }
                }
        }
 }}
 
-extern "C" handle_message(ParameterInfoaBlock *pib, Array<uint8_t> *ex_arr)
+extern "C" void abort();
+
+extern "C" void handle_message(::System::RunTime::ParamInfoBlock *pib,
+                               ::System::RunTime::Array<uint8_t> *ex_arr)
 {
        try {
-               ::System::RunTime::handle_message(pib);
+               ::System::RunTime::Priv::handle_message(pib);
        }
        
-       catch (::System::Exception *ex) {
-               exception_to_array(ex, ex_arr);
+       catch (::System::Exceptions::Exception &ex) {
+               ::System::RunTime::Priv::exception_to_array(&ex, ex_arr);
        }
        
        catch (...) {
-               assertl(0, Assert::Always);
+               abort();
        }
 }