Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] OOPify/C++ify Type
[simgrid.git] / src / mc / mc_object_info.cpp
index 679c0b4..67e4d35 100644 (file)
@@ -1,3 +1,9 @@
+/* Copyright (c) 2014-2015. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
 #include <stddef.h>
 
 #include <xbt/dynar.h>
 #include "mc_object_info.h"
 #include "mc_private.h"
 
-extern "C" {
+namespace simgrid {
+namespace mc {
+
+// Type
+
+Type::Type()
+{
+  this->type = 0;
+  this->id = 0;
+  this->name = std::string();
+  this->byte_size = 0;
+  this->element_count = 0;
+  this->members = nullptr;
+  this->is_pointer_type = 0;
+  this->location = {0, 0, 0, 0};
+  this->offset = 0;
+  this->subtype = nullptr;
+  this->full_type = nullptr;
+}
+
+Type::~Type()
+{
+  xbt_dynar_free(&this->members);
+  mc_dwarf_expression_clear(&this->location);
+}
+
+// ObjectInformations
 
-dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, const void *ip)
+dw_frame_t ObjectInformation::find_function(const void *ip) const
 {
-  xbt_dynar_t dynar = info->functions_index;
+  xbt_dynar_t dynar = this->functions_index;
   mc_function_index_item_t base =
       (mc_function_index_item_t) xbt_dynar_get_ptr(dynar, 0);
   int i = 0;
@@ -24,19 +56,20 @@ dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, const void *
       return base[k].function;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
-dw_variable_t MC_file_object_info_find_variable_by_name(mc_object_info_t info, const char* name)
+dw_variable_t ObjectInformation::find_variable(const char* name) const
 {
   unsigned int cursor = 0;
   dw_variable_t variable;
-  xbt_dynar_foreach(info->global_variables, cursor, variable){
+  xbt_dynar_foreach(this->global_variables, cursor, variable){
     if(!strcmp(name, variable->name))
       return variable;
   }
 
-  return NULL;
+  return nullptr;
 }
 
 }
+}
\ No newline at end of file