func DumpFunctionInfo(info *C.GIFunctionInfo) { DumpCallableInfo(asCallableInfo(info)) flags := C.g_function_info_get_flags(info) if flags&C.GI_FUNCTION_IS_METHOD > 0 { p("is method\n") } if flags&C.GI_FUNCTION_IS_CONSTRUCTOR > 0 { p("is constructor\n") } if flags&C.GI_FUNCTION_IS_GETTER > 0 { p("is getter\n") property := C.g_function_info_get_property(info) DumpPropertyInfo(property) } if flags&C.GI_FUNCTION_IS_SETTER > 0 { p("is setter\n") property := C.g_function_info_get_property(info) DumpPropertyInfo(property) } if flags&C.GI_FUNCTION_WRAPS_VFUNC > 0 { p("wraps vfunc\n") _ = C.g_function_info_get_vfunc(info) } if flags&C.GI_FUNCTION_THROWS > 0 { p("throws error\n") } symbol := fromGStr(C.g_function_info_get_symbol(info)) p("symbol %s\n", symbol) }
// g_function_info_get_symbol func (fi *FunctionInfo) Symbol() string { ret := C.g_function_info_get_symbol((*C.GIFunctionInfo)(fi.c)) return _GStringToGoString(ret) }
func (info *GiInfo) GetSymbol() string { return GoString(C.g_function_info_get_symbol((*C.GIFunctionInfo)(info.ptr))) }
func (self *Generator) GenFunction(info *C.GIFunctionInfo) { // name name := fromGStr(C.g_base_info_get_name(asBaseInfo(info))) self.currentFunctionName = name goName := convertFuncName(name) w(self.FuncsWriter, "func %s", goName) // collect args var inArgs, outArgs []*C.GIArgInfo nArgs := C.g_callable_info_get_n_args(asCallableInfo(info)) for i := C.gint(0); i < nArgs; i++ { arg := C.g_callable_info_get_arg(asCallableInfo(info), i) argDirection := C.g_arg_info_get_direction(arg) switch argDirection { case C.GI_DIRECTION_IN: inArgs = append(inArgs, arg) case C.GI_DIRECTION_OUT: outArgs = append(outArgs, arg) case C.GI_DIRECTION_INOUT: inArgs = append(inArgs, arg) outArgs = append(outArgs, arg) } } // output in args w(self.FuncsWriter, "(") for _, arg := range inArgs { argName := convertArgName(fromGStr(C.g_base_info_get_name(asBaseInfo(arg)))) goTypeStr := self.getGoTypeStr(C.g_arg_info_get_type(arg)) /* argCallerAllocates := C.g_arg_info_is_caller_allocates(arg) == True if argCallerAllocates { goTypeStr = "*" + goTypeStr } */ w(self.FuncsWriter, "%s %s,", argName, goTypeStr) } w(self.FuncsWriter, ")") w(self.FuncsWriter, "{}\n") //TODO body // symbol symbol := fromGStr(C.g_function_info_get_symbol(info)) _ = symbol // error throwsError := C.g_callable_info_can_throw_gerror(asCallableInfo(info)) == True _ = throwsError // args /* nArgs := C.g_callable_info_get_n_args(asCallableInfo(info)) for i := C.gint(0); i < nArgs; i++ { argCallerAllocates := C.g_arg_info_is_caller_allocates(arg) == True if argCallerAllocates { p(" CALLER_ALLOCATES") } if argTypeTag == C.GI_TYPE_TAG_ARRAY { arrayType := C.g_type_info_get_array_type(argType) p(" ARRAY of %s", ArrayTypeToString(arrayType)) if arrayType == C.GI_ARRAY_TYPE_C { elemType := C.g_type_info_get_param_type(argType, 0) elemTypeTag := C.g_type_info_get_tag(elemType) p(" %s", fromGStr(C.g_type_tag_to_string(elemTypeTag))) } } p("\n") } */ // return returnType := C.g_callable_info_get_return_type(asCallableInfo(info)) _ = returnType //TODO same as arg type mayReturnNull := C.g_callable_info_may_return_null(asCallableInfo(info)) == True _ = mayReturnNull skipReturn := C.g_callable_info_skip_return(asCallableInfo(info)) == True _ = skipReturn }