func DumpArgInfo(info *C.GIArgInfo) { dataIndex := C.g_arg_info_get_closure(info) p("data index %d\n", dataIndex) destroyNotifyIndex := C.g_arg_info_get_destroy(info) p("destroy notify index %d\n", destroyNotifyIndex) direction := C.g_arg_info_get_direction(info) switch direction { case C.GI_DIRECTION_IN: p("in arg\n") case C.GI_DIRECTION_OUT: p("out arg\n") case C.GI_DIRECTION_INOUT: p("in out arg\n") } transfer := C.g_arg_info_get_ownership_transfer(info) p("transfer %s\n", TransferGetName(transfer)) scope := C.g_arg_info_get_scope(info) p("scope %v\n", scope) t := C.g_arg_info_get_type(info) DumpTypeInfo(t) mayBeNull := C.g_arg_info_may_be_null(info) p("may be null %v\n", mayBeNull) caller_allocates := C.g_arg_info_is_caller_allocates(info) p("caller allocates %v\n", caller_allocates) optional := C.g_arg_info_is_optional(info) p("optional %v\n", optional) isReturnValue := C.g_arg_info_is_return_value(info) p("is return value %v\n", isReturnValue) onlyUsefulInC := C.g_arg_info_is_skip(info) p("is only useful in C %v\n", onlyUsefulInC) }
// g_arg_info_get_direction func (ai *ArgInfo) Direction() Direction { return Direction(C.g_arg_info_get_direction((*C.GIArgInfo)(ai.c))) }
func (info *GiInfo) GetDirection() Direction { return (Direction)(C.g_arg_info_get_direction((*C.GIArgInfo)(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 }