dictionary_helper_gen.py doesn't handle 'unsigned long' types

RESOLVED FIXED

Status

()

Core
XPConnect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: mikeh, Assigned: smaug)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 4 obsolete attachments)

Steps to reproduce:
1. edit an IDL to include a dictionary with 'unsigned long' types, e.g.:
dictionary Foo {
  unsigned long bar;
};
2. modify dictionary_helper_gen.conf to include your IDL;
3. make

Expected behaviour: should handle unsigned long types.

Observed behaviour:
Traceback (most recent call last):
  File "/home/mikeh/dev/mozilla/btg011/gecko/config/pythonpath.py", line 56, in <module>
    main(sys.argv[1:])
  File "/home/mikeh/dev/mozilla/btg011/gecko/config/pythonpath.py", line 48, in main
    execfile(script, frozenglobals)
  File "/home/mikeh/dev/mozilla/btg011/gecko/js/xpconnect/src/dictionary_helper_gen.py", line 464, in <module>
    print_cpp_file(outfd, conf)
  File "/home/mikeh/dev/mozilla/btg011/gecko/js/xpconnect/src/dictionary_helper_gen.py", line 247, in print_cpp_file
    print_cpp(idl, fd, conf, d[0], dicts)
  File "/home/mikeh/dev/mozilla/btg011/gecko/js/xpconnect/src/dictionary_helper_gen.py", line 188, in print_cpp
    write_cpp(p, fd)
  File "/home/mikeh/dev/mozilla/btg011/gecko/js/xpconnect/src/dictionary_helper_gen.py", line 401, in write_cpp
    write_getter(a, iface, fd)
  File "/home/mikeh/dev/mozilla/btg011/gecko/js/xpconnect/src/dictionary_helper_gen.py", line 341, in write_getter
    raise BaseException("Unsupported type %s found in dictionary %s" % (realtype, iface.name))
BaseException: Unsupported type PRUint32  found in dictionary Dimensions
make[7]: *** [DictionaryHelpers.cpp] Error 1
make[7]: *** Deleting file `DictionaryHelpers.cpp'
make[6]: *** [libs] Error 2
make[5]: *** [libs_tier_platform] Error 2
make[4]: *** [tier_platform] Error 2
make[3]: *** [default] Error 2
make[2]: *** [realbuild] Error 2
make[1]: *** [build] Error 2

Note: signed 'long' works fine.
Created attachment 645502 [details] [diff] [review]
patch
Created attachment 645508 [details] [diff] [review]
patch
Attachment #645502 - Attachment is obsolete: true
Btw, this stuff used to work when dictionaries used XPCOM stuff.
Created attachment 645513 [details] [diff] [review]
with commit message

At least it compiles :)
Assignee: nobody → bugs
Attachment #645513 - Flags: review?(khuey)
Compiles and runs as expected.
> +    elif realtype.count("PRUint32"):
> +        fd.write("    uint32_t u;\n")
> +        fd.write("    NS_ENSURE_STATE(JS_ValueToECMAUint32(aCx, v, &u));\n")
> +        fd.write("    aDict.%s = u;\n" % a.name)
You can pass |aDict.%s| directly to JS_ValueToECMAUint32 instead of using a temporary variable.
https://mxr.mozilla.org/mozilla-central/source/js/xpconnect/src/XPCConvert.cpp?rev=0581a34dde2a#412
emk, want to upload such patch? I could review it immediately ;)
Sorry, I'm about to go out. Plaese create a patch yourself.
Created attachment 645561 [details] [diff] [review]
patch
Attachment #645508 - Attachment is obsolete: true
Attachment #645513 - Attachment is obsolete: true
Attachment #645513 - Flags: review?(khuey)
Attachment #645561 - Flags: review?(khuey)
Comment on attachment 645561 [details] [diff] [review]
patch

too hard to get this 2 line patch right :/
Attachment #645561 - Attachment is obsolete: true
Attachment #645561 - Flags: review?(khuey)
Created attachment 645562 [details] [diff] [review]
patch
Attachment #645562 - Flags: review?(khuey)
Attachment #645562 - Flags: review?(khuey) → review+
Blocks: 740997
https://hg.mozilla.org/mozilla-central/rev/9792ee3e5244
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Created attachment 645936 [details] [diff] [review]
idl file using dictionaries
Attachment #645936 - Flags: feedback?(khuey)
Attachment #645936 - Flags: feedback?(bzbarsky)
Comment on attachment 645936 [details] [diff] [review]
idl file using dictionaries

Wrong bug?
Comment on attachment 645936 [details] [diff] [review]
idl file using dictionaries

interns :)
Attachment #645936 - Flags: feedback?(khuey)
Attachment #645936 - Flags: feedback?(bzbarsky)
wrong bug, sorry about that
You need to log in before you can comment on or make changes to this bug.