Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2199] [android] v8 optional float/double argument failure

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2013-04-01T22:14:24.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, arguments, kroll, optional, v8
ReporterMartin Guillon
AssigneeDaniel Sefton
Created2012-11-22T14:26:26.000+0000
Updated2016-03-08T07:41:11.000+0000

Description

I am trying to add default values support to Ti.App.Properties. Something like this
@Kroll.method
public double getDouble(String key, @Kroll.argument(optional=true) double defaultValue)
{
	return appProperties.getDouble(key, defaultValue);
}
If i try to compile with that code i get an error:
[exec] src/native/../../generated/ti.modules.titanium.app.properties.PropertiesModule.cpp:314:22: error: invalid suffix "d" on integer constant
[exec] make: *** [/Volumes/data/dev/titanium/titanium_mobile/android/runtime/v8/obj/local/armeabi/objs/kroll-v8/__/__/generated/ti.modules.titanium.app.properties.PropertiesModule.o] Error 1
[exec] make: *** Waiting for unfinished jobs....

Comments

  1. Martin Guillon 2012-11-22

    I had another at this using another method
       @Kroll.method
       public double getDouble(String key, @Kroll.argument(optional=true) Object obj)
       {
       	double defaultValue = 0D;
       	if (obj != null) {
       		defaultValue = TiConvert.toDouble(obj);
       	}
       	return appProperties.getDouble(key, defaultValue);
       }
       
    And it worked. I am actually wondering if what i was doing was correct :s
  2. Pedro Enrique 2013-04-01

    For assistance, please use the Q&A: http://developer.appcelerator.com/questions/newest
  3. Szymon Tomasz Stefanek 2014-10-22

    This bug is still present in 3.4.0GA. The cpp code generator adds invalid suffixes on float and double optional Kroll.arguments.

JSON Source