Can't find implementation of gtk_menu_shell_get_type (gtk) - gtk

Can somebody tell me, how i can see implementation of gtk_menu_shell_get_type function and other common ..._get_type functions in gtk3? According to this documentation gtk+2.0-directfb i can see implementation of this, but there is no any info about it in gtk3. I've downloaded its one of the sources and only can see:
1. gtkmenushell.h:
define GTK_TYPE_MENU_SHELL (gtk_menu_shell_get_type ())
...
GDK_AVAILABLE_IN_ALL GType gtk_menu_shell_get_type (void) G_GNUC_CONST;
...
2. gtktypefuncs.c:
*tp++ = gtk_menu_shell_get_type();
I've spent a few days with this problem and can't understand, how can i get the implementation of this function, to see it realization clearly.
In other sources I've met there's no any "c" file with this function, only header. How can i see implementation of it and others like this ..._get_type function? Does anybody know this subtlety?
Thanks.

gtk_menu_shell_get_type function is defined in gtkmenushell.c. It's not declared directly. Instead, macro G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE is used to declare it.
See example for G_DEFINE_TYPE_EXTENDED.

Related

Xcode 8 Swift 3 Undefined symbols for architecture armv7

As I'm not allowed to add an answer to several duplicated questions, I will ask this question and give also one answer ;-)
The undefined symbol was a call to a self written swift function. This function sits in an swift file with only "global" functions (no class in that file). The function is called from several classes and all was good until this morning.
Suddenly I got this link-error message when producing the release product. The funny think was, it was only for ONE function call. All other calls got no errors, and when I commented out this particular function call, all was good. And this function is a very easy one. There is only one function parameter (Int64) and it returns a CLocationCoordinate2D.
I checked all possible solutions found here and at other places in the web. I even copied the function 1:1 as a local function inside the class.. nothing worked.
The final solution was the compiler flag for optimization. For release builds the flag in "Swift Compiler - Code Generation" is set to "Fast, Whole Module Optimization".
After changing that to "Fast, Single Module Optimization", everything worked ...
I think it is simply a bug in the optimization engine.
.. maybe that will help others in similar situations.

Swift 3 (Omit Needless Words) causing two functions to have the same name

In Swift 3.0, the automated changing of function names due to the "Omit Needless Words" rule has caused two functions in an ObjC class to be the same.
- (void)showLoader;
...and...
- (void)show __deprecated_msg("User 'showLoader'");
The problem is that these functions are within a third party Cocoa Pod (otherwise I would just delete the unnecessary 'show' function).
This results in getting the error "Ambiguous use of 'show'" when I try to invoke the function like this:
loader?.show()
Is there a way to reverse the automatic changing of function name in Swift 3.0 or to help the compiler know which function I want to invoke?
Thanks for your help!
See MartinR's answer to my similar question here: Converting to Swift 3 renamed my own Objective-C method
If you owned the code, you could use NS_SWIFT_NAME(showLoader()) after your method declaration to force the ObjC-to-Swift method conversion to be named what you want:
- (void)showLoader NS_SWIFT_NAME(showLoader());
I think it's worth mentioning even though in your case it doesn't exactly solve your problem because you don't own the code.
You can work around this by calling
loader?.perform(Selector("showLoader"))
You will see a warning from the compiler, but it will compile successfully, and things will work correctly at runtime.

Which header file defines Serial.begin?

