Beispiel #1
0
func cppFunctionSignal(f *parser.Function) string {
	return fmt.Sprintf("void Signal_%v(%v){callback%v%v(%v);}", strings.Title(f.Name), converter.CppBodyInputCallback(f), f.Class(), strings.Title(f.Name), converter.CppBodyOutputCallback(f))
}
Beispiel #2
0
func cppFunctionSignal(f *parser.Function) string {

	//TODO: parse from docs
	var constP string
	if strings.Contains(strings.Split(f.Signature, ")")[1], "const") {
		constP = " const"
	}

	var originalInput string
	for _, p := range f.Parameters {
		if p.Name == "" {
			originalInput += "v, "
		} else {
			originalInput += fmt.Sprintf("%v, ", p.Name)
		}
	}
	originalInput = strings.TrimSuffix(originalInput, ", ")

	if strings.Contains(f.Virtual, "impure") && f.Output == "void" {
		if isDerivedFromPure(f) {
			return fmt.Sprintf("void %v(%v)%v { callback%v%v%v(%v); }", f.Name, converter.CppBodyInputCallback(f), constP, f.Class(), strings.Title(f.Name), cppFunctionSignalOverload(f), converter.CppBodyOutputCallback(f))
		} else {
			if f.Meta == "slot" || isDerivedFromSlot(f) {
				return fmt.Sprintf("void %v(%v)%v { if (!callback%v%v%v(%v)) { %v::%v(%v); }; }", f.Name, converter.CppBodyInputCallback(f), constP, f.Class(), strings.Title(f.Name), cppFunctionSignalOverload(f), converter.CppBodyOutputCallback(f), f.Class(), f.Name, originalInput)
			} else {
				return fmt.Sprintf("void %v(%v)%v { callback%v%v%v(%v); }", f.Name, converter.CppBodyInputCallback(f), constP, f.Class(), strings.Title(f.Name), cppFunctionSignalOverload(f), converter.CppBodyOutputCallback(f))
			}
		}
	}
	return fmt.Sprintf("void Signal_%v%v(%v) { callback%v%v%v(%v); }", strings.Title(f.Name), cppFunctionSignalOverload(f), converter.CppBodyInputCallback(f), f.Class(), strings.Title(f.Name), cppFunctionSignalOverload(f), converter.CppBodyOutputCallback(f))
}