Giter Club home page Giter Club logo

Comments (3)

m0rkeulv avatar m0rkeulv commented on September 26, 2024

i've been playing around with the code and i got things working, but i am not a hundred percent sure i am not breaking anything. my changes are in safe cast, to me it looks like the issue is that since my other class contains a member that is first in the fields array it breaks and return false without checking if the expected fields are included.

this seems to work fine in what little tesiting i've done

case HVIRTUAL:
		if( to->virt->nfields < t->virt->nfields ) {
			int i, j;
			int matches = 0;
			for(i=0;i<to->virt->nfields;i++) {
				hl_obj_field *f2 = to->virt->fields + i;
				for(j=i; j < t->virt->nfields;j++) {
					hl_obj_field *f1 = t->virt->fields + j;
					if( f1->hashed_name == f2->hashed_name && hl_same_type(f1->t,f2->t) ) {
						matches++;
						break;
					}
				}
			}
			if( matches == to->virt->nfields )
				return true;
		}
		break;
		````

from hashlink.

ncannasse avatar ncannasse commented on September 26, 2024

from hashlink.

m0rkeulv avatar m0rkeulv commented on September 26, 2024

just adding this for some more context, to maybe help find a different root causeof my problem.
if i add this to hl_safe_cast

if (t->kind == HOBJ && to->kind == HVIRTUAL) {
		vdynamic * d =  *(vdynamic**)t->obj->global_value;
		vvirtual* conv = hl_to_virtual(to, d);
		return hl_safe_cast(conv->t, to);
	}

(must of course be before this line to have any effect)

if( t->kind != to->kind )
		return false;

the typedef example also runs just fine, but it feels more like the issue is related to hl_to_virtual and what effect null values for fields ( hl_vfields(v)[i] = NULL; ) has to the later execution.

before i modified the HVIRTUAL case in hl_safe_cast hl_to_virtual would set the field to NULL and this some how made the code try to execute a different method, maybe some kind of index missmatch between the real object type and the interface.

without the code above, the typdef seems to get the same problem, hl_vfields(v)[i] = NULL, and later on it throws an Access Violatio error.

from hashlink.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.