[pygobject/llvm: 5/17] Convert two functions into methods



commit 0b83497ae1b04df70de34241182fb86563197814
Author: Johan Dahlin <johan gnome org>
Date:   Mon Jul 5 20:21:04 2010 -0300

    Convert two functions into methods

 gi/llvm-compiler.cpp |   22 ++++++++++------------
 gi/llvm-compiler.h   |    5 +++++
 2 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/gi/llvm-compiler.cpp b/gi/llvm-compiler.cpp
index cd12a08..6e4ec85 100644
--- a/gi/llvm-compiler.cpp
+++ b/gi/llvm-compiler.cpp
@@ -434,8 +434,8 @@ LLVMCompiler::tupleGetItem(llvm::BasicBlock *block,
                              llvm::ConstantInt::get(llvm::Type::getInt32Ty(mCtx), i));
 }
 
-static void *
-pyg_get_native_address(GIFunctionInfo *info)
+void *
+LLVMCompiler::getNativeAddress(GIFunctionInfo *info)
 {
   void * nativeAddress;
 
@@ -448,18 +448,16 @@ pyg_get_native_address(GIFunctionInfo *info)
   return nativeAddress;
 }
 
-static llvm::Function *
-pyg_create_native_call(llvm::Module *module,
-                       const llvm::Type *nativeRetvalType,
-                       std::vector<const llvm::Type*> nativeTypes,
-                       std::vector<llvm::Value*> nativeArgValues,
-                       GIFunctionInfo *functionInfo)
+llvm::Function *
+LLVMCompiler::createNativeCall(GIFunctionInfo *functionInfo,
+                               const llvm::Type *nativeRetvalType,
+                               std::vector<const llvm::Type*> nativeTypes,
+                               std::vector<llvm::Value*> nativeArgValues)
 {
   std::string symbol(g_function_info_get_symbol(functionInfo));
 
-  // native call
   llvm::FunctionType *nativeFT = llvm::FunctionType::get(nativeRetvalType, nativeTypes, false);
-  return llvm::Function::Create(nativeFT, llvm::Function::ExternalLinkage, symbol, module);
+  return llvm::Function::Create(nativeFT, llvm::Function::ExternalLinkage, symbol, mModule);
 }
 
 char *
@@ -579,8 +577,8 @@ LLVMCompiler::compile(GIFunctionInfo *info)
   // py->native return type
   GIArgInfo *retTypeInfo = g_callable_info_get_return_type(callableInfo);
   const llvm::Type *nativeRetvalType = this->getTypeFromTypeInfo(retTypeInfo);
-  llvm::Function * nativeF = pyg_create_native_call(mModule, nativeRetvalType, nativeTypes, nativeArgValues, info);
-  mEE->updateGlobalMapping(nativeF, pyg_get_native_address(info));
+  llvm::Function * nativeF = this->createNativeCall(info, nativeRetvalType, nativeTypes, nativeArgValues);
+  mEE->updateGlobalMapping(nativeF, this->getNativeAddress(info));
 
   const char *retValName;
   if (g_type_info_get_tag(retTypeInfo) == GI_TYPE_TAG_VOID)
diff --git a/gi/llvm-compiler.h b/gi/llvm-compiler.h
index ccdcf38..1633a6c 100644
--- a/gi/llvm-compiler.h
+++ b/gi/llvm-compiler.h
@@ -70,6 +70,11 @@ namespace pygi {
     char * getFunctionName(GIFunctionInfo *info);
     llvm::Value * createPyNone();
     void loadSymbols();
+    llvm::Function * createNativeCall(GIFunctionInfo *functionInfo,
+                                      const llvm::Type *nativeRetvalType,
+                                      std::vector<const llvm::Type*> nativeTypes,
+                                      std::vector<llvm::Value*> nativeArgValues);
+    void * getNativeAddress(GIFunctionInfo *info);
 
   public:
     LLVMCompiler(llvm::LLVMContext &ctx);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]