Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Dlang
gtkd
Commits
dd08ce6a
Commit
dd08ce6a
authored
Mar 27, 2021
by
Mike Wey
Browse files
Set the correct pointer for setting functions of a parentStruct.
Fixes: #326
parent
4f62b29b
Changes
2
Hide whitespace changes
Inline
Side-by-side
generated/gtkd/gtkd/Implement.d
View file @
dd08ce6a
...
...
@@ -106,8 +106,7 @@ template ImplementClassImpl(Klass, Impl)
"\t"
~
Klass
.
stringof
~
"Class parentClass;\n"
~
"}\n\n"
;
result
~=
"protected "
~
toPascalCase
!
Impl
()
~
"* "
~
toCamelCase
!
Impl
()
~
";\n"
~
"protected static "
~
Klass
.
stringof
~
"Class* parentClass = null;\n\n"
;
result
~=
"protected "
~
toPascalCase
!
Impl
()
~
"* "
~
toCamelCase
!
Impl
()
~
";\n\n"
;
result
~=
"protected override void* getStruct()\n"
~
"{\n"
~
...
...
@@ -145,7 +144,7 @@ template ImplementClassImpl(Klass, Impl)
{
result
~=
"static void "
~
toCamelCase
!
Impl
()
~
"ClassInit (void* klass)\n"
~
"{\n"
~
"\t
parentClass = cast("
~
Klass
.
stringof
~
"Class*) g_type_class_peek_parent(
klass
)
;\n"
;
"\t
"
~
fullyQualifiedName
!(
getClass
!
Klass
)
~
"* "
~
toCamelCase
!(
getClass
!
Klass
)()
~
" = cast("
~
fullyQualifiedName
!(
getClass
!
Klass
)
~
"*)
klass;\n"
;
result
~=
setFunctionPointers
!(
getClass
!
Klass
)();
...
...
@@ -175,10 +174,7 @@ template ImplementClassImpl(Klass, Impl)
!
implements
!
Impl
(
toCamelCase
!
Impl
()
~
names
[
i
].
capitalizeFirst
)
)
//TODO: __traits(isOverrideFunction, Foo.foo) ?
{
static
if
(
is
(
GtkClass
==
getClass
!
Klass
)
)
result
~=
"\tparentClass."
~
names
[
i
]
~
" = &"
~
toCamelCase
!
Impl
()
~
names
[
i
].
capitalizeFirst
~
";\n"
;
else
result
~=
"\t"
~
toCamelCase
!
GtkClass
()
~
"."
~
names
[
i
]
~
" = &"
~
toCamelCase
!
Impl
()
~
names
[
i
].
capitalizeFirst
~
";\n"
;
result
~=
"\t"
~
toCamelCase
!
GtkClass
()
~
"."
~
names
[
i
]
~
" = &"
~
toCamelCase
!
Impl
()
~
names
[
i
].
capitalizeFirst
~
";\n"
;
}
}
...
...
@@ -209,16 +205,6 @@ template ImplementClassImpl(Klass, Impl)
return
result
;
}
template
getClass
(
Instance
)
{
mixin
(
"import "
~
getClassImport
!
Instance
()
~
"; alias getClass = "
~
Instance
.
stringof
~
"Class;"
);
}
private
string
getClassImport
(
Klass
)()
{
return
fullyQualifiedName
!
Klass
.
replace
(
"."
~
Klass
.
stringof
,
""
);
}
}
template
ImplementInterfaceImpl
(
Base
,
Klass
,
Impl
)
...
...
@@ -248,8 +234,7 @@ template ImplementInterfaceImpl(Base, Klass, Impl)
"\t"
~
Base
.
stringof
~
"Class parentClass;\n"
~
"}\n\n"
;
result
~=
"protected "
~
toPascalCase
!
Impl
()
~
"* "
~
toCamelCase
!
Impl
()
~
";\n"
~
"protected static "
~
Base
.
stringof
~
"Class* parentClass = null;\n\n"
;
result
~=
"protected "
~
toPascalCase
!
Impl
()
~
"* "
~
toCamelCase
!
Impl
()
~
";\n\n"
;
result
~=
"protected override void* getStruct()\n"
~
"{\n"
~
...
...
@@ -306,7 +291,7 @@ template ImplementInterfaceImpl(Base, Klass, Impl)
{
result
~=
"static void "
~
toCamelCase
!
Impl
()
~
"ClassInit (void* klass)\n"
~
"{\n"
~
"\t
parentClass = cast("
~
Base
.
stringof
~
"Class*) g_type_class_peek_parent(
klass
)
;\n"
~
"\t
"
~
fullyQualifiedName
!(
getClass
!
Base
)
~
"* "
~
toCamelCase
!(
getClass
!
Base
)()
~
" = cast("
~
fullyQualifiedName
!(
getClass
!
Base
)
~
"*)
klass;\n"
~
"}\n\n"
;
}
...
...
@@ -370,6 +355,16 @@ private string getTypeImport(Iface)()
return
fullyQualifiedName
!
Iface
.
replace
(
"types."
~
Iface
.
stringof
,
"functions"
);
}
template
getClass
(
Instance
)
{
mixin
(
"import "
~
getClassImport
!
Instance
()
~
"; alias getClass = "
~
Instance
.
stringof
~
"Class;"
);
}
private
string
getClassImport
(
Klass
)()
{
return
fullyQualifiedName
!
Klass
.
replace
(
"."
~
Klass
.
stringof
,
""
);
}
private
string
getWrapFunction
(
Impl
,
Member
,
string
name
)()
{
string
result
;
...
...
src/gtkd/Implement.d
View file @
dd08ce6a
...
...
@@ -87,6 +87,7 @@ template ImplementClassImpl(Klass, Impl)
string
result
;
result
~=
"import glib.Str;\n"
~
"import gobject.ObjectG;\n"
~
"import gobject.Type : Type;\n"
~
"import gobject.c.functions : g_type_class_peek_parent, g_object_get_data;\n"
;
...
...
@@ -105,8 +106,7 @@ template ImplementClassImpl(Klass, Impl)
"\t"
~
Klass
.
stringof
~
"Class parentClass;\n"
~
"}\n\n"
;
result
~=
"protected "
~
toPascalCase
!
Impl
()
~
"* "
~
toCamelCase
!
Impl
()
~
";\n"
~
"protected static "
~
Klass
.
stringof
~
"Class* parentClass = null;\n\n"
;
result
~=
"protected "
~
toPascalCase
!
Impl
()
~
"* "
~
toCamelCase
!
Impl
()
~
";\n\n"
;
result
~=
"protected override void* getStruct()\n"
~
"{\n"
~
...
...
@@ -144,7 +144,7 @@ template ImplementClassImpl(Klass, Impl)
{
result
~=
"static void "
~
toCamelCase
!
Impl
()
~
"ClassInit (void* klass)\n"
~
"{\n"
~
"\t
parentClass = cast("
~
Klass
.
stringof
~
"Class*) g_type_class_peek_parent(
klass
)
;\n"
;
"\t
"
~
fullyQualifiedName
!(
getClass
!
Klass
)
~
"* "
~
toCamelCase
!(
getClass
!
Klass
)()
~
" = cast("
~
fullyQualifiedName
!(
getClass
!
Klass
)
~
"*)
klass;\n"
;
result
~=
setFunctionPointers
!(
getClass
!
Klass
)();
...
...
@@ -205,16 +205,6 @@ template ImplementClassImpl(Klass, Impl)
return
result
;
}
template
getClass
(
Instance
)
{
mixin
(
"import "
~
getClassImport
!
Instance
()
~
"; alias getClass = "
~
Instance
.
stringof
~
"Class;"
);
}
private
string
getClassImport
(
Klass
)()
{
return
fullyQualifiedName
!
Klass
.
replace
(
"."
~
Klass
.
stringof
,
""
);
}
}
template
ImplementInterfaceImpl
(
Base
,
Klass
,
Impl
)
...
...
@@ -244,8 +234,7 @@ template ImplementInterfaceImpl(Base, Klass, Impl)
"\t"
~
Base
.
stringof
~
"Class parentClass;\n"
~
"}\n\n"
;
result
~=
"protected "
~
toPascalCase
!
Impl
()
~
"* "
~
toCamelCase
!
Impl
()
~
";\n"
~
"protected static "
~
Base
.
stringof
~
"Class* parentClass = null;\n\n"
;
result
~=
"protected "
~
toPascalCase
!
Impl
()
~
"* "
~
toCamelCase
!
Impl
()
~
";\n\n"
;
result
~=
"protected override void* getStruct()\n"
~
"{\n"
~
...
...
@@ -302,7 +291,7 @@ template ImplementInterfaceImpl(Base, Klass, Impl)
{
result
~=
"static void "
~
toCamelCase
!
Impl
()
~
"ClassInit (void* klass)\n"
~
"{\n"
~
"\t
parentClass = cast("
~
Base
.
stringof
~
"Class*) g_type_class_peek_parent(
klass
)
;\n"
~
"\t
"
~
fullyQualifiedName
!(
getClass
!
Base
)
~
"* "
~
toCamelCase
!(
getClass
!
Base
)()
~
" = cast("
~
fullyQualifiedName
!(
getClass
!
Base
)
~
"*)
klass;\n"
~
"}\n\n"
;
}
...
...
@@ -366,6 +355,16 @@ private string getTypeImport(Iface)()
return
fullyQualifiedName
!
Iface
.
replace
(
"types."
~
Iface
.
stringof
,
"functions"
);
}
template
getClass
(
Instance
)
{
mixin
(
"import "
~
getClassImport
!
Instance
()
~
"; alias getClass = "
~
Instance
.
stringof
~
"Class;"
);
}
private
string
getClassImport
(
Klass
)()
{
return
fullyQualifiedName
!
Klass
.
replace
(
"."
~
Klass
.
stringof
,
""
);
}
private
string
getWrapFunction
(
Impl
,
Member
,
string
name
)()
{
string
result
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment