My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 262: function substring is null for a certain string
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Oct 2013


 
Reported by adrian.v...@googlemail.com, Oct 29, 2013
What steps will reproduce the problem?
that's difficult - its inside a bigger project and I couldn't find a reduced version that will reproduce this behavior.

I have a code snippet that shows the error in the application, but standalone the reduced version runs normal:

		var template: RuleTemplate = {
			name: "@border(@size=1)", //line.prefix,
			content: line.content,
			params: new Array(),
		}
		trace(template.name); // @border(@size=1)
		trace(Std.is(template.name, String)); // true
		trace(template.name.substring); // null
		trace("abc".substring(1)); // bc
		trace(template.name.substring(1)); // crash


What version of the product are you using? On what operating system?

hxcpp 3.0.3-beta, same problem on windows and linux. the code runs perfectly targeted to neko or flash



Oct 29, 2013
#1 adrian.v...@googlemail.com
maybe this helps:

I tried to find a workaround for the problem and changed my code:

	static public function parse(line: RuleIteratorResult): RuleTemplate {
		var template: RuleTemplate = {
			name: line.prefix,
			content: line.content,
			params: new Array(),
		}
		var name = template.name;
		trace(template.name);
		trace(Std.is(name, String));
		trace(name.substring);
		trace("abc".substring(1));
		trace(name.substring(1));
		if ( name.charAt(0) == "@" ) 
			name = name.substring(1);
		var pOpen = name.indexOf("(");
		if (pOpen >= 0) {
			var pClose = name.lastIndexOf(")");
			if (pClose > pOpen) {
				var params = name.substring(pOpen + 1, pClose).split(",");
				name = name.substring(0, pOpen);
				for (p in params) {
					var pos = p.indexOf("=");
					var def = "";
					if (pos == -1) {
						pos = p.indexOf(":");
					} else {
						def = p.substring(pos + 1);
					}
					var vname = (pos >= 0) ? p.substring(0, pos): p;
					vname = name + "__" + (vname.charAt(0) == "@" ? vname.substring(1): vname);
					template.params.push({name: vname, def: def});
				}
			} else {
				trace('warning $name has open parenthesis');
				name = name.substring(0, pOpen);
			}
		}		
		template.name = name;
		return template;
	}

now the compilation of the generated cpp fails with:

cl.exe -Iinclude -nologo -Od /WX- /fp:precise -DHX_WINDOWS -GR -Zi -Oy- -c -EHs -IC:\Motion-Twin\Haxe\lib\hxcpp\3,0,3-beta//include -DHXCPP_DEBUG -DHXCPP_VISIT_ALLOCS -D_CRT_SECURE_NO_DEPRECATE -wd4996 -MT -Yuhxcpp.h /Fpobj/mscv17-debug/__pch/haxe/hxcpp.pch ./src/Main.cpp -Foobj/mscv17-debug/src/Main.obj

Main.cpp

./src/Main.cpp(77) : error C2039: 'substring_dyn': Ist kein Element von 'String' 
= is not an element of String

        c:\motion-twin\haxe\lib\hxcpp\3,0,3-beta\include\hxString.h(17): Siehe Deklaration von 'String'
= see declaration of String

Called from ? line 1
Called from BuildTool.hx line 1536
Called from BuildTool.hx line 673
Called from BuildTool.hx line 708
Called from BuildTool.hx line 845
Called from BuildTool.hx line 942
Uncaught exception - Error in building thread
Error: Build failed

Oct 29, 2013
#2 adrian.v...@googlemail.com
sorry for the noise, but the second error came from that line:
trace(name.substring);

the workaround works ! 
Oct 29, 2013
Project Member #3 gameh...@gmail.com
Thanks - this should be fixed in the svn version of hxcpp.

Status: Fixed

Powered by Google Project Hosting