Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use & when passing function references to HashTable constructor #1728

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/gx/tilix/terminal/monitor.d
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ enum SLEEP_CONSTANT_MS = 300;
/**
* List of processes being monitored.
*/
shared ProcessStatus[GPid] processes;
shared(ProcessStatus)[GPid] processes;

void monitorProcesses(int sleep, Tid tid) {
bool abort = false;
Expand Down
4 changes: 2 additions & 2 deletions source/gx/tilix/terminal/password.d
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private:
string uuid = randomUUID().toString();
pending[uuid] = c;
import gtkc.glib;
HashTable attributes = new HashTable(g_str_hash, g_str_equal);
HashTable attributes = new HashTable(&g_str_hash, &g_str_equal);
immutable(char*) uuidz = toStringz(uuid);
attributes.insert(cast(void*)attrID, cast(void*)uuidz);
attributes.insert(cast(void*)attrDescription, cast(void*)descriptionValue);
Expand Down Expand Up @@ -285,7 +285,7 @@ private:

HashTable createHashTable() {
import gtkc.glib;
return new HashTable(g_str_hash, g_str_equal);
return new HashTable(&g_str_hash, &g_str_equal);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ref is a keyword in function signatures, not in calls??

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you need this then do it in the function call. I assume this error will propagate to other calls, right? Or is it context specific? If then then this is fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HashTable is obviously not a Tilix type, the constructor we're calling here is GtkD's wrapper around g_hash_table_new, we're giving it pointers to C functions (which g_str_hash and _equal are)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it seems this is the correct approach, I wish GtkD would provide more type safety.

}

void createSchema() {
Expand Down