I'm working on a small Arduino project. I need to know where the Serial functions like Serial.begin and Serial.read are defined. My IDE is complaining that these functions are undefined, so I want to point my IDE to the headers to get code assistance working properly (Netbeans).
Which header file defines these functions? Or how can I search to find them?
Serial.begin() is defined in the setup() function.
You have to give the baud rate in the Serial.begin() function.
For example, Serial.begin(9600)`.
Serial.read() can be defined anywhere in your loop() function.
It does not need to be defined if you used Serial.begin() in the setup() function already.
Hope that solves your problem :)
For more info check out the example on this website

Documentation of OCaml code in Eclipse

I'm using Eclipse with the OcaIDE-Plugin to write my ocaml-project.
I have written several ocaml-functions that I want to document (comment, return values and params).
I've created my documentation in the .ml-files like described in this link: http://caml.inria.fr/pub/docs/manual-ocaml/ocamldoc.html
Here is an example of one function:
(** sorting tuples where first element is key *)
let my_comp x y = (*Some code*)
Unfortunately, my comments don't show up, when I press F2 at one of the functions, it only shows the name and the file it is contained.
When writing comments in an mli-file, it works as expected, but i also want to document "private" functions that are not accessible from the outside. Can I define functions in the mli, that are NOT accessible from the outside, just for the documentation?
How can I make Eclipse to show my documention?
Well, as you said, you would like to show the documentation but not export the function out of the module. That, sadly, won't work.
I guess OcaIDE can be considered as incomplete but it doesn't look like it's something people care about (I don't know a single person working on OcaIDE). If you like having autocompletion etc, maybe try to program with emacs and install merlin (look, I found the perfect post for you : here)
As for the suggestion of defining a function in the mli not accessible from the outside, it's completely opposed to why mli files are created, so don't expect that to be possible. ;-)
I hoped I've been able to help you.

what makes a variable be visible (intellij idea)

With intellij idea, how do I find out what makes a variable be visible?
An example of when it is hard:
Suppose you look at class A, and you see a variable something. If you jump to source you see that it's defined in trait X. But you don't extend trait X directly. What do you extend, then, that makes this variable visible? If you have a deeply nested hierarchy, tracking can be hard.
Any recommendations or solutions?
EDIT: Please vote for the feature if you're interested: http://youtrack.jetbrains.com/issue/IDEA-124369
I don't think that IntelliJ IDEA has any shortcut for "finding what makes a variable visible".
However you can determine it using the "Find Usages" option (Alt + F7). For example:
import java.nio._
object TempObj extends App {
def func = 2
val p = file.Paths.get("some-path")
func
}
So Find Usages on "file", tells you that its from the Package "file" (in heading of the new Tab it also shows the complete package name, ex: Find Usages of java.nio.file in Project Files).
Whereas Find Usages on func will tell you that its a Method (And the Tab heading now says: Find Usages of func() in Project and Libraries)
So now in way you can determine, what exactly makes the variable visible. This also works for imports since it shows the package from which it is imported and you can then look for import of that packages.
I know of two almost-solutions to this problem.
Go-to-declaration, as you mentioned, solves this problem in the case of local variables.
More generally, the "find usages" feature gives you a neat little breakdown by type and file of different uses of the variable. From this you can see if it's involved in a static import.
It's not perfect, but with a moment's thought these two are generally sufficient to figure out what you want.
Use ctrl+b or F4 to jump to source code. Alternatively you can use ctrl+shift+a to get option/action. You can find shortcuts at http://gaerfield.github.io/ide-shortcuts/ as well. Hope it will help.
From what I understood you want to see the code that creates an Object you use, for instance Mystery someMystery;.
That gives you two options to populate someMystery:
someMystery = ... where ... is your code to populate
someMystery and if that is the case you should follow
that code (with ctrl+B as far as you need to) to the point where it
actually creates the Mystery object.
Use CDI to populate that object instance for you, in which case you should look into the CDI mechanism in order to see in what way the object instance is populated.
In either way IMO there is no way to know for sure if the someMystery instance is of some more concrete class than Mystery, because it is decided in runtime, not in compile time, so your next bet would be to run the program in debug and see what object goes into someMystery, although you are not guaranteed to get the same type of object every time.
PS. My answer is based entirely on my java understanding of the topic, can't say if it is valid for scala also.
This might not be exactly the answer you were hoping to get.
However, quoting yourself,
If you have a deeply nested hierarchy, tracking can be hard.
Have you considered using composition over inheritance? Perhaps this would remove the need for the feature you are looking for.
Deeply nested hierarchy doesn't sound good. I understand your pain about that.
When you override vals or defs there is a little circle next to the line number that shows where it is from even when it is from nested hierarchy. Hovering over vals with the command key down also shows you a little tooltip where it is from.
Does this help?
https://youtu.be/r3D9axSlBo8
if you want class, field or method to be visible, you need to implement them as public. If it was your question.